Last seen?
-
Hello,
I have a problem with a sensor that is not updating in the dashboard. In the hardware setup page for mysensors gateway v2.0 I see "last seen" update every 10 sec. But under device I can see the device but it doesn't update more then once. "Last seen" in device page doesn't update. So the temperature doesn't update in the dashboard. What am I doing wrong? I'm kind of new at this.
The sketch looks like this:
/******************************************************************************
I2C_ReadAllData.ino
BME280 Arduino and Teensy example
Marshall Taylor @ SparkFun Electronics
May 20, 2015
https://github.com/sparkfun/SparkFun_BME280_Arduino_LibraryThis sketch configures the BME280 to read all measurements. The sketch also
displays the BME280's physical memory and what the driver perceives the
calibration words to be.Resources:
Uses Wire.h for I2C operation
Uses SPI.h for SPI operationDevelopment environment specifics:
Arduino IDE 1.6.4
Teensy loader 1.23This code is released under the MIT License.
Please review the LICENSE.md file included with this example. If you have any questions
or concerns with licensing, please contact techsupport@sparkfun.com.
Distributed as-is; no warranty is given.
******************************************************************************/#include <stdint.h>
#include "SparkFunBME280.h"
//Library allows either I2C or SPI, so include both.
#include "Wire.h"
#include "SPI.h"#define MY_DEBUG
#define MY_RADIO_NRF24
#include <MySensors.h>#define SKETCH_NAME "Environment Sensor"
#define SKETCH_MAJOR_VER "1"
#define SKETCH_MINOR_VER "0"
#define CHILD_ID_1 1
#define CHILD_ID_2 2
#define CHILD_ID_3 3//Global sensor object
BME280 Sensor;MyMessage msg1(CHILD_ID_1, V_TEMP);
MyMessage msg2(CHILD_ID_2, V_HUM);
MyMessage msg3(CHILD_ID_3, V_PRESSURE);void setup()
{
//Driver settings*****************************//
//commInterface can be I2C_MODE or SPI_MODE
//specify chipSelectPin using arduino pin names
//specify I2C address. Can be 0x77(default) or 0x76//For I2C, enable the following and disable the SPI section Sensor.settings.commInterface = I2C_MODE; Sensor.settings.I2CAddress = 0x77; //For SPI enable the following and dissable the I2C section //Sensor.settings.commInterface = SPI_MODE; //Sensor.settings.chipSelectPin = 10; //***Operation settings*****************************// //renMode can be: // 0, Sleep mode // 1 or 2, Forced mode // 3, Normal mode Sensor.settings.runMode = 3; //Normal mode //tStandby can be: // 0, 0.5ms // 1, 62.5ms // 2, 125ms // 3, 250ms // 4, 500ms // 5, 1000ms // 6, 10ms // 7, 20ms Sensor.settings.tStandby = 5; //filter can be off or number of FIR coefficients to use: // 0, filter off // 1, coefficients = 2 // 2, coefficients = 4 // 3, coefficients = 8 // 4, coefficients = 16 Sensor.settings.filter = 0; //tempOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.tempOverSample = 1; //pressOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.pressOverSample = 1; //humidOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.humidOverSample = 1;
// Serial.begin(57600);
Serial.print("Program Started\n");
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(Sensor.begin(), HEX); Serial.print("Displaying ID, reset and ctrl regs\n"); Serial.print("ID(0xD0): 0x"); Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX); Serial.print("Reset register(0xE0): 0x"); Serial.println(Sensor.readRegister(BME280_RST_REG), HEX); Serial.print("ctrl_meas(0xF4): 0x"); Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX); Serial.print("ctrl_hum(0xF2): 0x"); Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX); Serial.print("\n\n"); Serial.print("Displaying all regs\n"); uint8_t memCounter = 0x80; uint8_t tempReadData; for(int rowi = 8; rowi < 16; rowi++ ) { Serial.print("0x"); Serial.print(rowi, HEX); Serial.print("0:"); for(int coli = 0; coli < 16; coli++ ) { tempReadData = Sensor.readRegister(memCounter); Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble Serial.print(" "); memCounter++; } Serial.print("\n"); } Serial.print("\n\n"); Serial.print("Displaying concatenated calibration words\n"); Serial.print("dig_T1, uint16: "); Serial.println(Sensor.calibration.dig_T1); Serial.print("dig_T2, int16: "); Serial.println(Sensor.calibration.dig_T2); Serial.print("dig_T3, int16: "); Serial.println(Sensor.calibration.dig_T3); Serial.print("dig_P1, uint16: "); Serial.println(Sensor.calibration.dig_P1); Serial.print("dig_P2, int16: "); Serial.println(Sensor.calibration.dig_P2); Serial.print("dig_P3, int16: "); Serial.println(Sensor.calibration.dig_P3); Serial.print("dig_P4, int16: "); Serial.println(Sensor.calibration.dig_P4); Serial.print("dig_P5, int16: "); Serial.println(Sensor.calibration.dig_P5); Serial.print("dig_P6, int16: "); Serial.println(Sensor.calibration.dig_P6); Serial.print("dig_P7, int16: "); Serial.println(Sensor.calibration.dig_P7); Serial.print("dig_P8, int16: "); Serial.println(Sensor.calibration.dig_P8); Serial.print("dig_P9, int16: "); Serial.println(Sensor.calibration.dig_P9); Serial.print("dig_H1, uint8: "); Serial.println(Sensor.calibration.dig_H1); Serial.print("dig_H2, int16: "); Serial.println(Sensor.calibration.dig_H2); Serial.print("dig_H3, uint8: "); Serial.println(Sensor.calibration.dig_H3); Serial.print("dig_H4, int16: "); Serial.println(Sensor.calibration.dig_H4); Serial.print("dig_H5, int16: "); Serial.println(Sensor.calibration.dig_H5); Serial.print("dig_H6, uint8: "); Serial.println(Sensor.calibration.dig_H6); Serial.println();
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER);// Register binary input sensor to sensor_node (they will be created as child devices)
// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage.
// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
present(CHILD_ID_1, S_TEMP);
present(CHILD_ID_2, S_HUM);
present(CHILD_ID_3, S_BARO);}
void loop()
{
//Each loop, take a reading.
//Start with temperature, as that data is needed for accurate compensation.
//Reading the temperature updates the compensators of the other functions
//in the background./* Serial.print("Temperature: ");
Serial.print(Sensor.readTempC(), 2);
Serial.println(" degrees C");Serial.print("Temperature: "); Serial.print(Sensor.readTempF(), 2); Serial.println(" degrees F"); Serial.print("Pressure: "); Serial.print(Sensor.readFloatPressure(), 2); Serial.println(" Pa"); Serial.print("Altitude: "); Serial.print(Sensor.readFloatAltitudeMeters(), 2); Serial.println("m"); Serial.print("Altitude: "); Serial.print(Sensor.readFloatAltitudeFeet(), 2); Serial.println("ft"); Serial.print("%RH: "); Serial.print(Sensor.readFloatHumidity(), 2); Serial.println(" %"); Serial.println(); delay(1000);
*/
int temperature; int humidity; long pressure; temperature=Sensor.readTempC(); humidity=Sensor.readFloatHumidity(); pressure=Sensor.readFloatPressure(); send(msg1.set(temperature)); send(msg2.set(humidity)); send(msg3.set(pressure)); sleep(10000);
}
-
@kk02067 please enclose the sketch in a "code block" to allow easy reading... you can also put 3 tick marks (back quote ` ) on both sides of the code
What does you debug on the serial output of the node tell you? (also enclose in code block ;-))
-
Thanks for your reply and tips to a beginner.
I experimented with a couple of things in the sketch and after a little digging I seem to have got it working.
The problem seem to be that if the values sent to the gateway is not in the correct format it wont work. If I send just one value in integer it works. But if I send alla three values as integer it stops working. If I send all three as "double" with two decimals it works as it should.
The sketch when it functions as it should:
/****************************************************************************** I2C_ReadAllData.ino BME280 Arduino and Teensy example Marshall Taylor @ SparkFun Electronics May 20, 2015 https://github.com/sparkfun/SparkFun_BME280_Arduino_Library This sketch configures the BME280 to read all measurements. The sketch also displays the BME280's physical memory and what the driver perceives the calibration words to be. Resources: Uses Wire.h for I2C operation Uses SPI.h for SPI operation Development environment specifics: Arduino IDE 1.6.4 Teensy loader 1.23 This code is released under the [MIT License](http://opensource.org/licenses/MIT). Please review the LICENSE.md file included with this example. If you have any questions or concerns with licensing, please contact techsupport@sparkfun.com. Distributed as-is; no warranty is given. ******************************************************************************/ #include <stdint.h> #include "SparkFunBME280.h" //Library allows either I2C or SPI, so include both. #include "Wire.h" #include "SPI.h" #define MY_DEBUG #define MY_RADIO_NRF24 #include <MySensors.h> #define SKETCH_NAME "Environment Sensor" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "0" #define CHILD_ID_1 1 #define CHILD_ID_2 2 #define CHILD_ID_3 3 //Global sensor object BME280 Sensor; MyMessage msg1(CHILD_ID_1, V_TEMP); MyMessage msg2(CHILD_ID_2, V_HUM); MyMessage msg3(CHILD_ID_3, V_PRESSURE); void setup() { //***Driver settings********************************// //commInterface can be I2C_MODE or SPI_MODE //specify chipSelectPin using arduino pin names //specify I2C address. Can be 0x77(default) or 0x76 //For I2C, enable the following and disable the SPI section Sensor.settings.commInterface = I2C_MODE; Sensor.settings.I2CAddress = 0x77; //For SPI enable the following and dissable the I2C section //Sensor.settings.commInterface = SPI_MODE; //Sensor.settings.chipSelectPin = 10; //***Operation settings*****************************// //renMode can be: // 0, Sleep mode // 1 or 2, Forced mode // 3, Normal mode Sensor.settings.runMode = 3; //Normal mode //tStandby can be: // 0, 0.5ms // 1, 62.5ms // 2, 125ms // 3, 250ms // 4, 500ms // 5, 1000ms // 6, 10ms // 7, 20ms Sensor.settings.tStandby = 5; //filter can be off or number of FIR coefficients to use: // 0, filter off // 1, coefficients = 2 // 2, coefficients = 4 // 3, coefficients = 8 // 4, coefficients = 16 Sensor.settings.filter = 0; //tempOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.tempOverSample = 1; //pressOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.pressOverSample = 1; //humidOverSample can be: // 0, skipped // 1 through 5, oversampling *1, *2, *4, *8, *16 respectively Sensor.settings.humidOverSample = 1; // Serial.begin(57600); Serial.print("Program Started\n"); 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(Sensor.begin(), HEX); Serial.print("Displaying ID, reset and ctrl regs\n"); Serial.print("ID(0xD0): 0x"); Serial.println(Sensor.readRegister(BME280_CHIP_ID_REG), HEX); Serial.print("Reset register(0xE0): 0x"); Serial.println(Sensor.readRegister(BME280_RST_REG), HEX); Serial.print("ctrl_meas(0xF4): 0x"); Serial.println(Sensor.readRegister(BME280_CTRL_MEAS_REG), HEX); Serial.print("ctrl_hum(0xF2): 0x"); Serial.println(Sensor.readRegister(BME280_CTRL_HUMIDITY_REG), HEX); Serial.print("\n\n"); Serial.print("Displaying all regs\n"); uint8_t memCounter = 0x80; uint8_t tempReadData; for(int rowi = 8; rowi < 16; rowi++ ) { Serial.print("0x"); Serial.print(rowi, HEX); Serial.print("0:"); for(int coli = 0; coli < 16; coli++ ) { tempReadData = Sensor.readRegister(memCounter); Serial.print((tempReadData >> 4) & 0x0F, HEX);//Print first hex nibble Serial.print(tempReadData & 0x0F, HEX);//Print second hex nibble Serial.print(" "); memCounter++; } Serial.print("\n"); } Serial.print("\n\n"); Serial.print("Displaying concatenated calibration words\n"); Serial.print("dig_T1, uint16: "); Serial.println(Sensor.calibration.dig_T1); Serial.print("dig_T2, int16: "); Serial.println(Sensor.calibration.dig_T2); Serial.print("dig_T3, int16: "); Serial.println(Sensor.calibration.dig_T3); Serial.print("dig_P1, uint16: "); Serial.println(Sensor.calibration.dig_P1); Serial.print("dig_P2, int16: "); Serial.println(Sensor.calibration.dig_P2); Serial.print("dig_P3, int16: "); Serial.println(Sensor.calibration.dig_P3); Serial.print("dig_P4, int16: "); Serial.println(Sensor.calibration.dig_P4); Serial.print("dig_P5, int16: "); Serial.println(Sensor.calibration.dig_P5); Serial.print("dig_P6, int16: "); Serial.println(Sensor.calibration.dig_P6); Serial.print("dig_P7, int16: "); Serial.println(Sensor.calibration.dig_P7); Serial.print("dig_P8, int16: "); Serial.println(Sensor.calibration.dig_P8); Serial.print("dig_P9, int16: "); Serial.println(Sensor.calibration.dig_P9); Serial.print("dig_H1, uint8: "); Serial.println(Sensor.calibration.dig_H1); Serial.print("dig_H2, int16: "); Serial.println(Sensor.calibration.dig_H2); Serial.print("dig_H3, uint8: "); Serial.println(Sensor.calibration.dig_H3); Serial.print("dig_H4, int16: "); Serial.println(Sensor.calibration.dig_H4); Serial.print("dig_H5, int16: "); Serial.println(Sensor.calibration.dig_H5); Serial.print("dig_H6, uint8: "); Serial.println(Sensor.calibration.dig_H6); Serial.println(); } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER "." SKETCH_MINOR_VER); // Register binary input sensor to sensor_node (they will be created as child devices) // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. // If S_LIGHT is used, remember to update variable type you send in. See "msg" above. present(CHILD_ID_1, S_TEMP); present(CHILD_ID_2, S_HUM); present(CHILD_ID_3, S_BARO); } void loop() { //Each loop, take a reading. //Start with temperature, as that data is needed for accurate compensation. //Reading the temperature updates the compensators of the other functions //in the background. /* Serial.print("Temperature: "); Serial.print(Sensor.readTempC(), 2); Serial.println(" degrees C"); Serial.print("Temperature: "); Serial.print(Sensor.readTempF(), 2); Serial.println(" degrees F"); Serial.print("Pressure: "); Serial.print(Sensor.readFloatPressure(), 2); Serial.println(" Pa"); Serial.print("Altitude: "); Serial.print(Sensor.readFloatAltitudeMeters(), 2); Serial.println("m"); Serial.print("Altitude: "); Serial.print(Sensor.readFloatAltitudeFeet(), 2); Serial.println("ft"); Serial.print("%RH: "); Serial.print(Sensor.readFloatHumidity(), 2); Serial.println(" %"); Serial.println(); delay(1000); */ double temperature; double humidity; double pressure; temperature=Sensor.readTempC(); humidity=Sensor.readFloatHumidity(); pressure=Sensor.readFloatPressure()/100; send(msg1.set(temperature,2)); send(msg2.set(humidity,2)); Serial.print(humidity, 2); send(msg3.set(pressure,2)); sleep(10000); }```