Serial.println(F("*** PRESS 'N' to reset the device"));
// Initialize the network device
networkDevice.initialize(deviceMac);
// Initialize the BME280 sensor
bme.settings.commInterface=I2C_MODE;
bme.settings.I2CAddress=0x76;
bme.settings.runMode=3;
bme.settings.tStandby=0;
bme.settings.filter=0;
bme.settings.tempOverSample=1;
bme.settings.pressOverSample=1;
bme.settings.humidOverSample=1;
Serial.print("Starting BME280... result of .begin(): 0x");
//Calling .begin() causes the settings to be loaded
delay(10);//Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
Serial.println(bme.begin(),HEX);
}
voidloop(){
if(Serial.available())
{
charc=toupper(Serial.read());
if(c=='N'){
networkDevice.resetData();
}
}
// Call this in the loop() function to maintain the network device
networkDevice.update();
// Send a message to the master every 4 seconds
if(lastWait<millis()){
floatfTemp=bme.readTempC();
Serial.print("Temperature: ");
Serial.print(fTemp,2);
Serial.println(" degrees C");
floatfPressure=bme.readFloatPressure();
Serial.print("Pressure: ");
Serial.print(fPressure,2);
Serial.println(" Pa");
floatfHumidity=bme.readFloatHumidity();
Serial.print("%RH: ");
Serial.print(fHumidity,2);
Serial.println(" %");
bytemessage[10+(3*4)];// the first 10 bytes containing the type of the sensor. The 3*4 bytes are needed for the values. float has a length of 32 bits = 4 bytes and we need 3 of them.