Hi All;
I have built a small sensor to monitor our air quailty. It sends in Temp/Hum/Pressure data as well as particle counts and VOC levels. THe hardware is working fine, sending the data to the gateway and other devices without issue. The dust and voc sensors are created and updated without issue.
The pressure sensor is also created and updated correctly. However the temp/hum is very strange. When I start domoticz fresh it will register the packet and update the sensor but only one time. Later updates are shown in the mysensors hardware tab but are not updating the domoticz device. As well the temp/hum/pressure is not being grouped as once device which I suspect is a related issue.
Anyone have ideas?
BETA Version: 4.9796 Not creating Temp/Hum Sensor Topic is solved
Moderator: leecollings
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
Without more information, it's hard to pinpoint your problem. How does your sketch look like?
You have to register temp+hum seperatly. In domoticz they shout appear as WTGR800 Temp+Hum device.
You have to register temp+hum seperatly. In domoticz they shout appear as WTGR800 Temp+Hum device.
Code: Select all
MyMessage msgHum (CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void presentation()
{
sendSketchInfo("Temperature&Humidity", "1.0"); // Send the sketch version information to the gateway
present(CHILD_ID_HUM, S_HUM); // Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
-
- Posts: 12
- Joined: Friday 14 October 2016 10:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
Sorry i forget other people wont know the full story
. I've attached the sketch I am working one though it is a work in progress.
However I am pretty sure this is a domoticz side issue. The same problem occurs if I use a sketch from any of the other devices I have running. Temp/HUM does not get updated if it is even created. When they are created a Temp+HUM device is made. However it should be producing a temp+hum+pressure device. I had one previously (which I accidentally destroyed....) which worked like that and is how domoticz should handle the problem.
To re-iterate this problem as occurs with any other temp+hum sketches I have been using for over a year; but not with those that are already registered. The sketches are sending the data and domoticz will show this data in the hardware table for mysensors. however it is not updated the actual domoticz sensors for temp/hum
Edit: Here is also screenshots to show better what I am seeing in domoticz



However I am pretty sure this is a domoticz side issue. The same problem occurs if I use a sketch from any of the other devices I have running. Temp/HUM does not get updated if it is even created. When they are created a Temp+HUM device is made. However it should be producing a temp+hum+pressure device. I had one previously (which I accidentally destroyed....) which worked like that and is how domoticz should handle the problem.
To re-iterate this problem as occurs with any other temp+hum sketches I have been using for over a year; but not with those that are already registered. The sketches are sending the data and domoticz will show this data in the hardware table for mysensors. however it is not updated the actual domoticz sensors for temp/hum
Edit: Here is also screenshots to show better what I am seeing in domoticz


Code: Select all
// Enable debug prints
#define MY_DEBUG
//#define MY_DEBUG_VERBOSE
// Enabled repeater feature for this node
#define MY_RF24_CHANNEL 100
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
#define MY_NODE_ID 18
#define MY_BAUD_RATE 38400
//#define MY_SERIAL_OUTPUT_SIZE (60u)
//#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <Wire.h>
#include <MySensors.h>
#include "Adafruit_HTU21DF.h"
//#include "Adafruit_CCS811.h"
#include <SoftwareSerial.h>
#include "PMS.h"
#include "RunningAverage.h"
#include <SparkFunCCS811.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#define CCS811_ADDR 0x5A //Default I2C Address
// Force sending an update of the temperature after n sensor reads, so a controller showing the
// timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
// the value didn't change since;
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
//#define FORCE_UPDATE_N_READS = 1;
#define CHILD_ID_HUM 1
#define CHILD_ID_TEMP 0
#define CHILD_ID_PRESS 2
#define CHILD_ID_DUST_PM10 3
#define CHILD_ID_DUST_PM25 4
#define CHILD_ID_DUST_PM100 5
#define CHILD_ID_CO2 6
#define CHILD_ID_VOC 7
#define SKETCH_NAME "Air Quality Sensor"
#define SKETCH_VERSION "1"
#define THRESHOLD 0.9 // Only make a new reading with reverse polarity if the change is larger than 10%
//#define BATTERY_FULL 3143 // 2xAA usually gives 3.143V when full
//#define BATTERY_FULL 3.100 // CR2032 usually gives 3.1V when full
//#define BATTERY_ZERO 1.8 // 2.34V limit for 328p at 8MHz
//#include <Vcc.h>
bool dusting =false;
byte dustCount;
bool vocing = false;
byte vocCount;
unsigned long lastUpdateDust = -12000000;
unsigned long lastUpdateVOC = -12000000;
unsigned long lastUpdateTemp = -12000000;
// Sleep time between sensor updates (in milliseconds)
// Must be >1000ms for DHT22 and >2000ms for DHT11 dtostrf(message.getFloat(), 5, 1, outTemp);}
#define UPDATE_INTERVAL_DUST 3540000
#define DUST_SAMPLE_COUNT 4
#define DUST_DELAY 40000
#define UPDATE_INTERVAL_TEMP 3000
#define UPDATE_INTERVAL_VOC 3600000
#define VOC_SAMPLE_COUNT 4
#define VOC_DELAY 1200000
#define UPDATE_INTERVAL_VOC 2400000
int val = 0; // variable to store the value coming from the sensor
int temp;
//float lastDUSTPM25 = 0.0;
//float lastDUSTPM10 = 0.0;
//float lastDUSTPM100 = 0.0;
//float lastCO2 = 0.0;
//float lastVOC = 0.0;
Adafruit_BMP280 bme; //
RunningAverage pm25RA(DUST_SAMPLE_COUNT);
RunningAverage pm10RA(DUST_SAMPLE_COUNT);
RunningAverage pm100RA(DUST_SAMPLE_COUNT);
RunningAverage co2RA(VOC_SAMPLE_COUNT);
RunningAverage vocRA(VOC_SAMPLE_COUNT);
MyMessage msgT1(CHILD_ID_TEMP, V_TEMP);
MyMessage msgP1(CHILD_ID_PRESS, V_PRESSURE);
MyMessage msgH1(CHILD_ID_HUM, V_HUM);
MyMessage msgF1(CHILD_ID_PRESS, V_FORECAST);
MyMessage dustMsgPM10(CHILD_ID_DUST_PM10, V_LEVEL);
MyMessage dustMsgPM25(CHILD_ID_DUST_PM25, V_LEVEL);
MyMessage dustMsgPM100(CHILD_ID_DUST_PM100, V_LEVEL);
MyMessage co2Msg(CHILD_ID_CO2, V_LEVEL);
MyMessage vocMsg(CHILD_ID_VOC, V_LEVEL);
//SI7021 sensor;
Adafruit_HTU21DF htu = Adafruit_HTU21DF();
//Adafruit_CCS811 ccs;
CCS811 ccs(CCS811_ADDR);
SoftwareSerial mySerial(8, 7); // RX, TX
PMS pms(mySerial);
PMS::DATA data;
void presentation()
{
//Start MySensors and send the sketch version information to the gateway
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
//Register all sensors
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_TEMP, S_TEMP,"TEMP");
delay(50);
present(CHILD_ID_HUM, S_HUM,"HUM");
delay(50);
present(CHILD_ID_PRESS, S_BARO,"PRES");
delay(50);
present(CHILD_ID_DUST_PM10, S_DUST, "PM10");
delay(50);
present(CHILD_ID_DUST_PM25, S_DUST, "PM25");
delay(50);
present(CHILD_ID_DUST_PM100, S_DUST, "PM100");
delay(50);
present(CHILD_ID_CO2, S_AIR_QUALITY, "CO2");
delay(50);
present(CHILD_ID_VOC, S_AIR_QUALITY, "VOC");
delay(50);
// msgPM10.set("ug/m3");
// msgPM25.set("ug/m3");
// msgPM100.set("ug/m3");
}
void setup()
{
pm25RA.clear();
pm10RA.clear();
pm100RA.clear();
vocRA.clear();
co2RA.clear();
// myBME280.settings.commInterface = I2C_MODE;
// myBME280.settings.I2CAddress = 0x76;
// myBME280.settings.runMode = 3; //Normal mode
// myBME280.settings.tStandby = 0;
// myBME280.settings.filter = 4;
// myBME280.settings.tempOverSample = 5;
// myBME280.settings.pressOverSample = 5;
// myBME280.settings.humidOverSample = 5;
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
mySerial.begin(9600);
pms.passiveMode();
pms.wakeUp();
//pms.activeMode();
// if(!ccs.begin()){
// Serial.println("Failed to start sensor! Please check your wiring.");
// while(1);
// }
// while(!ccs.available());
// //float temp = ccs.calculateTemperature();
// //ccs.setTempOffset(temp - 25.0);
// ccs.setEnvironmentalData(40, 21);
// ccs.setDriveMode(CCS811_DRIVE_MODE_10SEC);
CCS811Core::status returnCode = ccs.begin();
Serial.print(F("CCS811 begin exited with: "));
//Pass the error code to a function to print the results
printDriverError( returnCode );
ccs.setDriveMode(2);
Serial.println();
delay(500);// just in case
// lastUpdate = 0;
}
void loop()
{
unsigned long start = millis();
//Serial.println("Wait max. 10 seconds for read...");
dust(start);
sendTemp(start);
voc(start);
}
void dust(unsigned long start)
{
//Serial.print(F("checking DUST: "));
//Serial.println((start - lastUpdateDust));
if (dusting ==0 & ((start - lastUpdateDust) >= UPDATE_INTERVAL_DUST))
{
dusting =true;
dustCount=0;
lastUpdateDust= millis();
pms.wakeUp();
//PMS WAKE
Serial.println(F("Starting DUST"));
}
else if (dusting && (dustCount>DUST_SAMPLE_COUNT))
{
send(dustMsgPM10.set(pm10RA.getAverage(), 1));
delay(50);
send(dustMsgPM25.set(pm25RA.getAverage(), 1));
delay(50);
send(dustMsgPM100.set(pm100RA.getAverage(), 1));
dusting=false;
delay(50);
pms.sleep();
lastUpdateDust= millis();
Serial.println(F("SLEEPING PMS"));
}
else if (dusting ==1 && ((start - lastUpdateDust) >= 40000))
{
Serial.println(F("Dusting count:"));
Serial.println(dustCount);
pms.requestRead();
if (pms.read(data, 10000))
{
pm10RA.addValue(data.PM_AE_UG_1_0);
pm25RA.addValue(data.PM_AE_UG_2_5);
pm100RA.addValue(data.PM_AE_UG_10_0);
dustCount++;
}
}
}
//printDriverError decodes the CCS811Core::status type and prints the
//type of error to the serial terminal.
//
//Save the return value of any function of type CCS811Core::status, then pass
//to this function to see what the output was.
void sendTemp(unsigned long start)
{
if ((start - lastUpdateTemp) >= UPDATE_INTERVAL_TEMP)
{
float temperature = htu.readTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT!");
} else {
// Only send temperature if it changed since the last measurement or if we didn't send an update for n times
msgT1.setDestination(0);
send(msgT1.set(temperature, 1));
delay(50);
msgT1.setDestination(15);
send(msgT1.set(temperature, 1));
msgT1.setDestination(0);
#ifdef MY_DEBUG
Serial.print("T: ");
Serial.println(temperature);
#endif
}
Serial.println("Here2");
float humidity = htu.readHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else {
// Only send humidity if it changed since the last measurement or if we didn't send an update for n times
send(msgH1.set(humidity, 2));
delay(50);
msgH1.setDestination(15);
msgH1.setDestination(0);
send(msgH1.set(humidity, 2));
msgH1.setDestination(0);
#ifdef MY_DEBUG
Serial.print("H: ");
Serial.println(humidity);
#endif
}
float pressure = bme.readPressure();
send(msgP1.set(pressure, 2));
send(msgF1.set("unknown"));
Serial.println("Here4");
#ifdef MY_DEBUG
Serial.print("P: ");
Serial.println(pressure);
#endif
//pms.requestRead();
ccs.setEnvironmentalData(humidity,temperature);
lastUpdateTemp=millis();
}
}
void voc(unsigned long start)
{
//Serial.print(F("checking VOC "));
//Serial.println((start - lastUpdateVOC));
if (vocing ==0 & ((start - lastUpdateVOC) >= UPDATE_INTERVAL_VOC))
{
Serial.print(F("Starting VOC"));
vocing =true;
vocCount=0;
lastUpdateVOC= millis();
ccs.setDriveMode(2);
// pms.wakeUp();
//PMS WAKE
}
else if (vocing && (vocCount>VOC_SAMPLE_COUNT))
{
ccs.setDriveMode(0);
send(co2Msg.set(co2RA.getAverage(), 1));
delay(50);
send(vocMsg.set(vocRA.getAverage(), 1));
delay(50);
vocing=false;
lastUpdateVOC=millis();
}
else if (vocing ==1 && ((start - lastUpdateVOC) >= VOC_DELAY))
{
// Serial.print(F("CCS811 CHECK:"));
if (ccs.dataAvailable())
{
//Calling this function updates the global tVOC and eCO2 variables
ccs.readAlgorithmResults();
//printInfoSerial fetches the values of tVOC and eCO2
//printInfoSerial();
Serial.print(F("CCS811 data:"));
Serial.println(vocCount);
Serial.print(F(" CO2 concentration : "));
Serial.print(ccs.getCO2());
Serial.println(F(" ppm"));
if (ccs.getCO2() < 65000) {
co2RA.addValue(ccs.getCO2());
}
//getTVOC() gets the previously read data from the library
Serial.print(F(" TVOC concentration : "));
Serial.print(ccs.getTVOC());
Serial.println(F(" ppb"));
if (ccs.getTVOC() < 65000) {
vocRA.addValue(ccs.getTVOC());
}
// float BMEtempC = myBME280.readTempC();
// float BMEhumid = myBME280.readFloatHumidity();
//
// Serial.print("Applying new values (deg C, %): ");
// Serial.print(BMEtempC);
// Serial.print(",");
// Serial.println(BMEhumid);
// Serial.println();
//
// //This sends the temperature data to the CCS811
//
vocCount++;}
}
}
void printDriverError( CCS811Core::status errorCode )
{
switch ( errorCode )
{
case CCS811Core::SENSOR_SUCCESS:
Serial.print(F("SUCCESS"));
break;
case CCS811Core::SENSOR_ID_ERROR:
Serial.print(F("ID_ERROR"));
break;
case CCS811Core::SENSOR_I2C_ERROR:
Serial.print(F("I2C_ERROR"));
break;
case CCS811Core::SENSOR_INTERNAL_ERROR:
Serial.print(F("INTERNAL_ERROR"));
break;
case CCS811Core::SENSOR_GENERIC_ERROR:
Serial.print(F("GENERIC_ERROR"));
break;
default:
Serial.print(F("Unspecified error."));
}
}
//printSensorError gets, clears, then prints the errors
//saved within the error register.
void printSensorError()
{
uint8_t error = ccs.getErrorRegister();
if ( error == 0xFF ) //comm error
{
Serial.println("Failed to get ERROR_ID register.");
}
else
{
Serial.print("Error: ");
if (error & 1 << 5) Serial.print(F("HeaterSupply"));
if (error & 1 << 4) Serial.print(F("HeaterFault"));
if (error & 1 << 3) Serial.print(F("MaxResistance"));
if (error & 1 << 2) Serial.print(F("MeasModeInvalid"));
if (error & 1 << 1) Serial.print(F("ReadRegInvalid"));
if (error & 1 << 0) Serial.print(F("MsgInvalid"));
Serial.println();
}
}
-
- Posts: 12
- Joined: Friday 14 October 2016 10:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
I enabled debug on mysensors and as expected it seems like the messages are arriving okay:
Code: Select all
2018-07-31 16:08:52.796 MySensors: NodeID: 18, ChildID: 0, MessageType: 1, Ack: 0, SubType: 0, Payload: 28.7
2018-07-31 16:08:52.868 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332648 TSF:MSG:READ,18-18-15,s=0,c=1,t=0,pt=7,l=5,
2018-07-31 16:08:52.869 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332648 TSF:MSG:REL MSG
2018-07-31 16:08:52.871 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332650 TSF:MSG:SEND,18-0-15-15,s=0,c=1,t=0,pt=7,l=
2018-07-31 16:08:52.943 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332722 TSF:MSG:READ,18-18-0,s=1,c=1,t=1,pt=7,l=5,s
2018-07-31 16:08:52.943 MySensors: NodeID: 18, ChildID: 1, MessageType: 1, Ack: 0, SubType: 1, Payload: 75.24
2018-07-31 16:08:53.014 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332794 TSF:MSG:READ,18-18-0,s=1,c=1,t=1,pt=7,l=5,s
2018-07-31 16:08:53.015 MySensors: NodeID: 18, ChildID: 1, MessageType: 1, Ack: 0, SubType: 1, Payload: 75.24
2018-07-31 16:08:53.039 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332819 TSF:MSG:READ,18-18-0,s=2,c=1,t=4,pt=7,l=5,s
2018-07-31 16:08:53.040 MySensors: NodeID: 18, ChildID: 2, MessageType: 1, Ack: 0, SubType: 4, Payload: 101048.38
2018-07-31 16:08:53.062 MySensors: NodeID: 0, ChildID: 255, MessageType: 3, Ack: 0, SubType: 9, Payload: 610332841 TSF:MSG:READ,18-18-0,s=2,c=1,t=5,pt=0,l=7,s
2018-07-31 16:08:53.062 MySensors: NodeID: 18, ChildID: 2, MessageType: 1, Ack: 0, SubType: 5, Payload: unknown
2018-07-31 16:08:53.065 Debug: SQLH UpdateValueInt PRES HwID:16 DevID:00001202 Type:243 sType:26 nValue:0 sValue:101048.38;5
2018-07-31 16:08:53.067 (My Sensors) General/Barometer (PRES)
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
I think you have to wait for GizMoCuz to respond, he is, i believe, the author of the MySensors gateway in Domoticz, or you can try to to debug this yourself if you run from sourcecode. If I have time, I will give it a try, but I have to make a new node that sends this Temp/Hum/Baro data and at the moment I ran out of RFM69 modules.
-
- Posts: 12
- Joined: Friday 14 October 2016 10:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
What I have found is that domoticz is calling SendTempHumBaroSensorFloat with each update but nothing further seems to happen. Only the baro is updated and there is still no combined sensor with all three. Perhaps because this is not created the update isn't being ,made?
-
- Posts: 12
- Joined: Friday 14 October 2016 10:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: BETA Version: 4.9796 Not creating Temp/Hum Sensor
So...I'm an idiot. My problem turned out to be very simple.
I was sending the barometric pressure as Pa and not as hPa. I apparently didn't have all the debug logging on (apparently) as domoticz did not write to the log showing this as I think it should.
I was sending the barometric pressure as Pa and not as hPa. I apparently didn't have all the debug logging on (apparently) as domoticz did not write to the log showing this as I think it should.
Who is online
Users browsing this forum: No registered users and 0 guests