Could i buy it assembled?
Posts made by Tommas
-
RE: Raspberry as mysensors gateway connection refused
Ok. Sorry. Working
--my-transport=rf24 --my-gateway=ethernet --my-port=5003 --my-gateway=ethernet -
Raspberry as mysensors gateway connection refused
Hi,
I follow the instruction but i got
Sep 01 15:26:49 DEBUG GWT:TPS:ETH OK
Sep 01 15:26:49 ERROR connect: Connection refused
Sep 01 15:26:49 ERROR failed to connect
Sep 01 15:26:49 DEBUG GWT:TPS:ETH OK
Sep 01 15:26:49 ERROR connect: Connection refused
Sep 01 15:26:49 ERROR failed to connect
Sep 01 15:26:49 DEBUG GWT:TPS:ETH OK
Sep 01 15:26:49 ERROR connect: Connection refused
Sep 01 15:26:49 ERROR failed to connect
Sep 01 15:26:49 DEBUG GWT:TPS:ETH OK
Sep 01 15:26:49 ERROR connect: Connection refused
Sep 01 15:26:49 ERROR failed to connect
Sep 01 15:26:49 DEBUG GWT:TPS:ETH OKerror.
The configuration was:
./configure --my-transport=rf24 --my-gateway=ethernet --my-controller-url-address=xxx.xxx.xxx.xxxMy controller is a VM and it has worked with an arduino gateway, but that go wrong, and i thought i try to use my rpi3 as an ethernet gateway. I connected the nrf24l01+ /pa/lna to it (5v, but i use an adapter for it such like this https://www.addicore.com/1x-nRF24L01-Adapter-p/ad279.htm )
please help
-
WakeOnLan over nrf24 radio
Hi!
I would like to wake up my pc over lan.
I thought that i make an arduino node with nrf24l01 and a ethernet w5100 to wake up my pc.
I need a sketch for it.
Does Anybody have it?Thanks
T -
Child X not present in node X
Dear All!
I dont know what might be the problem.
Openhab2 2.4.0
Mysensors 2.3.0 binding
All other nodes are OK except my NoDE 3. Previously it had been OK until I upgraded to openhab2 2.3 , but Im not sure that the upgrade the main problem.
Please give me suggestion what should i try to fix this issue.Message from gateway received: 3;1;1;0;0;5.2 2018-07-06 19:58:24.834 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 3 found in gateway 2018-07-06 19:58:24.834 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 not present in node 3 2018-07-06 19:58:24.845 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 3;2;1;0;1;69 2018-07-06 19:58:24.845 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 3 found in gateway 2018-07-06 19:58:24.845 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 2 not present in node 3
Thanks in advance,
Tamás -
RE: All things unitialized after upgrade openhab 2.3.0-snapshot
It seems to work with the older mysensors binding:
org.openhab.binding.mysensors-2.2.0-SNAPSHOT.jar .3 of my 5 nodes updated the values in openhab2 (2.3.0~20180331153334-1)
-
All things unitialized after upgrade openhab 2.3.0-snapshot
Dear All!
I updated openhab2 2.3.0 previous build (via apt-get) to 2.3.0-SNAPSHOT Build #1246 . 2.3.0~20180331153334-1
Except one of my node the nodes values arent updated on the sitemap, and arent written to the database, but in the openhab log I see the sent values, but:
Child X not present in node YAnother problem on the paperui:
My mysensor ethernet gateway status on things page:
Status: UNINITIALIZED - HANDLER_INITIALIZING_ERROR Unresolved compilation problems: The type org.eclipse.jdt.annotation.Nullable cannot be resolved. It is indirectly referenced from required .class files The type org.eclipse.jdt.annotation.NonNullByDefault cannot be resolved. It is indirectly referenced from required .class files .The strange is that one of my node's values are updating...
MY mysensors addon:
org.openhab.binding.mysensors-2.3.0-SNAPSHOT.jarWhat might be the problem?
Please help,
-
RE: Arduino mini pro 3.3 battery optimization code
Thank you very much, and sorry....
-
RE: Arduino mini pro 3.3 battery optimization code
Ok! After the "loop ended " the node should go to sleep. On the console I see these lines:
Loop ended
62763 MCO:SLP:MS=300000,SMS=0,I1=255,M1=255,I2=255,M2=255
62773 MCO:SLP:TPDWhat does it mean?
-
RE: Arduino mini pro 3.3 battery optimization code
@gohan said in Arduino mini pro 3.3 battery optimization code:
loop
What kind of sleep is it? There are parameters out there. ADC_OFF and some and some... Is this sleep turn off adc?
-
RE: Arduino mini pro 3.3 battery optimization code
Should I use any other sleep "code"? How I know that the nrf24L01 go to sleep?
-
RE: Arduino mini pro 3.3 battery optimization code
I did a new code, and it seems that it is do the job.
My goal was, that I only send the battery voltage (percent) when:
At least one of sensor value transmission occured + The battery report time is elapsed.What do you think about my code? IT IS NOT ONLY MY CODE and it is not clear yet Thank for @gohan , @sundberg84 and mysensors for the base.
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 6 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 #include <MySensors.h> #include <Wire.h> #include <SI7021.h> #include <SPI.h> #include <RunningAverage.h> #include <BH1750.h> //BH1750 #include <Math.h> #define DEBUG #ifdef DEBUG #define DEBUG_SERIAL(x) Serial.begin(x) #define DEBUG_PRINT(x) Serial.print(x) #define DEBUG_PRINTLN(x) Serial.println(x) #else #define DEBUG_SERIAL(x) #define DEBUG_PRINT(x) #define DEBUG_PRINTLN(x) #endif #define NODE_ID 6 // <<<<<<<<<<<<<<<<<<<<<<<<<<< Enter Node_ID #define CHILD_ID_TEMP 0 #define CHILD_ID_HUM 1 #define CHILD_ID_LIGHT 2 //BH1750 #define CHILD_ID_VBAT 254 /*BATTERY*/ // BATTERY MEASURER // VOLTAGE DIVIDER SETUP // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 #define VBAT_PER_BITS 0.003363075 #define VMIN 2.1 // Vmin (radio Min Volt)=1.9V (564v) #define VMAX 3.1 // Vmax = (2xAA bat)=3.0V (892v) int batteryPcnt = 0; // Calc value for battery % int battAveragePcnt; int battSumPcnt = 0; int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point float VbatAverage=0; float VbatSum=0; //========================= /*BATTERY*/ //#define SLEEP_TIME 180000 // 3 min //#define FORCE_TRANSMIT_CYCLE 10 // SLEEP_TIME*FORCE_TRANSMIT_CYCLE=Mindenképp küldi az értéket (Temp+HUM), különben akkor ha HUMI_TRANSMIT_THRESHOLD vagy TEMP_TRANSMIT_THRESHOLD igaz, //#define BATT_MEASURE_CYCLE 10 // SLEEP_TIME/1000*BATTERY_Measure_CYCLE=Ennyi időnként Veszünk mintát (BATTERY) //#define BATT_REPORT_CYCLE 15 // SLEEP_TIME/1000*BATTERY_REPORT_CYCLE=Ennyi időnként küldi az értéket (BATTERY) #define SLEEP_TIME 300000 // 15sec #define FORCE_TRANSMIT_CYCLE 24 // 30sec SLEEP_TIME*FORCE_TRANSMIT_CYCLE=Mindenképp küldi az értéket (Temp+HUM), különben akkor ha HUMI_TRANSMIT_THRESHOLD vagy TEMP_TRANSMIT_THRESHOLD igaz, #define BATT_MEASURE_CYCLE 2 // Hányszor vegyünk mintát a küldés előtt #define BATT_REPORT_CYCLE 60 // SLEEP_TIME/1000*BATTERY_REPORT_CYCLE*2=Ennyi időnként küldi az értéket (BATTERY) #define HUMI_TRANSMIT_THRESHOLD 3.0 // THRESHOLD tells how much the value should have changed since last time it was transmitted. #define TEMP_TRANSMIT_THRESHOLD 0.5 #define LUX_TRANSMIT_THRESHOLD 10 #define AVERAGES 2 int measureCount = 0; int battreportCount=-2; float lastTemperature = -100; int lastHumidity = -100; int lastLux = 0; //BH1750 boolean transmission_occured = false; RunningAverage raHum(AVERAGES); SI7021 humiditySensor; BH1750 lightSensor; //MySensor gw; MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message MyMessage msgHum(CHILD_ID_HUM,V_HUM); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //BH1750 MyMessage msgVBat(CHILD_ID_VBAT, V_VOLTAGE); //BH1750 void presentation(){ sendSketchInfo("Node 6, Temp,Hum,Light", "1.1"); present(CHILD_ID_TEMP, S_TEMP); // Present sensor to controller present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); //BH1750 present(CHILD_ID_VBAT, S_MULTIMETER); //BH1750 } void setup() { DEBUG_SERIAL(115200); DEBUG_PRINTLN("Serial started"); delay(500); // Allow time for radio if power useed as reset raHum.clear(); lightSensor.begin(); //BH1750 /*BATTERY*/ //========================= // BATTERY MEASURER //Set internal ref to internal to be able to measure bat 0-1v //Make sure this fits other sensors using analogRead()! //If you have a sensor reporting 0-5v you need to change analogReference() before reading that sensor. analogReference(INTERNAL); //DEFAULT: the default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards) //INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega) //EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. //Battery inital calc Serial.print("With Battery VMax (100%) = "); Serial.print(VMAX); Serial.print("volts and Vmin (0%) = "); Serial.print(VMIN); Serial.println(" volts"); Serial.print("Battert Percent 25%/50%/75% should be: "); Serial.print(((VMAX - VMIN) / 4) + VMIN); Serial.print("/"); Serial.print(((VMAX - VMIN) / 2) + VMIN); Serial.print("/"); Serial.println(VMAX - ((VMAX - VMIN) / 4)); delay(500); int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(50); float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat - VMIN) / (VMAX - VMIN)) * 100.); Serial.print("Current battery are measured to (please confirm!): "); Serial.print(batteryPcnt); Serial.print(" % - Or "); Serial.print(Vbat); Serial.println(" Volts"); //========================= /*BATTERY*/ } void loop() { DEBUG_PRINTLN("Loop started"); boolean forceTransmit = false; transmission_occured = false; battreportCount ++; measureCount ++; forceTransmit = false; if (measureCount == FORCE_TRANSMIT_CYCLE) { forceTransmit = true; measureCount = 0; } sendTempHumidityMeasurements(forceTransmit); sendLightMeasurements(forceTransmit); Serial.print("battreportCount");Serial.println(battreportCount); /*BATTERY*/ //========================= // BATTERY MEASURER if(((transmission_occured) && (battreportCount>=BATT_REPORT_CYCLE)) || (battreportCount == -1)){ Serial.print("----BATTERY SEND/Measure CYCLE---- "); MeasureBattery(); send(msgVBat.set(VbatAverage, 3)); sendBatteryLevel(battAveragePcnt); Serial.print("Battery Average (Send): "); Serial.print(battAveragePcnt); Serial.println(" %"); Serial.print("Battery Average Voltage (Send): "); Serial.print(VbatAverage); Serial.println(" V"); battreportCount=0; battAveragePcnt=0; VbatAverage=0; VbatSum=0; battSumPcnt=0; measureCount=0; } //========================= /*BATTERY*/ DEBUG_PRINTLN("Loop ended"); sleep(SLEEP_TIME); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; DEBUG_PRINTLN("Send TEMP and HUM started"); si7021_env data = humiditySensor.getHumidityAndTemperature(); float temperature = data.celsiusHundredths / 100.0; DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature); float diffTemp = abs(lastTemperature - temperature); DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp); if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) { send(msgTemp.set(temperature, 1)); lastTemperature = temperature; DEBUG_PRINTLN("TEMP sent!"); transmission_occured = true; } int humidity = data.humidityPercent; DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity); raHum.addValue(humidity); humidity = raHum.getAverage(); // MA sample imply reasonable fast sample frequency float diffHum = abs(lastHumidity - humidity); DEBUG_PRINT(F("HumDiff :"));DEBUG_PRINTLN(diffHum); if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) { send(msgHum.set(humidity, 1)); lastHumidity = humidity; DEBUG_PRINTLN("HUM sent!"); transmission_occured = true; } } //BH1750 void sendLightMeasurements(bool force){ bool tx = force; int lux = lightSensor.readLightLevel();// Get Lux value float diffLux = abs(lastLux - lux); //Serial.println(lux); DEBUG_PRINT("LUX: ");DEBUG_PRINTLN(lux); DEBUG_PRINT("LuxDiff: ");DEBUG_PRINTLN(diffLux); if (diffLux > LUX_TRANSMIT_THRESHOLD || tx) { send(msgLight.set(lux)); lastLux = lux; DEBUG_PRINTLN("LUX sent!"); transmission_occured = true; } } //BH1750 /*BATTERY*/ //========================= // BATTERY MEASURER void MeasureBattery() //The battery calculations { if (batteryPcnt > 100) { batteryPcnt = 100; } for (int i = 1 ; i <= BATT_MEASURE_CYCLE; i++) { delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat - VMIN) / (VMAX - VMIN)) * 100.); Serial.print("I: ");Serial.println(i); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.print(" %"); Serial.print("Battery Voltage: "); Serial.print(Vbat); Serial.println(" Volts"); battSumPcnt += batteryPcnt; Serial.print("battSumPcnt:::");Serial.println(battSumPcnt); battAveragePcnt = battSumPcnt / i; VbatSum += Vbat; VbatAverage = VbatSum / i; Serial.print("battAveragePcnt Calculated: ");Serial.println(battAveragePcnt); } } //========================= /*BATTERY*/
-
RE: Arduino mini pro 3.3 battery optimization code
Dear @neverdie ,
Ok, so I wont use these batteries. -
RE: Arduino mini pro 3.3 battery optimization code
Hi All!
Im near to get it work:) .
Someone could write an example openhab2 thing and item for Battery Voltage handling?Thank you!
-
RE: Arduino mini pro 3.3 battery optimization code
Dear Gohan!
Thank you! I thought that it isnt equal with this: https://www.mysensors.org/download/sensor_api_20#sleeping ....
But perhaps I misunderstood something because you says that it is the same sleep mode... -
RE: Arduino mini pro 3.3 battery optimization code
Oh ok. I have put this in the code, so it is OK, i think. I thought that SLEEP_TIME isnt equal to powerdown, but it seems that i misunderstood.
I use your easypcb board Sundberg.... Is your battery measurement code better than this standard mysensors one?Thank You again!
-
Arduino mini pro 3.3 battery optimization code
Dear All!
I would like to use the Arduino Mini Pro 3.3 8Mhz (aTMega328) with 2xAA battery. I have read that it useful to put it in powerdown/sleep mode.
Could you help me what code/sketch should I use. I copied to here my beta sketch(It works, but it doesnt have the powerdown function)
If someone has any other suggestion related to the code, please write it!/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 6 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* Sketch with Si7021 and battery monitoring. by m26872, 20151109 */ #include <MySensors.h> #include <Wire.h> #include <SI7021.h> #include <SPI.h> #include <RunningAverage.h> #include <BH1750.h> //BH1750 #define DEBUG #ifdef DEBUG #define DEBUG_SERIAL(x) Serial.begin(x) #define DEBUG_PRINT(x) Serial.print(x) #define DEBUG_PRINTLN(x) Serial.println(x) #else #define DEBUG_SERIAL(x) #define DEBUG_PRINT(x) #define DEBUG_PRINTLN(x) #endif #define MOTION_DIGITAL_INPUT_SENSOR 3 //MOTION #define NODE_ID 6 // <<<<<<<<<<<<<<<<<<<<<<<<<<< Enter Node_ID #define CHILD_ID_TEMP 0 #define CHILD_ID_HUM 1 #define CHILD_ID_LIGHT 2 //BH1750 #define CHILD_ID_MOTION 3 /*MOTION*/ //BATTERY int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point uint32_t SLEEP_TIME = 900000; // sleep time between reads (seconds * 1000 milliseconds) int oldBatteryPcnt = 0; //#define SLEEP_TIME 15000 // 15s for DEBUG #define SLEEP_TIME 10000 // 5 min //#define FORCE_TRANSMIT_CYCLE 36 // 5min*12=1/hour, 5min*36=1/3hour #define FORCE_TRANSMIT_CYCLE 1 // 5min*12=1/hour, 5min*36=1/3hour //#define BATTERY_REPORT_CYCLE 2880 // Once per 5min => 12*24*7 = 2016 (one report/week) //#define VMIN 1900 //#define VMAX 3300 #define HUMI_TRANSMIT_THRESHOLD 3.0 // THRESHOLD tells how much the value should have changed since last time it was transmitted. #define TEMP_TRANSMIT_THRESHOLD 0.5 #define AVERAGES 2 //int batteryReportCounter = BATTERY_REPORT_CYCLE - 1; // to make it report the first time. int measureCount = 0; float lastTemperature = -100; int lastHumidity = -100; uint16_t lastlux; //BH1750 RunningAverage raHum(AVERAGES); SI7021 humiditySensor; BH1750 lightSensor; //MySensor gw; MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message MyMessage msgHum(CHILD_ID_HUM,V_HUM); MyMessage msgLight(CHILD_ID_LIGHT, V_LIGHT_LEVEL); //BH1750 MyMessage msgMotion(CHILD_ID_MOTION, V_TRIPPED); //MOTION void presentation(){ sendSketchInfo("Node 6, Temp,Hum,Light,Motion", "1.1"); present(CHILD_ID_TEMP, S_TEMP); // Present sensor to controller present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); //BH1750 present(CHILD_ID_MOTION, S_MOTION); /*MOTION*/ //BATTERY sendSketchInfo("Battery Meter", "1.0"); } void setup() { //BATTERY // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif //BATTERY DEBUG_SERIAL(115200); DEBUG_PRINTLN("Serial started"); //DEBUG_PRINT("Voltage: "); //DEBUG_PRINT(readVcc()); //DEBUG_PRINTLN(" mV"); /* delay(500); DEBUG_PRINT("Internal temp: "); DEBUG_PRINT(GetInternalTemp()); // Probably not calibrated. Just to print something. DEBUG_PRINTLN(" *C"); */ delay(500); // Allow time for radio if power useed as reset //begin(NULL,NODE_ID); //DEBUG_PRINT("Node and "); DEBUG_PRINTLN("2 children presented."); raHum.clear(); lightSensor.begin(); //BH1750 /* MOTION */ pinMode(MOTION_DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void loop() { DEBUG_PRINTLN("Loop started"); measureCount ++; bool forceTransmit = true; //if (measureCount > FORCE_TRANSMIT_CYCLE) { //forceTransmit = true; //} sleep(SLEEP_TIME); //BATTERY // get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); #ifdef MY_DEBUG Serial.println(sensorValue); #endif // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 int batteryPcnt = sensorValue / 10; #ifdef MY_DEBUG float batteryV = sensorValue * 0.003363075; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); #endif if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } //BATTERY sendTempHumidityMeasurements(forceTransmit); //BH1750 uint16_t lux = lightSensor.readLightLevel();// Get Lux value Serial.println(lux); DEBUG_PRINT("LUX: ");DEBUG_PRINTLN(lux); if (lux != lastlux) { send(msgLight.set(lux)); lastlux = lux; } //BH1750 /* MOTION */ // Read digital motion value bool tripped = digitalRead(MOTION_DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msgMotion.set(tripped?"1":"0")); // Send tripped value to gw DEBUG_PRINTLN("Loop ended"); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; DEBUG_PRINTLN("Send TEMP and HUM started"); si7021_env data = humiditySensor.getHumidityAndTemperature(); float temperature = data.celsiusHundredths / 100.0; DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature); float diffTemp = abs(lastTemperature - temperature); DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp); //if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) { send(msgTemp.set(temperature, 1)); //lastTemperature = temperature; //measureCount = 0; DEBUG_PRINTLN("T sent!"); //} int humidity = data.humidityPercent; DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity); raHum.addValue(humidity); humidity = raHum.getAverage(); // MA sample imply reasonable fast sample frequency float diffHum = abs(lastHumidity - humidity); DEBUG_PRINT(F("HumDiff :"));DEBUG_PRINTLN(diffHum); //if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) { send(msgHum.set(humidity, 1)); //lastHumidity = humidity; //measureCount = 0; DEBUG_PRINTLN("H sent!"); //} }``` Thank you in advance!!
-
RE: Easy/Newbie PCB for MySensors
Or have you got any suggestion expansion board for arduino mini pro ? Something like this: arduino-pro-mini-undershield (but it can not buy on ebay)
-
RE: Easy/Newbie PCB for MySensors
Unofrtunately i havent got the skills and free time for a daughter board.:(. But doesnt have someone else a daughterboard?:)
-
RE: Easy/Newbie PCB for MySensors
Hi All!
Could someone suggest me an elegant way to extend the mysx connector? SO i would like to multiple the A4 A5 pins onto another prototype board to use more I2C devices....
-
How connect si7021 and bh1750 to arduino mini pro
Dear All!
I would like to connect my si7021 and bh1750 to the same arduino mini pro 5v. These use the I2C interaface, but i dont know how should wire it.
After the wiring, how can I read the values both of them with mysensors sketch?Thank you for your help in advance!
T.
-
RE: Connect esp nodes to ethernet gateway
So if i would like to use gateway for esp nodes i have to create an only esp gateway?
-
RE: 💬 FOTA (Wireless Programming)
Dear all!
I have an mysensors ethernet gateway and nodes with nrf24 . I have an openhab2 controller. Could i use the above solution to program my nodes over the air through my current gateway? So i write my sketch on windows arduino and send it through my gateway to the node? Or i have to connect my computer direct to nodes over air?
-
RE: Connect esp nodes to ethernet gateway
Can I control/monitor the esp based sensors (which are connected to my AP, same network as openhab server) with openhab2 without any GATEWAY?
-
RE: Connect esp nodes to ethernet gateway
Thank for all!
Can i use the ESP node over wifi without controller? Can i register these to openhab2? -
Connect esp nodes to ethernet gateway
Dear All!
I have a mysensors ethernet gateway with nrf24. Now all my nodes communicate with it via nrf24.
I think that i would like to use some esp sensor nodes.
how can i connect these new esp nodes to this same gateway over wifi?Thanks,
T -
RE: Mysensors si7021 sketch
Dear @Yveaux
I think that yes. The si7021 module has an smd 103 part on it. Maybe it is at the sda and scl but im not sure.
https://www.ebay.com/i/401364416322
Thanks
-
RE: Mysensors si7021 sketch
There arent any indication. Sometimes it works.... i tried another si7021 and same. Voltage is Ok. A connected the sda - A4 scl - A5 on easypcb board
Any idea?
-
RE: Mysensors si7021 sketch
What is the problem with my sketch? It is in developement phase, but the reading stops at this line, but sometimes it works for 3-4 loop...
" DEBUG_PRINTLN("Send TEMP and HUM started"); "
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 4 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* Sketch with Si7021 and battery monitoring. by m26872, 20151109 */ #include <MySensors.h> #include <Wire.h> #include <SI7021.h> #include <SPI.h> #include <RunningAverage.h> #define DEBUG #ifdef DEBUG #define DEBUG_SERIAL(x) Serial.begin(x) #define DEBUG_PRINT(x) Serial.print(x) #define DEBUG_PRINTLN(x) Serial.println(x) #else #define DEBUG_SERIAL(x) #define DEBUG_PRINT(x) #define DEBUG_PRINTLN(x) #endif #define NODE_ID 4 // <<<<<<<<<<<<<<<<<<<<<<<<<<< Enter Node_ID #define CHILD_ID_TEMP 0 #define CHILD_ID_HUM 1 //#define SLEEP_TIME 15000 // 15s for DEBUG #define SLEEP_TIME 10000 // 5 min //#define FORCE_TRANSMIT_CYCLE 36 // 5min*12=1/hour, 5min*36=1/3hour #define FORCE_TRANSMIT_CYCLE 1 // 5min*12=1/hour, 5min*36=1/3hour //#define BATTERY_REPORT_CYCLE 2880 // Once per 5min => 12*24*7 = 2016 (one report/week) //#define VMIN 1900 //#define VMAX 3300 #define HUMI_TRANSMIT_THRESHOLD 3.0 // THRESHOLD tells how much the value should have changed since last time it was transmitted. #define TEMP_TRANSMIT_THRESHOLD 0.5 #define AVERAGES 2 //int batteryReportCounter = BATTERY_REPORT_CYCLE - 1; // to make it report the first time. int measureCount = 0; float lastTemperature = -100; int lastHumidity = -100; RunningAverage raHum(AVERAGES); SI7021 humiditySensor; //MySensor gw; MyMessage msgTemp(CHILD_ID_TEMP,V_TEMP); // Initialize temperature message MyMessage msgHum(CHILD_ID_HUM,V_HUM); void presentation(){ sendSketchInfo("Node 4, Temp,Hum sensor", "1.1"); present(CHILD_ID_TEMP, S_TEMP); // Present sensor to controller present(CHILD_ID_HUM, S_HUM); } void setup() { DEBUG_SERIAL(115200); DEBUG_PRINTLN("Serial started"); //DEBUG_PRINT("Voltage: "); //DEBUG_PRINT(readVcc()); //DEBUG_PRINTLN(" mV"); /* delay(500); DEBUG_PRINT("Internal temp: "); DEBUG_PRINT(GetInternalTemp()); // Probably not calibrated. Just to print something. DEBUG_PRINTLN(" *C"); */ delay(500); // Allow time for radio if power useed as reset //begin(NULL,NODE_ID); //DEBUG_PRINT("Node and "); DEBUG_PRINTLN("2 children presented."); raHum.clear(); } void loop() { DEBUG_PRINTLN("Loop started"); measureCount ++; bool forceTransmit = true; //if (measureCount > FORCE_TRANSMIT_CYCLE) { //forceTransmit = true; //} sleep(SLEEP_TIME); sendTempHumidityMeasurements(forceTransmit); DEBUG_PRINTLN("Loop ended"); } /********************************************* * * Sends temperature and humidity from Si7021 sensor * Parameters * - force : Forces transmission of a value (even if it's the same as previous measurement) *********************************************/ void sendTempHumidityMeasurements(bool force) { bool tx = force; DEBUG_PRINTLN("Send TEMP and HUM started"); si7021_env data = humiditySensor.getHumidityAndTemperature(); float temperature = data.celsiusHundredths / 100.0; DEBUG_PRINT("T: ");DEBUG_PRINTLN(temperature); float diffTemp = abs(lastTemperature - temperature); DEBUG_PRINT(F("TempDiff :"));DEBUG_PRINTLN(diffTemp); //if (diffTemp > TEMP_TRANSMIT_THRESHOLD || tx) { send(msgTemp.set(temperature, 1)); //lastTemperature = temperature; //measureCount = 0; DEBUG_PRINTLN("T sent!"); //} int humidity = data.humidityPercent; DEBUG_PRINT("H: ");DEBUG_PRINTLN(humidity); raHum.addValue(humidity); humidity = raHum.getAverage(); // MA sample imply reasonable fast sample frequency float diffHum = abs(lastHumidity - humidity); DEBUG_PRINT(F("HumDiff :"));DEBUG_PRINTLN(diffHum); //if (diffHum > HUMI_TRANSMIT_THRESHOLD || tx) { send(msgHum.set(humidity, 1)); //lastHumidity = humidity; //measureCount = 0; DEBUG_PRINTLN("H sent!"); //} }
-
RE: Mysensors si7021 sketch
Dear @mfalkvidd !
Thank you, and to everyone for the help!
I got it work!
If the sketch will be completed i will upload that! -
RE: Mysensors si7021 sketch
Dear @sundberg84
Thanks for the suggestions!
Another, which pin should i connect to the si7021? I cant find this info...Thanks,
-
Mysensors si7021 sketch
Dear All!
Has anybody a sketch for this temperature and humidity sensor? I would like to use it with mini pro combined easypcb board.
Thank you in advance!
-
GUVA-S12SD UV sensor sketch required
Dear All!
Does anybody have mysensors compatible GUVA-S12SD UV sensor sketch?
I would like to operate it from 3.3V battery connected to Sensebender MIcro.Thank you in advance!
-
RE: 💬 Easy/Newbie PCB for MySensors
Oh OK! Thank you! The decision is hard for me, which solution i should use:) .
-
Configure Sensebender Micro Battery internal message
Dear All!
I would like to display the sensebender micro battery percentage in openhab2. How should I configure it in my openhab?
Thank you in advance!
Best regards,
T -
RE: 💬 Easy/Newbie PCB for MySensors
Dear gohan!
I would like to power all my nodes from a central power source with 5V . I would like to use 3.3V microcontroller with 3V sensors... because of the voltage drop down caused by the distance (5-15m from the power source). Maybe there will be 1-2 battery powered sensor nodes..
This is my plan.
I dont like using battery. It is too hard for me to optimize the sensors for battery...Best regards
T -
RE: 💬 Easy/Newbie PCB for MySensors
Dear @sundberg84 !
Thank you! ANd which example should i follow with this modification?
Thanks
T -
RE: 💬 Easy/Newbie PCB for MySensors
Dear @gohan !
Thank for your help!
Which configuratation should i use? Or do i have to modify one of the above configurations? (3.3V , 5V regulated, or 6-12V) ? -
RE: 💬 Easy/Newbie PCB for MySensors
Dear All!
I would like to use this PCB. I would like power it with 5V, but I would like to use a 3.3V version mini Pro. How should I do it? I would like to use it from 5V (USB adapter) or battery 2xAA . Could I do it?
Best regards,
T -
Openhab2 Last Update value
Dear All!
How can i get it work?: I would like to see that time the sensor sent the last value (last update). I would like to display it on the sitemap.
Please help me.Have a godd weekend!
T.
-
RE: Which microcontroller for Node
Another question.
Can i use the mini pro's 3.3V output for all of my 3.3V sensors? Cant i exceed the current limit of the mini pro with these sensors? -
RE: Which microcontroller for Node
Dear @Nca78
Thank you for the long answer.
Could you suggest power module (in 5V ---> out 3.3V and 5V? I think something like with integrated microusb plug) what i can to build in to my circuit?Best regards
T -
RE: Which microcontroller for Node
Dear @mfalkvidd
I think that i will use mini pro 3.3V version and in this case it is i will be capable to run it from battery or external power source.
Thanks
T -
RE: Which microcontroller for Node
Dear gohan.
Sorry! I think about a general solution. We can forget the relay for now. I would like to know where is the limit approximatelly if i used battery with not too complocated circuits...
Best regards
T -
RE: Which microcontroller for Node
Hi @LastSamurai
If i powered a 3.3V mini pro from 2 AA (2000mAh) battery, how long my sensor node can work? Approximately..? NRF24L01 low power, MQ2, si7021, lm393 light, PIR motion, one relay module, and a sound sensor? Or these are too much for battery power?
Can I attach these directly to the mini pro power output?Thanks,
T. -
RE: Help make Openhab2 MQ2 AirQuality work
Dear all!
Has someone any idea, why i cant display the mq2 value on the sitemap?
Only a "-" appear. I would like to see the value. On the control tab on the paperui i see the changes.
Another solution would be good as well, for example an alert if the mq2 value greater than X.Thank you in advance!
T. -
RE: TSM:FPAR:No Reply
I havent had got blob one yet so i havent got experience with it. But i red about the blob version and it should work....
But I suggest to you that you should buy these from reliable brand/shop. I think Itead or keyestudio are reliable brands. And i bought a pair nrf24 from ebyte, but it hasnt arrived yet. -
RE: Which microcontroller for Node
It sounds very good, but i have started to use nrf24 with arduino and sensebender stuffs so i would like to continue with these ... but thank you for the suggestions because in the future i will test the esp solution.
I havent decided yet which arduino i use... the sensebender micro is very good because it has good quality humidity ad temp sensor integrated on it, but it is a bit expensive... arduinpro mini with the same temp sensor is max 6-7USD
-
RE: Which microcontroller for Node
Dear gohan!
Does This mean that every node has an IP address and communicate with the gateway over my WiFi network?
Thanks
T -
RE: Which microcontroller for Node
Hi @LastSamurai
Thank you!
Which mini pro do you suggest? The 5V version?
What about the nano? It is about the same price as mini pro.Have you got reliable buying source?
Thank you!
T -
Which microcontroller for Node
Dear All!
I would like to place sensor nodes to all of my rooms.
I plan, that i will power these from a central power source (12V or 5V).
The distance between a node and the power source will be max 20m.
I would like to ask your opinion about:- which microcontroller do you suggest? (arduino nano, mini, sensebender micro) sensors will be: 1-2 relay, gas sensor, temp+hum, light, sound, motion
- should I power with 12V or the 5V is enough?
- Where do you buy low cost enclosure (something with nice design)?
Thank you in advance!
Best regards,
T. -
RE: Help make Openhab2 MQ2 AirQuality work
Unfortunately nothing changed:(
I paste the openhab log, when the mq2 sense something:2017-07-27 18:42:12.899 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2017-07-27 18:42:12.899 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 2 found in node 1 2017-07-27 18:42:12.900 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: level(V_LEVEL) value to: 4 2017-07-27 18:42:12.902 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 1/2 to 2017-07-27T18:42:12.000+0200 2017-07-27 18:42:19.369 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;2;1;0;37;0 2017-07-27 18:42:19.370 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway 2017-07-27 18:42:19.370 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 2 found in node 1 2017-07-27 18:42:19.371 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: level(V_LEVEL) value to: 0 2017-07-27 18:42:19.373 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 1/2 to 2017-07-27T18:42:19.000+0200
-
RE: Help make Openhab2 MQ2 AirQuality work
Dear All!
I dont know exactly what i did to make it work, but it is almost OK now.
Almost, because on the PaperUI the Control tab shows the right value of the Air Quality Meter, but on the BasicUI sitemap and in the OPENHAB ios APP shows only the Text (Air Quality ...) without the valueI attach the new sketch and code, if somebody could help me:
Sketch
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 1 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* TemperatureAndHumidity */ #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 5000; // 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] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_MQ 2 /*MQ2*/ float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; /*---------------------------------MQ2---------------------------------------------------------*/ /************************Hardware Related Macros************************************/ #define MQ_SENSOR_ANALOG_PIN (0) //define which analog input channel you are going to use #define RL_VALUE (5) //define the load resistance on the board, in kilo ohms #define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, //which is derived from the chart in datasheet /***********************Software Related Macros************************************/ #define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase #define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the //cablibration phase #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation #define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in //normal operation /**********************Application Related Macros**********************************/ #define GAS_LPG (0) #define GAS_CO (1) #define GAS_SMOKE (2) /*****************************Globals***********************************************/ //unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds) //VARIABLES float Ro = 10000.0; // this has to be tuned 10K Ohm int val = 0; // variable to store the value coming from the sensor float valMQ =0.0; float lastMQ =0.0; float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) float COCurve[3] = {2.3,0.72,-0.34}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15) float SmokeCurve[3] = {2.3,0.53,-0.44}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.53), point2:(lg10000,-0.22) /*--------------------MQ2 end---------------------------------*/ MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; MyMessage msg(CHILD_ID_MQ, V_LEVEL); void presentation() { // Send the sketch version information to the gateway // sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Temperature, Humidity and Gas", "1.1"); /*MQ2*/ // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_MQ, S_AIR_QUALITY); /*MQ2*/ // present(CHILD_ID_MQ, S_SMOKE); /*MQ2*/ metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); /*---MQ2---------------------------------------------------------*/ Ro = MQCalibration(MQ_SENSOR_ANALOG_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } /*----MQ2----*/ uint16_t valMQ = MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO); Serial.println(val); Serial.print("LPG:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_LPG) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("CO:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("SMOKE:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_SMOKE) ); Serial.print( "ppm" ); Serial.print("\n"); if (valMQ != lastMQ) { send(msg.set((int16_t)ceil(valMQ))); lastMQ = ceil(valMQ); } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } /*----MQ2----*/ /****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage Output: the calculated sensor resistance Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage across the load resistor and its resistance, the resistance of the sensor could be derived. ************************************************************************************/ float MQResistanceCalculation(int raw_adc) { return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc)); } /***************************** MQCalibration **************************************** Input: mq_pin - analog channel Output: Ro of the sensor Remarks: This function assumes that the sensor is in clean air. It use MQResistanceCalculation to calculates the sensor resistance in clean air and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 10, which differs slightly between different sensors. ************************************************************************************/ float MQCalibration(int mq_pin) { int i; float val=0; for (i=0; i<CALIBARAION_SAMPLE_TIMES; i++) { //take multiple samples val += MQResistanceCalculation(analogRead(mq_pin)); delay(CALIBRATION_SAMPLE_INTERVAL); } val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro //according to the chart in the datasheet return val; } /***************************** MQRead ********************************************* Input: mq_pin - analog channel Output: Rs of the sensor Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs). The Rs changes as the sensor is in the different consentration of the target gas. The sample times and the time interval between samples could be configured by changing the definition of the macros. ************************************************************************************/ float MQRead(int mq_pin) { int i; float rs=0; for (i=0; i<READ_SAMPLE_TIMES; i++) { rs += MQResistanceCalculation(analogRead(mq_pin)); delay(READ_SAMPLE_INTERVAL); } rs = rs/READ_SAMPLE_TIMES; return rs; } /***************************** MQGetGasPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro gas_id - target gas type Output: ppm of the target gas Remarks: This function passes different curves to the MQGetPercentage function which calculates the ppm (parts per million) of the target gas. ************************************************************************************/ int MQGetGasPercentage(float rs_ro_ratio, int gas_id) { if ( gas_id == GAS_LPG ) { return MQGetPercentage(rs_ro_ratio,LPGCurve); } else if ( gas_id == GAS_CO ) { return MQGetPercentage(rs_ro_ratio,COCurve); } else if ( gas_id == GAS_SMOKE ) { return MQGetPercentage(rs_ro_ratio,SmokeCurve); } return 0; } /***************************** MQGetPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro pcurve - pointer to the curve of the target gas Output: ppm of the target gas Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) of the line could be derived if y(rs_ro_ratio) is provided. As it is a logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic value. ************************************************************************************/ int MQGetPercentage(float rs_ro_ratio, float *pcurve) { return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0]))); } /*----MQ2----*/
Openhab codes:
/etc/openhab2/sitemaps# cat /etc/openhab2/things/demo.things
Bridge mysensors:bridge-eth:gateway [ ipAddress="100.100.6.41", tcpPort=5003, sendDelay=200, startupCheckEnabled=false,networkSanCheckEnabled=false ] {
/** define things connected to that bridge here */
humidity hum01 [ nodeId=1, childId=0 ]
temperature temp01 [ nodeId=1, childId=1 ]
airQuality airq01 [ nodeId=1, childId=2 ]
}/etc/openhab2/sitemaps# cat /etc/openhab2/items/demo.items
Number hum01 "Humidity" { channel="mysensors:humidity:gateway:hum01:hum" }
Number temp01 "Temperature" { channel="mysensors:temperature:gateway:temp01:temp" }
Number airq01 "AirQuality" { channel="mysensors:airquality:gateway:airq01:level" }:/etc/openhab2/sitemaps# cat /etc/openhab2/sitemaps/demo.sitemap
sitemap demo label="Main Menu" {
Frame {
Text item=hum01
Text item=temp01
Default item=airq01}
}
Thank you in advance!
Best regards,
T -
Help make Openhab2 MQ2 AirQuality work
Dear All!
I would like to configure my ethernet gateway + NODE 1 (DHT+MQ2) sensor node with openhab2
Some friends from here helped to me , so i could create the node's sketch. The temperature+humidity works, but i cant make the mq2 sensor work. I use the airquality sketch for it mixed it with the temperaturehumidity sketch.
The openhab get the value from the mq2 (based on the logs) but i cant display it on the website.
I have just seen that based on this table Controller table the airquality is not supported in the openhab 2 + mysensors . Is it true?Node's sketch:
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 1 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* TemperatureAndHumidity */ #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 5000; // 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] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; /*---------------------------------MQ2---------------------------------------------------------*/ #define CHILD_ID_MQ 2 /************************Hardware Related Macros************************************/ #define MQ_SENSOR_ANALOG_PIN (0) //define which analog input channel you are going to use #define RL_VALUE (5) //define the load resistance on the board, in kilo ohms #define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, //which is derived from the chart in datasheet /***********************Software Related Macros************************************/ #define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase #define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the //cablibration phase #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation #define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in //normal operation /**********************Application Related Macros**********************************/ #define GAS_LPG (0) #define GAS_CO (1) #define GAS_SMOKE (2) /*****************************Globals***********************************************/ //unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds) //VARIABLES float Ro = 10000.0; // this has to be tuned 10K Ohm int val = 0; // variable to store the value coming from the sensor float valMQ =0.0; float lastMQ =0.0; float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) float COCurve[3] = {2.3,0.72,-0.34}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15) float SmokeCurve[3] = {2.3,0.53,-0.44}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.53), point2:(lg10000,-0.22) /*--------------------MQ2 end---------------------------------*/ MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; MyMessage msg(CHILD_ID_MQ, V_LEVEL); void presentation() { // Send the sketch version information to the gateway // sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Temperature, Humidity and Gas", "1.1"); /*MQ2*/ // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_MQ, S_AIR_QUALITY); /*MQ2*/ // present(CHILD_ID_MQ, S_SMOKE); /*MQ2*/ metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); /*---MQ2---------------------------------------------------------*/ Ro = MQCalibration(MQ_SENSOR_ANALOG_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } /*----MQ2----*/ uint16_t valMQ = MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO); Serial.println(val); Serial.print("LPG:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_LPG) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("CO:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("SMOKE:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_SMOKE) ); Serial.print( "ppm" ); Serial.print("\n"); if (valMQ != lastMQ) { send(msg.set((int16_t)ceil(valMQ))); lastMQ = ceil(valMQ); } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } /*----MQ2----*/ /****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage Output: the calculated sensor resistance Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage across the load resistor and its resistance, the resistance of the sensor could be derived. ************************************************************************************/ float MQResistanceCalculation(int raw_adc) { return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc)); } /***************************** MQCalibration **************************************** Input: mq_pin - analog channel Output: Ro of the sensor Remarks: This function assumes that the sensor is in clean air. It use MQResistanceCalculation to calculates the sensor resistance in clean air and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 10, which differs slightly between different sensors. ************************************************************************************/ float MQCalibration(int mq_pin) { int i; float val=0; for (i=0; i<CALIBARAION_SAMPLE_TIMES; i++) { //take multiple samples val += MQResistanceCalculation(analogRead(mq_pin)); delay(CALIBRATION_SAMPLE_INTERVAL); } val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro //according to the chart in the datasheet return val; } /***************************** MQRead ********************************************* Input: mq_pin - analog channel Output: Rs of the sensor Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs). The Rs changes as the sensor is in the different consentration of the target gas. The sample times and the time interval between samples could be configured by changing the definition of the macros. ************************************************************************************/ float MQRead(int mq_pin) { int i; float rs=0; for (i=0; i<READ_SAMPLE_TIMES; i++) { rs += MQResistanceCalculation(analogRead(mq_pin)); delay(READ_SAMPLE_INTERVAL); } rs = rs/READ_SAMPLE_TIMES; return rs; } /***************************** MQGetGasPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro gas_id - target gas type Output: ppm of the target gas Remarks: This function passes different curves to the MQGetPercentage function which calculates the ppm (parts per million) of the target gas. ************************************************************************************/ int MQGetGasPercentage(float rs_ro_ratio, int gas_id) { if ( gas_id == GAS_LPG ) { return MQGetPercentage(rs_ro_ratio,LPGCurve); } else if ( gas_id == GAS_CO ) { return MQGetPercentage(rs_ro_ratio,COCurve); } else if ( gas_id == GAS_SMOKE ) { return MQGetPercentage(rs_ro_ratio,SmokeCurve); } return 0; } /***************************** MQGetPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro pcurve - pointer to the curve of the target gas Output: ppm of the target gas Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) of the line could be derived if y(rs_ro_ratio) is provided. As it is a logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic value. ************************************************************************************/ int MQGetPercentage(float rs_ro_ratio, float *pcurve) { return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0]))); } /*----MQ2----*/```
Openhab2 logs:
2017-07-25 21:17:29.818 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: temp(V_TEMP) value to: 27.0
2017-07-25 21:17:29.821 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 1/1 to 2017-07-25T21:17:29.000+0200
2017-07-25 21:17:29.821 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;0;1;0;1;36.0
2017-07-25 21:17:29.822 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway
2017-07-25 21:17:29.822 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 1
2017-07-25 21:17:29.822 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: hum(V_HUM) value to: 36.0
2017-07-25 21:17:29.823 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 1/0 to 2017-07-25T21:17:29.000+0200
2017-07-25 21:17:30.838 [DEBUG] [rsAbstractConnection$MySensorsReader] - Message from gateway received: 1;2;1;0;37;32111
2017-07-25 21:17:30.839 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 1 found in gateway
2017-07-25 21:17:30.839 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 2 not present in node 1Openhab codes:
Bridge mysensors:bridge-eth:gateway [ ipAddress="100.100.6.41", tcpPort=5003, sendDelay=200, startupCheckEnabled=false,networkSanCheckEnabled=false ] {
/** define things connected to that bridge here */
humidity hum01 [ nodeId=1, childId=0 ]
temperature temp01 [ nodeId=1, childId=1 ]
airquality airq01 [ nodeId=1, childId=2 ]
}items
Number hum01 "Humidity" { channel="mysensors:humidity:gateway:hum01:hum" }
Number temp01 "Temperature" { channel="mysensors:temperature:gateway:temp01:temp" }
Number airq01 "AirQuality" { channel="mysensors:airquality:gateway:airq01:level" }Thanking you in advance for the helping..
-
RE: Combine airquality, temperature code and send to the ethernet gateway
Dear Gohan!
I realized that I can not transfer the gas sensors calculated value through the V_LEVEL variable used in the sketch, because on the openhab side i should use tripped type value i think...
So i think there is a missconfiguration between openhab item/sitemap configuration and the sketch.The goal would be to display the mq2 sensor's calculated value, which i can use for alarm in the future, but now i will be happy about the value:)
Have a good day
-
RE: Combine airquality, temperature code and send to the ethernet gateway
Dear Gohan!
OK!
I paste the new code again:/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 1 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* TemperatureAndHumidity */ #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 5000; // 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] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; /*---------------------------------MQ2---------------------------------------------------------*/ #define CHILD_ID_MQ 2 /************************Hardware Related Macros************************************/ #define MQ_SENSOR_ANALOG_PIN (0) //define which analog input channel you are going to use #define RL_VALUE (5) //define the load resistance on the board, in kilo ohms #define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, //which is derived from the chart in datasheet /***********************Software Related Macros************************************/ #define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase #define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the //cablibration phase #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation #define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in //normal operation /**********************Application Related Macros**********************************/ #define GAS_LPG (0) #define GAS_CO (1) #define GAS_SMOKE (2) /*****************************Globals***********************************************/ //unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds) //VARIABLES float Ro = 10000.0; // this has to be tuned 10K Ohm int val = 0; // variable to store the value coming from the sensor float valMQ =0.0; float lastMQ =0.0; float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) float COCurve[3] = {2.3,0.72,-0.34}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15) float SmokeCurve[3] = {2.3,0.53,-0.44}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.53), point2:(lg10000,-0.22) /*--------------------MQ2 end---------------------------------*/ MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; MyMessage msg(CHILD_ID_MQ, V_LEVEL); void presentation() { // Send the sketch version information to the gateway // sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Temperature, Humidity and Gas", "1.1"); /*MQ2*/ // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_MQ, S_AIR_QUALITY); /*MQ2*/ //present(CHILD_ID_MQ, S_SMOKE); /*MQ2*/ metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); /*---MQ2---------------------------------------------------------*/ Ro = MQCalibration(MQ_SENSOR_ANALOG_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } /*----MQ2----*/ uint16_t valMQ = MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO); Serial.println(val); Serial.print("LPG:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_LPG) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("CO:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("SMOKE:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_SMOKE) ); Serial.print( "ppm" ); Serial.print("\n"); if (valMQ != lastMQ) { send(msg.set((int16_t)ceil(valMQ))); lastMQ = ceil(valMQ); } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } /*----MQ2----*/ /****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage Output: the calculated sensor resistance Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage across the load resistor and its resistance, the resistance of the sensor could be derived. ************************************************************************************/ float MQResistanceCalculation(int raw_adc) { return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc)); } /***************************** MQCalibration **************************************** Input: mq_pin - analog channel Output: Ro of the sensor Remarks: This function assumes that the sensor is in clean air. It use MQResistanceCalculation to calculates the sensor resistance in clean air and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 10, which differs slightly between different sensors. ************************************************************************************/ float MQCalibration(int mq_pin) { int i; float val=0; for (i=0; i<CALIBARAION_SAMPLE_TIMES; i++) { //take multiple samples val += MQResistanceCalculation(analogRead(mq_pin)); delay(CALIBRATION_SAMPLE_INTERVAL); } val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro //according to the chart in the datasheet return val; } /***************************** MQRead ********************************************* Input: mq_pin - analog channel Output: Rs of the sensor Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs). The Rs changes as the sensor is in the different consentration of the target gas. The sample times and the time interval between samples could be configured by changing the definition of the macros. ************************************************************************************/ float MQRead(int mq_pin) { int i; float rs=0; for (i=0; i<READ_SAMPLE_TIMES; i++) { rs += MQResistanceCalculation(analogRead(mq_pin)); delay(READ_SAMPLE_INTERVAL); } rs = rs/READ_SAMPLE_TIMES; return rs; } /***************************** MQGetGasPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro gas_id - target gas type Output: ppm of the target gas Remarks: This function passes different curves to the MQGetPercentage function which calculates the ppm (parts per million) of the target gas. ************************************************************************************/ int MQGetGasPercentage(float rs_ro_ratio, int gas_id) { if ( gas_id == GAS_LPG ) { return MQGetPercentage(rs_ro_ratio,LPGCurve); } else if ( gas_id == GAS_CO ) { return MQGetPercentage(rs_ro_ratio,COCurve); } else if ( gas_id == GAS_SMOKE ) { return MQGetPercentage(rs_ro_ratio,SmokeCurve); } return 0; } /***************************** MQGetPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro pcurve - pointer to the curve of the target gas Output: ppm of the target gas Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) of the line could be derived if y(rs_ro_ratio) is provided. As it is a logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic value. ************************************************************************************/ int MQGetPercentage(float rs_ro_ratio, float *pcurve) { return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0]))); } /*----MQ2----*/```
-
RE: Combine airquality, temperature code and send to the ethernet gateway
Thank you very much guys!
I had to modify things for openhab, it is better now. But...
in openhab2 i get this in the log:
2017-07-24 19:23:36.497 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 2 found in node 1
2017-07-24 19:23:36.498 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable V_LEVEL not presentDoes someone know what i missed?
Good afternoon!
-
RE: Combine airquality, temperature code and send to the ethernet gateway
Hi Gohan!
Thank you again for your help:)
I have uploaded already but i see that the link dont work.
I added comments to the MQ2 sections
Code/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0: Henrik EKblad * Version 1.1 - 2016-07-20: Converted to MySensors v2.0 and added various improvements - Torben Woltjen (mozzbozz) * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a DHT11/DHT-22. * * For more information, please visit: * http://www.mysensors.org/build/humidity * */ #define MY_NODE_ID 1 // Enable debug prints #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 //#define MY_RS485 /* TemperatureAndHumidity */ #include <SPI.h> #include <MySensors.h> #include <DHT.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 5000; // 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] static const uint8_t FORCE_UPDATE_N_READS = 10; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; /*---------------------------------MQ2---------------------------------------------------------*/ #define CHILD_ID_MQ 2 /************************Hardware Related Macros************************************/ #define MQ_SENSOR_ANALOG_PIN (0) //define which analog input channel you are going to use #define RL_VALUE (5) //define the load resistance on the board, in kilo ohms #define RO_CLEAN_AIR_FACTOR (9.83) //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO, //which is derived from the chart in datasheet /***********************Software Related Macros************************************/ #define CALIBARAION_SAMPLE_TIMES (50) //define how many samples you are going to take in the calibration phase #define CALIBRATION_SAMPLE_INTERVAL (500) //define the time interal(in milisecond) between each samples in the //cablibration phase #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation #define READ_SAMPLE_TIMES (5) //define the time interal(in milisecond) between each samples in //normal operation /**********************Application Related Macros**********************************/ #define GAS_LPG (0) #define GAS_CO (1) #define GAS_SMOKE (2) /*****************************Globals***********************************************/ unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) //VARIABLES float Ro = 10000.0; // this has to be tuned 10K Ohm int val = 0; // variable to store the value coming from the sensor float valMQ =0.0; float lastMQ =0.0; float LPGCurve[3] = {2.3,0.21,-0.47}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) float COCurve[3] = {2.3,0.72,-0.34}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000, 0.15) float SmokeCurve[3] = {2.3,0.53,-0.44}; //two points are taken from the curve. //with these two points, a line is formed which is "approximately equivalent" //to the original curve. //data format:{ x, y, slope}; point1: (lg200, 0.53), point2:(lg10000,-0.22) /*--------------------MQ2 end---------------------------------*/ MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); DHT dht; MyMessage msg(CHILD_ID_MQ, V_LEVEL); void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Air Quality Sensor", "1.0"); /*MQ2*/ // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_MQ, S_AIR_QUALITY); /*MQ2*/ metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); /*---MQ2---------------------------------------------------------*/ Ro = MQCalibration( MQ_SENSOR_ANALOG_PIN); //Calibrating the sensor. Please make sure the sensor is in clean air } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } /*----MQ2----*/ uint16_t valMQ = MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO); Serial.println(val); Serial.print("LPG:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_LPG) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("CO:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_CO) ); Serial.print( "ppm" ); Serial.print(" "); Serial.print("SMOKE:"); Serial.print(MQGetGasPercentage(MQRead(MQ_SENSOR_ANALOG_PIN)/Ro,GAS_SMOKE) ); Serial.print( "ppm" ); Serial.print("\n"); if (valMQ != lastMQ) { send(msg.set((int16_t)ceil(valMQ))); lastMQ = ceil(valMQ); } // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } /*----MQ2----*/ /****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage Output: the calculated sensor resistance Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage across the load resistor and its resistance, the resistance of the sensor could be derived. ************************************************************************************/ float MQResistanceCalculation(int raw_adc) { return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc)); } /***************************** MQCalibration **************************************** Input: mq_pin - analog channel Output: Ro of the sensor Remarks: This function assumes that the sensor is in clean air. It use MQResistanceCalculation to calculates the sensor resistance in clean air and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 10, which differs slightly between different sensors. ************************************************************************************/ float MQCalibration(int mq_pin) { int i; float val=0; for (i=0; i<CALIBARAION_SAMPLE_TIMES; i++) { //take multiple samples val += MQResistanceCalculation(analogRead(mq_pin)); delay(CALIBRATION_SAMPLE_INTERVAL); } val = val/CALIBARAION_SAMPLE_TIMES; //calculate the average value val = val/RO_CLEAN_AIR_FACTOR; //divided by RO_CLEAN_AIR_FACTOR yields the Ro //according to the chart in the datasheet return val; } /***************************** MQRead ********************************************* Input: mq_pin - analog channel Output: Rs of the sensor Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs). The Rs changes as the sensor is in the different consentration of the target gas. The sample times and the time interval between samples could be configured by changing the definition of the macros. ************************************************************************************/ float MQRead(int mq_pin) { int i; float rs=0; for (i=0; i<READ_SAMPLE_TIMES; i++) { rs += MQResistanceCalculation(analogRead(mq_pin)); delay(READ_SAMPLE_INTERVAL); } rs = rs/READ_SAMPLE_TIMES; return rs; } /***************************** MQGetGasPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro gas_id - target gas type Output: ppm of the target gas Remarks: This function passes different curves to the MQGetPercentage function which calculates the ppm (parts per million) of the target gas. ************************************************************************************/ int MQGetGasPercentage(float rs_ro_ratio, int gas_id) { if ( gas_id == GAS_LPG ) { return MQGetPercentage(rs_ro_ratio,LPGCurve); } else if ( gas_id == GAS_CO ) { return MQGetPercentage(rs_ro_ratio,COCurve); } else if ( gas_id == GAS_SMOKE ) { return MQGetPercentage(rs_ro_ratio,SmokeCurve); } return 0; } /***************************** MQGetPercentage ********************************** Input: rs_ro_ratio - Rs divided by Ro pcurve - pointer to the curve of the target gas Output: ppm of the target gas Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) of the line could be derived if y(rs_ro_ratio) is provided. As it is a logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic value. ************************************************************************************/ int MQGetPercentage(float rs_ro_ratio, float *pcurve) { return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0]))); } /*----MQ2----*/
Best regards,
T -
Combine airquality, temperature code and send to the ethernet gateway
Dear All!
My project: Node + EthernetGW + openhab2
I try to combine the two example sketch codes (I would like to trigger the MQ2 sensor for smoke) , but it seems that the node sends the MQ2 sensors values, but
-the gateway dont read that, and
-i think that the node send the data more frequently than it should do.GW
0;255;3;0;9;TSF:MSG:FPAR REQ,ID=1 0;255;3;0;9;TSF:PNG:SEND,TO=0 0;255;3;0;9;TSF:CKU:OK 0;255;3;0;9;TSF:MSG:GWL OK 0;255;3;0;9;TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=OK:0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 0;255;3;0;9;TSF:MSG:PINGED,ID=1,HP=1 0;255;3;0;9;TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 0;255;3;0;9;TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.1.1 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=11,pt=0,l=22,sg=0:TemperatureAndHumidity 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.1 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=11,pt=0,l=18,sg=0:Air Quality Sensor 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=0,t=7,pt=0,l=0,sg=0: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=0,t=6,pt=0,l=0,sg=0: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=2,c=0,t=22,pt=0,l=0,sg=0: 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 0;255;3;0;9;TSF:MSG:SEND,0-0-1-1,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:45.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:45.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:45.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:45.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:46.0 0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:45.0
NODE
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1 3 TSM:INIT 4 TSF:WUR:MS=0 11 TSM:INIT:TSP OK 13 TSM:INIT:STATID=1 15 TSF:SID:OK,ID=1 16 TSM:FPAR 53 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 875 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0 880 TSF:MSG:FPAR OK,ID=0,D=1 2060 TSM:FPAR:OK 2061 TSM:ID 2062 TSM:ID:OK 2064 TSM:UPL 2067 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 2076 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1 2081 TSF:MSG:PONG RECV,HP=1 2084 TSM:UPL:OK 2085 TSM:READY:ID=1,PAR=0,DIS=1 2091 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 2098 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 2105 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1 2113 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 4121 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=22,sg=0,ft=0,st=OK:TemperatureAndHumidity 4131 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.1 4141 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=18,sg=0,ft=0,st=OK:Air Quality Sensor 4150 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0 4158 TSF:MSG:SEND,1-1-0-0,s=0,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 4166 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK: 4173 TSF:MSG:SEND,1-1-0-0,s=2,c=0,t=22,pt=0,l=0,sg=0,ft=0,st=OK: 4179 MCO:REG:REQ 4183 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 4190 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1 4195 MCO:PIM:NODE REG=1 4197 MCO:BGN:STP 4199 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255 4204 MCO:SLP:TPD 4206 MCO:SLP:WUP=-1 4208 MCO:BGN:INIT OK,TSP=1 4235 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:26.0 T: 26.00 4243 TSF:MSG:SEND,1-1-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:46.0 H: 46.00 0 LPG:0ppm CO:0ppm SMOKE:0ppm 5257 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255 5262 MCO:SLP:TPD 5263 MCO:SLP:WUP=-1 0 LPG:0ppm CO:0ppm SMOKE:0ppm 6294 MCO:SLP:MS=5000,SMS=0,I1=255,M1=255,I2=255,M2=255 6299 MCO:SLP:TPD``` **Combined Node Sketch**
Im attach the sketch of the node.0_1500791513747_DHT_MQ2_uj.ino
Another question will be, that is this code OK for openhab:
The temp and humidity works as expect, everything is OK. but the new manually entered code seems isnot recognized , but the openhab automatic search find the new child sensor but the values are zero.~# cat /etc/openhab2/things/demo.things Bridge mysensors:bridge-eth:gateway [ ipAddress="100.100.6.41", tcpPort=5003, sendDelay=200, startupCheckEnabled=false,networkSanCheckEnabled=false ] { /** define things connected to that bridge here */ humidity hum01 [ nodeId=1, childId=0 ] temperature temp01 [ nodeId=1, childId=1 ] AirQuality airq01 [ nodeId=1, childId=2 ] }
cat /etc/openhab2/items/demo.items Number hum01 "Humidity" { channel="mysensors:humidity:gateway:hum01:hum" } Number temp01 "Temperature" { channel="mysensors:temperature:gateway:temp01:temp" } Number airq01 "AirQuality" { channel="mysensors:airQuality:gateway:airq01:level" }
cat /etc/openhab2/sitemaps/demo.sitemap sitemap demo label="Main Menu" { Frame { Text item=hum01 Text item=temp01 Text item=airq01 } }
Thank you your help!
Best regards,
T -
How nodes select gateways?
Dear All!
I would like to use multiple gateways and pair these to specific nodes.
How can i pair nodes and gateways?
I use ethernet gateway (uno+w5100)Thanks
T -
RE: openhab mysensors ethernet gateway value missing
I downgraded to 1.6.11 , and it seems working:
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:28.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:19.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:25.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:28.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:19.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:25.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:29.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:28.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:19.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:25.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:28.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:19.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:25.0
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=0,c=1,t=1,pt=7,l=5,sg=0:28.0Im trying to troubleshoot openhab, because the temprature and humidity values are 0 .
Thank you very much for the idea!
-
RE: openhab mysensors ethernet gateway value missing
I found the answer to my question:) https://forum.mysensors.org/topic/4462/gatewayw5100-unable-to-get-working-w-v2-0-0/2
But why the downgrade should be a solution? The latest version Arduino AVR board doesnt compatible with all clone?
Thanks, T
-
RE: openhab mysensors ethernet gateway value missing
@TimO
Dear TimO!What does downgrafing the board definition means?
Im beginner sorryHave a good day!
T -
RE: TSM:FPAR:No Reply
I see. I hope, i can use it for a while:).
I think im closed this topic. The solution was to change the nrf24 modules, because i could not pair them.
The anoother problem was that i use two power source, and i didnt common the GND.Thank you everyone who helped to me!
(I run into another problem, if you had some free time:) openhab-mysensors-ethernet-gateway-value-missing
-
openhab mysensors ethernet gateway value missing
Dear All!
My problem is, that openhab 2.2 (snapshot) show my gateway + temp + hum things online, but values are missing.
(additional info, that first I installed openhab2 stable (same results) with apt, after it i change the repo to snapshot and installed it with apt upgrade)The sensor node sends the temp and hum values to gateway, and i see that the gateway receive these., but in openhab no values.
I followed these:
https://www.mysensors.org/build/ethernet_gateway
https://github.com/tobof/openhab2-addons/wikiGateway monitor:
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:28.0
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 100.100.1.41
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:26.0
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 100.100.1.41
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=0,pt=7,l=5,sg=0:28.0
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 100.100.1.41
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1 -
RE: TSM:FPAR:No Reply
Thanks for the suggestions.
Had you got problems with nrf24?
Tomorrow i will try to configure openhab. I have tried to find a quick up to date guide for openhab 2 + mqtt mysensors but font find one.
Mysensors said that their bindigs support only ethernet or serial gateway officially.
I dont understand what is the diff (or why mqtt used mostly) the ethernet and mqtt solution but i have started the mqtt already.Best regards
T -
RE: TSM:FPAR:No Reply
Hi rejoe2!
What kind of nrf24 do you use, and where did you buy these?
I think that you use capacitor as well, and stable 3.3V dont you?
Do you think that this shield is good for my node? It would be very good if i didnt have to use cables for nrf24....
https://www.itead.cc/wiki/Arduino_Nano_IO_shieldBest regards
T -
RE: TSM:FPAR:No Reply
On ebay, i cant find the bypass capacitor in the specs. I have written to a seller asked about it. I will report to you about the answer.
I have tried once again the two high power nrf24 pa+lna (I put foil onto these) but these dont work. I think these are broken or very very bad ones.
Could you suggest to me a seller who sells High power nrf24 which ones you have got good experinces?
Thanks,
T -
RE: TSM:FPAR:No Reply
Dear rejoe2!
Thank You for the infos.
Than i will buy two of this ebay version.Best regards,
T -
RE: TSM:FPAR:No Reply
Oh! I missed that. I will look for another one with cap.
-
RE: TSM:FPAR:No Reply
Dear gohan!
Thank you for your help. I will buy from ebay this one: https://www.ebay.com/itm/200960749614
And im planning that i will buy a shielded nrf24 pa+lna .
Today im installing an openhab and try to transfer the datas from gateway to the openhab...What projects have you done already?
Best regards
T -
RE: TSM:FPAR:No Reply
Dear Gohan!
Everyone suggests that if you use pa+lna version you should power it from external regulated 3.3 V because the arduino clones 3.3V isnt strong enough. So i bought externaI power source.... i have figured out today that i can common the power source's gnd with the arduino gnd. It is working....What is last that i would like to power the arduino uno from power module 5V and connect it to my computer same time... i dont know how to do it.
I have tested the two nrf24 pa+lna and these arent working together only. Separately is OK.
I will go with the standard nrf24 , make it working than i will try to buy branded nrf24 pa+lna.
Have you got favourite brand for cheaper electronic parts? -
RE: TSM:FPAR:No Reply
Dear Gohan!
I have just tried the new nrf24 standard, and it works!
It seems that the GND should be common (im newbie).
I would like to test further with the pa+lna version, but....
I have an other question.
I would like to power the board with 5V from the power module 5V output, and i would like to program the board via USB at the same time. How should i connect the power module to the board? -
RE: TSM:FPAR:No Reply
Dear gohan!
Sorry, it is a private home server and it was in maintenance mode when you were trying to connect. Now it should be working.
(The new nrf24 have just arrived so im going to try these as soon as i can)Best regards
T -
RE: TSM:FPAR:No Reply
Oh ok. Thanks.
I tried to attach 100uF capacitor but the results are same.(no reply) . The node ID is defined, the parent ID isnt.
It seems that im out of ideas. I wait for the new nrf24 without pa lna.
Im attaching some pictures about the project.
Should i foil the nrf24 modul?https://cloud.freeforall.hu/owncloud/public.php?service=files&t=1f73fddc20c6d9a2560f88f78affd499
-
RE: TSM:FPAR:No Reply
Hi Ben!
I havent define the parent ID because i havent known that i should do. i will try these settings as soon as i can.
I have already defined the node id in the node sketch
Thank you!
T -
RE: TSM:FPAR:No Reply
Dear gohan!
I have tried but nothing change. I bought two nrf24 from keyestudio without pa/lna , if it arrives i will try those.
I will write the experiences with the new ones.Best regards
T -
RE: TSM:FPAR:No Reply
Dear gonhan!
First of all, thank you for your help.
I have two power module (https://www.ebay.com/itm/262102860958 ) with an mb102 bread board and i use it for powering my nrf24. I use a 7.5v 1000mA adapter to power the modules.
The capacitor is a 47uF one.
I power the two microcontrollers through USB connected to my laptop at the same time, because at this way i can switch the console output between the two controllers when i would like to see the output.I try to follow the guides described here. All parts are from keyestudio except the two nrf24(with antenna) module.
I use the mysensors latest library , gatewayW5100mqttclient and a dht11 example sketch (but i have tried already another official mysensors lightsensor sketch) on the node.
-
TSM:FPAR:No Reply
Dear All!
Im beginner in the wireless sensor node + gateway world, and I started to build a simple MQTTClient Gateway (UNO R3 + W5100 + nrf24) with an DHT11 Sensor node (Arduino nano + DHT11 + nrf24).
The gateway and the node are seems to be working, but the node says that
"!TSM:FPAR:NO REPLY"Could someone help me what might be the problem?
The full messages:
NODE
0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
3 TSM:INIT
4 TSF:WUR:MS=0
11 TSM:INIT:TSP OK
13 TSM:INIT:STATID=2
14 TSF:SID:OK,ID=2
16 TSM:FPAR
53 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
2060 !TSM:FPAR:NO REPLY
2062 TSM:FPAR
2098 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
4106 !TSM:FPAR:NO REPLY
4108 TSM:FPAR
4144 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
6152 !TSM:FPAR:NO REPLY
6154 TSM:FPAR
6190 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
8198 !TSM:FPAR:FAIL
8199 TSM:FAIL:CNT=1
8201 TSM:FAIL:PDT
18204 TSM:FAIL:RE-INIT
18206 TSM:INIT
18213 TSM:INIT:TSP OK
18215 TSM:INIT:STATID=2
18217 TSF:SID:OK,ID=2
18220 TSM:FPAR
18256 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
20264 !TSM:FPAR:NO REPLY
20267 TSM:FPAR
20303 TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:GW
0;255c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
IP: 100.100.13.150
0;255;3;0;9;MCO:BGN:STP
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
IP: 100.100.13.150
0;255;3;0;9;Attempting MQTT connection...
0;255;3;0;9;MQTT connected
0;255;3;0;9;Sending message on topic: mygateway1-out/0/255/0/0/18
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0:
0;255;3;0;9;!TSF:MSG:LEN,0!=7
0;255;3;0;9;TSF:MSG:READ,0-0-0,s=0,c=0,t=0,pt=0,l=0,sg=0: