 }
 
 void loop() {
+  if (!ISREADY(ENVIRONMENT_SENSOR)) {
+    // DHT library uses delay() internally, which can't be used in interrupts
+    environment_temperature = (byte)environment_sensor.readTemperature();
+    environment_humidity = (byte)environment_sensor.readHumidity();
+    READY(ENVIRONMENT_SENSOR);
+  }
   delay(100);
 }
 


void setup() {
  Wire.begin(I2C_ADDRESS); // join i2c channel
  Wire.onRequest(i2cRequest);
  Wire.onReceive(i2cReceive);
  READY(BOARD);

#ifdef DEBUG
  Serial.begin(9600);
#endif

  environment_sensor.begin();
  // not: READY(ENVIRONMENT_SENSOR);

#define PIN_ANALOG_I2C_SDA      4 // i2c enabled by jumper
#define PIN_ANALOG_I2C_SCL      5 // i2c enabled by jumper

// TODO: read these from Arduino Nano (protocol = ?)
long encoder_left_front = 0, encoder_left_back = 0,
     encoder_right_front = 0, encoder_right_back = 0;

DHT environment_sensor(PIN_ENVIRONMENT_SENSOR, DHT11);
byte environment_temperature, environment_humidity;
