Solved. Issue with power supply. Added a capacidade to power source.
Posts made by Oumuamua
-
RE: Node broadcast loop
-
Node broadcast loop
Hi all,
I have a node with 2 sensor that have been working well for weeks and suddenly starts to loop on some kind of broadcasting message. It comes back if I restart the RPI+Gateway (but not if I just restart the Mysensor service at RPI).
I would like to solve it the right way, instead of having to reboot the server every time it happens.
This is the log at the server:
Oct 13 20:44:27 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Oct 13 20:44:27 DEBUG TSF:MSG:BC Oct 13 20:44:27 DEBUG TSF:MSG:FPAR REQ,ID=2 Oct 13 20:44:27 DEBUG TSF:CKU:OK,FCTRL Oct 13 20:44:27 DEBUG TSF:MSG:GWL OK Oct 13 20:44:28 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Oct 13 20:44:30 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Oct 13 20:44:30 DEBUG TSF:MSG:BC Oct 13 20:44:30 DEBUG TSF:MSG:FPAR REQ,ID=2 Oct 13 20:44:30 DEBUG TSF:CKU:OK,FCTRL Oct 13 20:44:30 DEBUG TSF:MSG:GWL OK Oct 13 20:44:31 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Oct 13 20:44:32 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Oct 13 20:44:32 DEBUG TSF:MSG:BC Oct 13 20:44:32 DEBUG TSF:MSG:FPAR REQ,ID=2 Oct 13 20:44:32 DEBUG TSF:CKU:OK,FCTRL Oct 13 20:44:32 DEBUG TSF:MSG:GWL OK Oct 13 20:44:34 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Oct 13 20:45:35 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Oct 13 20:45:35 DEBUG TSF:MSG:BC Oct 13 20:45:35 DEBUG TSF:MSG:FPAR REQ,ID=2 Oct 13 20:45:35 DEBUG TSF:PNG:SEND,TO=0 Oct 13 20:45:35 DEBUG TSF:CKU:OK Oct 13 20:45:35 DEBUG TSF:MSG:GWL OK Oct 13 20:45:37 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
This is the node's 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 * */ // Enable debug prints #define MY_DEBUG // Atualizar para nó esperado #define MY_NODE_ID 2 // Novo driver para gateway RPI #define MY_RFM69_NEW_DRIVER // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) #define MY_IS_RFM69HW // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case #include <SPI.h> #include <MySensors.h> #include <DHT.h> #include <NewPing.h> // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 3 // Sonar parameters #define TRIGGER_PIN 8 // Arduino pin tied to trigger pin on the ultrasonic sensor. #define ECHO_PIN 9 // Arduino pin tied to echo pin on the ultrasonic sensor. #define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm. #define ITERATIONS 5 // Number of iterations. // Set this offset if the sensor has a permanent small offset to the real temperatures. // In Celsius degrees (as measured by the device) #define SENSOR_TEMP_OFFSET 0 NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance. // Sleep time between sensor updates (in milliseconds) // Must be >1000ms for DHT22 and >2000ms for DHT11 static const uint64_t UPDATE_INTERVAL = 600000; // 600000 = 10 min // 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 = 5; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_RSSI 2 //RSSI #define CHILD_ID_VOLT 3 //Voltage #define CHILD_ID_DIST 4 //Distance //float lastTemp; //float lastHum; //uint8_t nNoUpdatesTemp; //uint8_t nNoUpdatesHum; bool metric = true; int8_t rssiVal; //RSSI uint8_t dist; //static const uint8_t update_count = 6; // 6 = every 1 hour //uint8_t count = 100; // > than update_count MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgRSSI(CHILD_ID_RSSI,V_VAR5); MyMessage msgDist(CHILD_ID_DIST, V_DISTANCE); MyMessage msgVOLT(CHILD_ID_VOLT,V_VOLTAGE); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("Temperature+Humidity+Sonar", "2.0"); // sendSketchInfo("Battery Meter", "1.0"); // sendSketchInfo("No02_DHT11+Sonar_v06"); // 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_RSSI, S_CUSTOM); present(CHILD_ID_DIST, S_DISTANCE); present(CHILD_ID_VOLT, S_MULTIMETER); metric = getControllerConfig().isMetric; } void setup() { // Battery // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif 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()); } 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 { // } 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; // apply the offset before converting to something different than Celsius degrees temperature += SENSOR_TEMP_OFFSET; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter // nNoUpdatesTemp = 0; send(msgTemp.set(temperature, 2)); #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 { // } 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, 2)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif // } else { // Increase no update counter if the humidity stayed the same // nNoUpdatesHum++; } // rssiVal = _radio.readRSSI(); // Old Driver rssiVal = RFM69_getSendingRSSI(); // New Driver send(msgRSSI.set(rssiVal)); #ifdef MY_DEBUG Serial.print("RSSI Sending: "); Serial.println(rssiVal); // Serial.print("RSSI Receiving: "); // Serial.println(RFM69_getReceivingRSSI()); #endif dist = sonar.convert_cm(sonar.ping_median(ITERATIONS, MAX_DISTANCE)); #ifdef MY_DEBUG Serial.print("Dist: "); Serial.print(dist); Serial.println("cm"); #endif if (dist > 0) { dist = 90 - dist; send(msgDist.set(dist, 2)); } long batteryMillivolts = hwCPUVoltage(); send(msgVOLT.set(batteryMillivolts / 1000.0, 2)); #ifdef MY_DEBUG Serial.print(batteryMillivolts / 1000.0); Serial.println(" V"); #endif // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }
This is the configuration of the RPI gateway
./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-user=user --my-mqtt-password=password --my-mqtt-publish-topic-prefix=mygateway1-out --my-mqtt-subscribe-topic-prefix=mygateway1-in --my-mqtt-client-id=gw_02 --my-transport=rfm69 --my-rfm69-frequency=433 --my-is-rfm69hw --extra-cxxflags="-DMY_DEBUG_VERBOSE_GATEWAY"
Thanks!
-
RE: Sudden battery drain - Pro-mini + RFM69
Hi all,
Should anyone face the same problem, I found the root cause: brownout threshold. I burned a new bootloader (Optiboot 8.0) without such trigger and the node has been working with used batteries (~2.7V) since May.
Hope this helps.
-
RE: Consistent NACK + RPI Gateway
Thanks for the hint @mfalkvidd
After much research (mainly here and here), it does look like RFM69+RPI+Mysensors 2.3.x don't like each other very much.
However, I updated my RPI code to the latest version (at RPI, move to MySensors directory, then "git pull", then make+install gateway again) and the NACK problem was completely solved. I also had many NACK during presentation, which all went away. Problem solved and it seems that the radio is performing faster (probably less time waiting ACK).
I also tried to address the low RSSI at gateway (again, it seems a recurring problem for RFM69+RPI) using this code, but it didn't "make".
Would you have any insight on the RSSI issue as well? It seems that you participated in some part of the discussion (here ).
Thanks!
-
Consistent NACK + RPI Gateway
Hi all,
Since I moved to RPI gateway (which I prefer), I've been having consistent NACK on some messages. I suspect it is related (but maybe not the cause) with some node reboots / battery drain.
On one node, I always (and I ran multiple tests) NACK when sending the RSSI message, despite temperature and humidity never get NACK.
I already tried sending RSSI before Temp and Hum, but it always get NACK.
The MQTT server still receives the information.
Any insight on why this is happening?
Node debug log
17:31:35.480 -> 32362 TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=1,st=OK:24.00 17:31:35.580 -> 32467 TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:95.00 17:31:37.836 -> 34721 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=NACK:-61
Gateway log
Jun 15 17:31:35 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:24.00 Jun 15 17:31:35 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Jun 15 17:31:35 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.00 Jun 15 17:31:35 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Jun 15 17:31:36 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=48,pt=2,l=2,sg=0:-61 Jun 15 17:31:36 DEBUG TSF:MSG:ECHO REQ Jun 15 17:31:39 DEBUG !TSF:MSG:SEND,0-0-2-2,s=2,c=1,t=48,pt=2,l=2,sg=0,ft=0,st=NACK:-61 Jun 15 17:31:39 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/48,MSG SENT
Node 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 * */ // Enable debug prints #define MY_DEBUG // Atualizar para nó esperado #define MY_NODE_ID 2 // Novo driver para gateway RPI #define MY_RFM69_NEW_DRIVER // Enable and select radio type attached //#define MY_RADIO_RF24 #define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) #define MY_IS_RFM69HW // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case #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 // select the input pin for the battery sense point int BATTERY_SENSE_PIN = A0; int oldBatteryPcnt = 0; // Set this offset if the sensor has a permanent small offset to the real temperatures. // In Celsius degrees (as measured by the device) #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 = 600000; // 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 = 5; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_RSSI 2 //RSSI #define CHILD_ID_BAT 3 //BATTERY float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; int8_t rssiVal; //RSSI char rssiStr[10]; //RSSI MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgRSSI(CHILD_ID_RSSI,V_CUSTOM); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Battery Meter", "1.0"); /// sendSketchInfo("DHT11-v05"); // 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_RSSI, S_CUSTOM); metric = getControllerConfig().isMetric; } void setup() { // Battery // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif 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()); } 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; // apply the offset before converting to something different than Celsius degrees temperature += SENSOR_TEMP_OFFSET; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; send(msgTemp.set(temperature, 2)); #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, 2)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // rssiVal = _radio.readRSSI(); // Old Driver rssiVal = RFM69_getReceivingRSSI(); // New Driver send(msgRSSI.set(rssiVal), true); #ifdef MY_DEBUG Serial.print("RSSI: "); Serial.println(rssiVal); #endif // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }
-
RE: Sudden battery drain - Pro-mini + RFM69
I haven’t moved the sensor to a weatherproof case (still figuring out the new design), but I connected it to an external power source.
The circuit is operating perfectly.
If humidity or something alike had damaged it, it should be not working, right?
Although I think it is important to use the weatherproof case, I feel something else is happening here.
@skywatch: where I live in BR temperature ranges between 5-36C. I can see some fluctuations in battery V when temp changes, but usually around 0.05V
Thanks!
-
RE: Sudden battery drain - Pro-mini + RFM69
Thanks @zboblamont !
I will try changing to a weatherproof case.
Today I realized I started having the sudden battery drain after I moved to a Raspberry PI gateway and therefore had to add #define MY_RFM69_NEW_DRIVER to my code.
Could it also be the case that the new driver has some bug that consumes the battery (e.g. holds the radio on)?
Thanks,
-
RE: Sudden battery drain - Pro-mini + RFM69
In case someone has the same issue, quick update:
I cleaned the battery contacts, added some solder (maybe they would not get oxidized) and put new batteries.
However, after 6 days, there was the sudden drop in battery again. From 3.0 to 2.5 in less than 24 hours.
Still don't know what is the problem...
-
RE: Sudden battery drain - Pro-mini + RFM69
Thanks @skywatch for the reply.
The board is pretty clean. After your comments, I also checked the led and regulator contacts (I removed both, mediocre but good enough job).
However, I think the battery contacts have oxidized. I cleaned that and am testing again.
Does anyone have any tips on how to avoid battery terminals to get oxidized? Adding solder tin on that battery case avoids that?
Thanks!
-
Sudden battery drain - Pro-mini + RFM69
Hi all,
I have a node based on Pro-Mini 3v + RFM69 + SI7021 that runs on 2 AA batteries. I use a Raspberry Pi gateway and Openhab as controller.
I had for the second time the problem of sudden battery drain. In the first time, I assumed the problem was the wearing out of the board (it stays outdoor in a case, but you can see the dirt and humidity kind of making the board + wires look bad).
I changed the whole kit for a new board, sensor and radio and also changed the bootload for Minicore bootloader (following this instruction).
However, after after a little more the 1 month, I got the same problem, as you can see below:
These were a brand new pair of AA batteries. After a couple of days offline (I was traveling when the sensor shut down), they measured on 2.4V.
I've checked the log file in Raspberrry, but nothing seemed unusual.
One thing that called my attention is that the node should check the battery level once a day, but since March 23, it had checked it more frequently.
Can anyone help me with it?
This is the node 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: Yveaux * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a Si7021 sensor. * * For more information, please visit: * http://www.mysensors.org/build/humiditySi7021 * */ // Enable debug prints //#define MY_DEBUG // Atualizar para nó esperado #define MY_NODE_ID 3 // Enable REPORT_BATTERY_LEVEL to measure battery level and send changes to gateway #define REPORT_BATTERY_LEVEL //#define REPORT_BATTERY_LEVEL_EXT // Novo driver para gateway RPI #define MY_RFM69_NEW_DRIVER // Enable and select radio type attached //#define MY_RADIO_RF24 #define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) //#define MY_IS_RFM69HW // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case #include <MySensors.h> static bool metric = true; // Sleep time between sensor updates (in milliseconds) static const uint64_t UPDATE_INTERVAL = 600000; // 600000 = 10 minutos #include <SI7021.h> static SI7021 sensor; #ifdef REPORT_BATTERY_LEVEL_EXT // BatteryPoweredSensor - Code int BATTERY_SENSE_PIN = A1; // select the input pin for the battery sense point // int oldBatteryPcnt = 0; #endif #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_RSSI 2 //RSSI #define CHILD_ID_VOLT 3 //Battary Voltage int16_t rssiVal; //RSSI MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgRSSI(CHILD_ID_RSSI,V_VAR5); MyMessage msgVOLT(CHILD_ID_VOLT,V_VOLTAGE); // Variables for update intervals and other static const float min_temp_chg = 0.4; // min change to send temperatura - 0.4 C (sensor error) static const uint8_t min_hum_chg = 3; // min change to send humidity - 3% (sensor error) static const uint8_t interv_temp = 72; // 12 hrs * 6 measurement / hour = 72 static const uint8_t interv_hum = 72; // 12 hrs * 6 measurement / hour = 72 static const uint8_t interv_bat_rssi = 144; // 24 hrs * 6 measurement / hour = 144 float last_temp; float last_hum; uint8_t cont_temp = interv_temp + 1; uint8_t cont_hum = interv_hum + 1; uint8_t cont_bat_rssi = interv_bat_rssi + 1; void presentation() { Serial.println("Presentation Begin"); // Send the sketch info to the gateway sendSketchInfo("Si7021_Tem_Hum_v07", "2.0"); // Present sensors as children to gateway present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_RSSI, S_CUSTOM); present(CHILD_ID_VOLT, S_MULTIMETER); metric = getControllerConfig().isMetric; Serial.println("Presentation OK"); #ifdef MY_DEBUG #endif } void setup() { Serial.println("Setup Begin"); while (not sensor.begin()) { Serial.println(F("Sensor not detected!")); delay(5000); } // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif Serial.println("Setup OK"); } void loop() { #ifdef MY_DEBUG Serial.println("Loop begin"); Serial.print(F("min_temp_chg ")); Serial.println(min_temp_chg); Serial.print(F("min_hum_chg ")); Serial.println(min_hum_chg); Serial.print(F("interv_temp ")); Serial.println(interv_temp); Serial.print(F("interv_hum ")); Serial.println(interv_hum); Serial.print(F("interv_bat_rssi ")); Serial.println(interv_bat_rssi); Serial.print(F("last_temp ")); Serial.println(last_temp); Serial.print(F("last_hum ")); Serial.println(last_hum); Serial.print(F("cont_temp ")); Serial.println(cont_temp); Serial.print(F("cont_hum ")); Serial.println(cont_hum); Serial.print(F("cont_bat_rssi ")); Serial.println(cont_bat_rssi); #endif // Read temperature & humidity from sensor. const float temperature = float( metric ? sensor.getCelsiusHundredths() : sensor.getFahrenheitHundredths() ) / 100.0; const float humidity = float( sensor.getHumidityBasisPoints() ) / 100.0; #ifdef MY_DEBUG Serial.print(F("Temp ")); Serial.print(temperature); Serial.print(metric ? 'C' : 'F'); Serial.print(F("\tHum ")); Serial.println(humidity); #endif if ( abs(last_temp - temperature) > min_temp_chg || cont_temp > interv_temp) { send(msgTemp.set(temperature, 2)); cont_temp = 0; last_temp = temperature; } else { cont_temp = cont_temp + 1; } if ( abs(last_hum - humidity) > min_hum_chg || cont_hum > interv_hum) { send(msgHum.set(humidity, 2)); cont_hum = 0; last_hum = humidity; } else { cont_hum = cont_hum + 1; } if ( cont_bat_rssi > interv_bat_rssi ) { #ifdef REPORT_BATTERY_LEVEL // get the battery Voltage #ifdef REPORT_BATTERY_LEVEL_EXT // 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 sensorValue = analogRead(BATTERY_SENSE_PIN); float batteryV = sensorValue * 0.003216031; // medido send(msgVOLT.set(batteryV, 2)); #ifdef MY_DEBUG Serial.print("Sensor Read: "); Serial.println(sensorValue); Serial.print("External volt: "); Serial.print(batteryV); Serial.println(" V"); #endif #else long batteryMillivolts = hwCPUVoltage(); send(msgVOLT.set(batteryMillivolts / 1000.0, 2)); #ifdef MY_DEBUG Serial.println("Else"); Serial.print(batteryMillivolts / 1000.0); Serial.println(" V"); #endif #endif #endif rssiVal = RFM69_getReceivingRSSI(); // New Driver send(msgRSSI.set(rssiVal, 2)); #ifdef MY_DEBUG Serial.print("RSSI: "); Serial.println(rssiVal); #endif cont_bat_rssi = 0; } else { cont_bat_rssi = cont_bat_rssi + 1; } // Sleep until next update to save energy #ifdef MY_DEBUG Serial.println("Sleep Start"); #endif sleep(UPDATE_INTERVAL); #ifdef MY_DEBUG Serial.println("Wake up!"); #endif }
-
RE: Raspberry Pi 3 (RPI 3) + MQTT gateway NACK and triple messages
Thanks @mfalkvidd @OldSurferDude !
The problem really was the antenna. I was using the helical antenna below and I welded in the "wrong" part of it the first time. The second I welded it on the "right" place and it work. The RSSI is still below that the old and good wire... am I welding it on the really right place?
Are helical antennas good?
Thanks again for the great support you provide.
-
Raspberry Pi 3 (RPI 3) + MQTT gateway NACK and triple messages
Hi all,
Following a previous post on my transition to a RPI gateway + MQTT, I'm now experiencing two problems:
- Significant NACK ocurrencies, specially when connecting to gateway
- messages to MQTT gateway tripled
As per the logs below, node and gateway are able to connect (they are 4m away), RSSI seems to be very good (-30 to -40), but there number of connection attempts with NACK are not justified.
Also, for each message sent from node, there are three (sometimes 2, sometimes 4) messages sent by gateway to MQTT server.
I've already changed the antenna on the gateway radio. I haven't tried another radio as this one seems to be working well.
Both logs were taken in paralell (see timestamp)
Many thanks for any help!!
Node Log
08:02:11.829 -> __ __ ____ 08:02:11.829 -> | \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___ 08:02:11.829 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __| 08:02:11.829 -> | | | | |_| |___| | __/ | | \__ \ _ | | \__ \ 08:02:11.829 -> |_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/ 08:02:11.863 -> |___/ 2.3.2 08:02:11.863 -> 08:02:11.863 -> 16 MCO:BGN:INIT NODE,CP=RPNNA---,FQ=16,REL=255,VER=2.3.2 08:02:11.863 -> 26 TSM:INIT 08:02:11.863 -> 28 TSF:WUR:MS=0 08:02:11.863 -> 29 TSM:INIT:TSP OK 08:02:11.863 -> 31 TSM:INIT:STATID=2 08:02:11.863 -> 33 TSF:SID:OK,ID=2 08:02:11.863 -> 35 TSM:FPAR 08:02:12.361 -> 540 ?TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 08:02:14.355 -> 2511 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0 08:02:14.355 -> 2516 TSF:MSG:FPAR OK,ID=0,D=1 08:02:14.388 -> 2547 TSM:FPAR:OK 08:02:14.388 -> 2548 TSM:ID 08:02:14.388 -> 2549 TSM:ID:OK 08:02:14.388 -> 2551 TSM:UPL 08:02:17.909 -> 6069 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 08:02:19.204 -> 7389 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1 08:02:19.204 -> 7394 TSF:MSG:PONG RECV,HP=1 08:02:19.238 -> 7396 TSM:UPL:OK 08:02:19.238 -> 7398 TSM:READY:ID=2,PAR=0,DIS=1 08:02:22.560 -> 10728 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100 08:02:23.723 -> 11901 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 08:02:27.246 -> 15421 !TSF:MSG:SEND,2-2-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=1,st=NACK:2.3.2 08:02:30.768 -> 18941 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=2,st=NACK:0 08:02:36.318 -> 24473 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=11,pt=0,l=22,sg=0,ft=3,st=NACK:TemperatureAndHumidity 08:02:39.841 -> 27993 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=4,st=NACK:1.1 08:02:43.364 -> 31519 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=5,st=NACK:Battery Meter 08:02:46.887 -> 35038 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=6,st=NACK:1.0 08:02:50.409 -> 38559 !TSF:MSG:SEND,2-2-0-0,s=0,c=0,t=7,pt=0,l=0,sg=0,ft=7,st=NACK: 08:02:53.898 -> 42077 !TSF:MSG:SEND,2-2-0-0,s=1,c=0,t=6,pt=0,l=0,sg=0,ft=8,st=NACK: 08:02:57.419 -> 45599 !TSF:MSG:SEND,2-2-0-0,s=2,c=0,t=23,pt=0,l=0,sg=0,ft=9,st=NACK: 08:02:57.453 -> 45605 MCO:REG:REQ 08:03:00.943 -> 49121 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=10,st=NACK:2 08:03:00.976 -> 49127 !TSM:READY:UPL FAIL,SNP 08:03:00.976 -> 49130 TSM:FPAR 08:03:01.474 -> 49635 ?TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=11,st=OK: 08:03:02.869 -> 51050 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1 08:03:02.903 -> 51055 MCO:PIM:NODE REG=1 08:03:04.898 -> 53058 !TSM:FPAR:NO REPLY 08:03:04.898 -> 53060 TSM:FPAR 08:03:05.396 -> 53565 ?TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 08:03:07.157 -> 55321 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0 08:03:07.157 -> 55326 TSF:MSG:FPAR OK,ID=0,D=1 08:03:07.423 -> 55572 TSM:FPAR:OK 08:03:07.423 -> 55573 TSM:ID 08:03:07.423 -> 55575 TSM:ID:OK 08:03:07.423 -> 55576 TSM:UPL 08:03:10.946 -> 59095 !TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=NACK:1 08:03:12.242 -> 60406 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1 08:03:12.242 -> 60411 TSF:MSG:PONG RECV,HP=1 08:03:12.242 -> 60414 TSM:UPL:OK 08:03:12.242 -> 60416 TSM:READY:ID=2,PAR=0,DIS=1 08:03:12.242 -> 60419 MCO:BGN:STP 08:03:12.242 -> 60422 MCO:SLP:MS=1000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:03:12.276 -> 60427 TSF:TDI:TSL 08:03:13.339 -> 60429 MCO:SLP:WUP=-1 08:03:13.339 -> 60431 TSF:TRI:TSB 08:03:13.372 -> 60433 MCO:BGN:INIT OK,TSP=1 08:03:16.894 -> 63969 !TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=NACK:22.0 08:03:16.894 -> T: 22.00 08:03:20.450 -> 67511 !TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=1,st=NACK:95.0 08:03:20.450 -> H: 95.00 08:03:23.940 -> 71028 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=2,st=NACK:-32 08:03:23.973 -> RSSI: -32 08:03:23.973 -> 71034 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:03:23.973 -> 71041 TSF:TDI:TSL 08:04:28.339 -> 71043 MCO:SLP:WUP=-1 08:04:28.339 -> 71045 TSF:TRI:TSB 08:04:31.893 -> 74582 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=3,st=NACK:-32 08:04:31.893 -> RSSI: -32 08:04:31.893 -> 74588 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:04:31.893 -> 74594 TSF:TDI:TSL 08:05:36.231 -> 74596 MCO:SLP:WUP=-1 08:05:36.231 -> 74598 TSF:TRI:TSB 08:05:39.785 -> 78135 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=4,st=NACK:-32 08:05:39.785 -> RSSI: -32 08:05:39.785 -> 78141 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:05:39.785 -> 78147 TSF:TDI:TSL 08:06:44.132 -> 78149 MCO:SLP:WUP=-1 08:06:44.132 -> 78151 TSF:TRI:TSB 08:06:47.683 -> 81691 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=5,st=NACK:-32 08:06:47.683 -> RSSI: -32 08:06:47.683 -> 81697 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:06:47.683 -> 81703 TSF:TDI:TSL 08:07:52.039 -> 81705 MCO:SLP:WUP=-1 08:07:52.039 -> 81708 TSF:TRI:TSB 08:07:52.039 -> 81709 !TSM:READY:UPL FAIL,SNP 08:07:52.039 -> 81712 TSM:FPAR 08:07:52.537 -> 82219 ?TSF:MSG:SEND,2-2-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=6,st=OK: 08:07:52.570 -> 82247 !TSF:SND:TNR 08:07:52.570 -> RSSI: -32 08:07:52.570 -> 82249 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:07:52.570 -> 82254 !MCO:SLP:TNR 08:07:53.700 -> 83374 TSF:MSG:READ,0-0-2,s=255,c=3,t=8,pt=1,l=1,sg=0:0 08:07:53.700 -> 83379 TSF:MSG:FPAR OK,ID=0,D=1 08:07:54.564 -> 84226 TSM:FPAR:OK 08:07:54.564 -> 84227 TSM:ID 08:07:54.564 -> 84229 TSM:ID:OK 08:07:54.564 -> 84230 TSM:UPL 08:07:57.188 -> 86844 TSF:MSG:SEND,2-2-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 08:07:58.882 -> 88552 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1 08:07:58.882 -> 88557 TSF:MSG:PONG RECV,HP=1 08:07:58.882 -> 88560 TSM:UPL:OK 08:07:58.882 -> 88561 TSM:READY:ID=2,PAR=0,DIS=1 08:07:58.882 -> 88564 MCO:SLP:MS=53692 08:07:58.882 -> 88566 TSF:TDI:TSL 08:08:56.465 -> 88568 MCO:SLP:WUP=-1 08:08:56.465 -> 88570 TSF:TRI:TSB 08:09:00.018 -> 92109 !TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=NACK:94.0 08:09:00.018 -> H: 94.00 08:09:01.946 -> 94031 TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=1,st=OK:-32 08:09:01.946 -> RSSI: -32 08:09:01.946 -> 94038 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:09:01.946 -> 94044 TSF:TDI:TSL 08:10:06.293 -> 94046 MCO:SLP:WUP=-1 08:10:06.293 -> 94048 TSF:TRI:TSB 08:10:09.848 -> 97585 !TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=NACK:23.0 08:10:09.848 -> T: 23.00 08:10:13.370 -> 101126 !TSF:MSG:SEND,2-2-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=1,st=NACK:95.0 08:10:13.370 -> H: 95.00 08:10:16.890 -> 104649 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=2,st=NACK:-33 08:10:16.924 -> RSSI: -33 08:10:16.924 -> 104655 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:10:16.924 -> 104662 TSF:TDI:TSL 08:11:21.281 -> 104664 MCO:SLP:WUP=-1 08:11:21.281 -> 104666 TSF:TRI:TSB 08:11:24.800 -> 108204 !TSF:MSG:SEND,2-2-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=3,st=NACK:22.0 08:11:24.800 -> T: 22.00 08:11:28.355 -> 111744 !TSF:MSG:SEND,2-2-0-0,s=2,c=1,t=28,pt=2,l=2,sg=0,ft=4,st=NACK:-33 08:11:28.355 -> RSSI: -33 08:11:28.355 -> 111750 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255 08:11:28.355 -> 111756 TSF:TDI:TSL 08:12:32.710 -> 111758 MCO:SLP:WUP=-1 08:12:32.710 -> 111760 TSF:TRI:TSB
Gateway Log
Sep 03 08:01:53 INFO Starting gateway... Sep 03 08:01:53 INFO Protocol version - 2.3.2 Sep 03 08:01:53 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,FQ=NA,REL=255,VER=2.3.2 Sep 03 08:01:53 DEBUG TSF:LRT:OK Sep 03 08:01:53 DEBUG TSM:INIT Sep 03 08:01:53 DEBUG TSF:WUR:MS=0 Sep 03 08:01:53 DEBUG TSM:INIT:TSP OK Sep 03 08:01:53 DEBUG TSM:INIT:GW MODE Sep 03 08:01:53 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Sep 03 08:01:53 DEBUG MCO:REG:NOT NEEDED Sep 03 08:01:53 DEBUG MCO:BGN:STP Sep 03 08:01:53 DEBUG MCO:BGN:INIT OK,TSP=1 Sep 03 08:01:53 DEBUG GWT:RMQ:CONNECTING... Sep 03 08:01:53 DEBUG connected to 127.0.0.1 Sep 03 08:01:53 DEBUG GWT:RMQ:OK Sep 03 08:01:53 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Sep 03 08:01:53 DEBUG TSM:READY:NWD REQ Sep 03 08:01:54 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Sep 03 08:02:12 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Sep 03 08:02:12 DEBUG TSF:MSG:BC Sep 03 08:02:12 DEBUG TSF:MSG:FPAR REQ,ID=2 Sep 03 08:02:12 DEBUG TSF:PNG:SEND,TO=0 Sep 03 08:02:12 DEBUG TSF:CKU:OK Sep 03 08:02:12 DEBUG TSF:MSG:GWL OK Sep 03 08:02:16 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Sep 03 08:02:17 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 Sep 03 08:02:17 DEBUG TSF:MSG:PINGED,ID=2,HP=1 Sep 03 08:02:21 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 Sep 03 08:02:21 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100 Sep 03 08:02:24 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100 Sep 03 08:02:25 DEBUG TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2 Sep 03 08:02:25 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/0/0/17,MSG SENT Sep 03 08:02:26 DEBUG TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.2 Sep 03 08:02:26 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/0/0/17,MSG SENT Sep 03 08:02:28 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 Sep 03 08:02:28 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/6,MSG SENT Sep 03 08:02:29 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 Sep 03 08:02:29 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/6,MSG SENT Sep 03 08:02:31 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:0 Sep 03 08:02:31 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/6,MSG SENT Sep 03 08:02:33 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=22,sg=0:TemperatureAndHumidity Sep 03 08:02:33 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:35 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=22,sg=0:TemperatureAndHumidity Sep 03 08:02:35 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:36 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=22,sg=0:TemperatureAndHumidity Sep 03 08:02:36 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:38 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.1 Sep 03 08:02:38 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/12,MSG SENT Sep 03 08:02:39 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.1 Sep 03 08:02:39 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/12,MSG SENT Sep 03 08:02:40 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=13,sg=0:Battery Meter Sep 03 08:02:40 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:42 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=13,sg=0:Battery Meter Sep 03 08:02:42 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:43 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=13,sg=0:Battery Meter Sep 03 08:02:43 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/11,MSG SENT Sep 03 08:02:45 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0 Sep 03 08:02:45 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/12,MSG SENT Sep 03 08:02:46 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.0 Sep 03 08:02:46 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/255/3/0/12,MSG SENT Sep 03 08:02:47 DEBUG TSF:MSG:READ,2-2-0,s=0,c=0,t=7,pt=0,l=0,sg=0: Sep 03 08:02:47 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/0/0/7,MSG SENT Sep 03 08:02:49 DEBUG TSF:MSG:READ,2-2-0,s=0,c=0,t=7,pt=0,l=0,sg=0: Sep 03 08:02:49 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/0/0/7,MSG SENT Sep 03 08:02:50 DEBUG TSF:MSG:READ,2-2-0,s=0,c=0,t=7,pt=0,l=0,sg=0: Sep 03 08:02:50 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/0/0/7,MSG SENT Sep 03 08:02:52 DEBUG TSF:MSG:READ,2-2-0,s=1,c=0,t=6,pt=0,l=0,sg=0: Sep 03 08:02:52 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/0/0/6,MSG SENT Sep 03 08:02:53 DEBUG TSF:MSG:READ,2-2-0,s=1,c=0,t=6,pt=0,l=0,sg=0: Sep 03 08:02:53 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/0/0/6,MSG SENT Sep 03 08:02:54 DEBUG TSF:MSG:READ,2-2-0,s=2,c=0,t=23,pt=0,l=0,sg=0: Sep 03 08:02:54 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/0/0/23,MSG SENT Sep 03 08:02:56 DEBUG TSF:MSG:READ,2-2-0,s=2,c=0,t=23,pt=0,l=0,sg=0: Sep 03 08:02:56 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/0/0/23,MSG SENT Sep 03 08:02:57 DEBUG TSF:MSG:READ,2-2-0,s=2,c=0,t=23,pt=0,l=0,sg=0: Sep 03 08:02:57 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/0/0/23,MSG SENT Sep 03 08:02:59 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2 Sep 03 08:03:02 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=NACK:1 Sep 03 08:03:05 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Sep 03 08:03:05 DEBUG TSF:MSG:BC Sep 03 08:03:05 DEBUG TSF:MSG:FPAR REQ,ID=2 Sep 03 08:03:05 DEBUG TSF:PNG:SEND,TO=0 Sep 03 08:03:05 DEBUG TSF:CKU:OK Sep 03 08:03:05 DEBUG TSF:MSG:GWL OK Sep 03 08:03:09 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Sep 03 08:03:10 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 Sep 03 08:03:10 DEBUG TSF:MSG:PINGED,ID=2,HP=1 Sep 03 08:03:14 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 Sep 03 08:03:15 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:22.0 Sep 03 08:03:15 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:03:16 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:22.0 Sep 03 08:03:16 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:03:17 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.0 Sep 03 08:03:17 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:03:19 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.0 Sep 03 08:03:19 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:03:20 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.0 Sep 03 08:03:20 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:03:22 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:03:22 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:03:23 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:03:23 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:04:29 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:04:29 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:04:30 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:04:30 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:04:32 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:04:32 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:05:37 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:05:37 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:05:38 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:05:38 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:05:40 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:05:40 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:06:45 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:06:45 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:06:46 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:06:46 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:06:47 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:06:47 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:07:52 DEBUG TSF:MSG:READ,2-2-255,s=255,c=3,t=7,pt=0,l=0,sg=0: Sep 03 08:07:52 DEBUG TSF:MSG:BC Sep 03 08:07:52 DEBUG TSF:MSG:FPAR REQ,ID=2 Sep 03 08:07:52 DEBUG TSF:PNG:SEND,TO=0 Sep 03 08:07:52 DEBUG TSF:CKU:OK Sep 03 08:07:52 DEBUG TSF:MSG:GWL OK Sep 03 08:07:56 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0 Sep 03 08:07:57 DEBUG TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 Sep 03 08:07:57 DEBUG TSF:MSG:PINGED,ID=2,HP=1 Sep 03 08:08:00 DEBUG !TSF:MSG:SEND,0-0-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=NACK:1 Sep 03 08:08:58 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:94.0 Sep 03 08:08:58 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:08:59 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:94.0 Sep 03 08:08:59 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:09:01 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:09:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:09:01 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-32 Sep 03 08:09:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:10:07 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:10:07 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:10:08 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:10:08 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:10:10 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:10:10 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:10:11 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.0 Sep 03 08:10:11 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:10:12 DEBUG TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:95.0 Sep 03 08:10:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/0/1/0/1,MSG SENT Sep 03 08:10:14 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:10:14 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:10:15 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:10:15 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:10:17 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:10:17 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:11:22 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:22.0 Sep 03 08:11:22 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:11:23 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:22.0 Sep 03 08:11:23 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:11:25 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:22.0 Sep 03 08:11:25 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:11:26 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:11:26 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:11:27 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:11:27 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:12:33 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:12:33 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:12:35 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:12:35 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:12:36 DEBUG TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:23.0 Sep 03 08:12:36 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/1/1/0/0,MSG SENT Sep 03 08:12:37 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:12:37 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT Sep 03 08:12:39 DEBUG TSF:MSG:READ,2-2-0,s=2,c=1,t=28,pt=2,l=2,sg=0:-33 Sep 03 08:12:39 DEBUG GWT:TPS:TOPIC=mygateway1-out/2/2/1/0/28,MSG SENT
Gateway config
./configure --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-user=user --my-mqtt-password=pswd --my-mqtt-publish-topic-prefix=mygateway1-out --my-mqtt-subscribe-topic-prefix=mygateway1-in --my-mqtt-client-id=gw_02 --my-transport=rfm69 --my-rfm69-frequency=433 --my-is-rfm69hw --extra-cxxflags="-DMY_DEBUG_VERBOSE_GATEWAY"
Node config
/** * 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 * */ // Enable debug prints #define MY_DEBUG // Atualizar para nó esperado #define MY_NODE_ID 2 // Novo driver para gateway RPI #define MY_RFM69_NEW_DRIVER // Enable and select radio type attached //#define MY_RADIO_RF24 #define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) #define MY_IS_RFM69HW // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case #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 // select the input pin for the battery sense point int BATTERY_SENSE_PIN = A0; int oldBatteryPcnt = 0; // Set this offset if the sensor has a permanent small offset to the real temperatures. // In Celsius degrees (as measured by the device) #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 = 60000; // 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 = 5; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_RSSI 2 //RSSI #define CHILD_ID_BAT 3 //BATTERY float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; int16_t rssiVal; //RSSI char rssiStr[10]; //RSSI MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgRSSI(CHILD_ID_RSSI,V_VAR5); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); sendSketchInfo("Battery Meter", "1.0"); /// sendSketchInfo("DHT11-v05"); // 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_RSSI, S_CUSTOM); metric = getControllerConfig().isMetric; } void setup() { // Battery // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif 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()); } 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; // apply the offset before converting to something different than Celsius degrees temperature += SENSOR_TEMP_OFFSET; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; 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++; } // rssiVal = _radio.readRSSI(); // Old Driver rssiVal = RFM69_getReceivingRSSI(); // New Driver send(msgRSSI.set(rssiVal)); #ifdef MY_DEBUG Serial.print("RSSI: "); Serial.println(rssiVal); #endif // Sleep for a while to save energy sleep(UPDATE_INTERVAL); }
-
RE: Raspberry Pi 3 (RPI 3) gateway initialization loop
Problem solved: I was using as --my-mqtt-client-id the same name as my previous broker.
Thanks for your help all!
-
RE: Raspberry Pi 3 (RPI 3) gateway initialization loop
My thanks for the quick hints.
Yes, Mosquitto is running on the same machine.
I added --extra-cxxflags="-DMY_DEBUG_VERBOSE_GATEWAY to the configure file and also updated the Mosquitto conf as per @mfalkvidd suggestion.
Unfortunately the log did change (see below).
One important comment: the connection is actually successful with the MQTT server as I can see all the publications in it using MQTT Explorer. It seems to me that the problem is with the gateway in some way that keeps sending it non-stop.
The problem happens if I just run mysgw or when I start the service.
Aug 28 07:39:11 INFO Starting gateway... Aug 28 07:39:11 INFO Protocol version - 2.3.2 Aug 28 07:39:11 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,FQ=NA,REL=255,VER=2.3.2 Aug 28 07:39:11 DEBUG TSF:LRT:OK Aug 28 07:39:11 DEBUG TSM:INIT Aug 28 07:39:11 DEBUG TSF:WUR:MS=0 Aug 28 07:39:11 DEBUG TSM:INIT:TSP OK Aug 28 07:39:11 DEBUG TSM:INIT:GW MODE Aug 28 07:39:11 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Aug 28 07:39:11 DEBUG MCO:REG:NOT NEEDED Aug 28 07:39:11 DEBUG MCO:BGN:STP Aug 28 07:39:11 DEBUG MCO:BGN:INIT OK,TSP=1 Aug 28 07:39:11 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:11 DEBUG connected to 127.0.0.1 Aug 28 07:39:11 DEBUG GWT:RMQ:OK Aug 28 07:39:11 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:11 DEBUG TSM:READY:NWD REQ Aug 28 07:39:12 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Aug 28 07:39:12 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:12 DEBUG connected to 127.0.0.1 Aug 28 07:39:12 DEBUG GWT:RMQ:OK Aug 28 07:39:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:12 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:12 DEBUG connected to 127.0.0.1 Aug 28 07:39:12 DEBUG GWT:RMQ:OK Aug 28 07:39:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:12 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:12 DEBUG connected to 127.0.0.1 Aug 28 07:39:12 DEBUG GWT:RMQ:OK Aug 28 07:39:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:12 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:12 DEBUG connected to 127.0.0.1 Aug 28 07:39:12 DEBUG GWT:RMQ:OK Aug 28 07:39:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:12 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:12 DEBUG connected to 127.0.0.1 Aug 28 07:39:12 DEBUG GWT:RMQ:OK Aug 28 07:39:12 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 28 07:39:13 DEBUG GWT:RMQ:CONNECTING... Aug 28 07:39:13 DEBUG connected to 127.0.0.1 Aug 28 07:39:13 DEBUG GWT:RMQ:OK Aug 28 07:39:13 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT
-
Raspberry Pi 3 (RPI 3) gateway initialization loop
Hi all,
I have a working ESP8266 gateway with 2 nodes, but I want to move the gateway to my Raspberry.
I followed all the instructions on the website and had a successful installation.
However, I notice that the gateway enters a loop on its initialization and keeps sending the version of MySensors to the MQTT server.
The gateway configuration is:
./configure --my-transport=rfm69 --my-rfm69-frequency=433 --my-is-rfm69hw --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-user=user --my-mqtt-password=password --my-mqtt-publish-topic-prefix=mygateway1-out --my-mqtt-subscribe-topic-prefix=mygateway1-in --my-mqtt-client-id=gw_01
My Raspberry runs:
Raspbian GNU/Linux 11 (bullseye)
Where I run Openhab 3.3.0
When I run mysgw or start the service, it keeps sending the same message over an over again (many times per second) as below:
Aug 27 23:16:00 INFO Starting gateway... Aug 27 23:16:00 INFO Protocol version - 2.3.2 Aug 27 23:16:00 DEBUG MCO:BGN:INIT GW,CP=RPNGL---,FQ=NA,REL=255,VER=2.3.2 Aug 27 23:16:00 DEBUG TSF:LRT:OK Aug 27 23:16:00 DEBUG TSM:INIT Aug 27 23:16:00 DEBUG TSF:WUR:MS=0 Aug 27 23:16:00 DEBUG TSM:INIT:TSP OK Aug 27 23:16:00 DEBUG TSM:INIT:GW MODE Aug 27 23:16:00 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Aug 27 23:16:00 DEBUG MCO:REG:NOT NEEDED Aug 27 23:16:00 DEBUG MCO:BGN:STP Aug 27 23:16:00 DEBUG MCO:BGN:INIT OK,TSP=1 Aug 27 23:16:00 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:00 DEBUG connected to 127.0.0.1 Aug 27 23:16:00 DEBUG GWT:RMQ:OK Aug 27 23:16:00 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:00 DEBUG TSM:READY:NWD REQ Aug 27 23:16:00 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Aug 27 23:16:00 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:00 DEBUG connected to 127.0.0.1 Aug 27 23:16:00 DEBUG GWT:RMQ:OK Aug 27 23:16:00 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:01 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:01 DEBUG connected to 127.0.0.1 Aug 27 23:16:01 DEBUG GWT:RMQ:OK Aug 27 23:16:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:01 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:01 DEBUG connected to 127.0.0.1 Aug 27 23:16:01 DEBUG GWT:RMQ:OK Aug 27 23:16:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:01 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:01 DEBUG connected to 127.0.0.1 Aug 27 23:16:01 DEBUG GWT:RMQ:OK Aug 27 23:16:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:01 DEBUG GWT:RMQ:CONNECTING... Aug 27 23:16:01 DEBUG connected to 127.0.0.1 Aug 27 23:16:01 DEBUG GWT:RMQ:OK Aug 27 23:16:01 DEBUG GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT Aug 27 23:16:01 DEBUG GWT:RMQ:CONNECTING...
Many thanks for any help.
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Guys,
Just quick update to help others that may find this topic relevant: problem is solved. Problem was the step-up (probably low quality). Sensor is working well and with very low battery usage (no change in 5 days).
Thanks for the comments.
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Hi all,
Thanks for all the help.
After some testing and letting the node run for some days, it seems that the issue is partially solved: battery consumption is very low when the node is idle.
However, the battery consumption seems to reach full runtime levels when something happens with the gateway. My follow-up question is:
What exactly happens happens when the node sends a message to a gateways that is either unreachable or cannot pass the message on (to a MQTT server, for example)? Shouldn't the node try a couple of times and then move on to sleep as per the code?
I have been working on my home network and had to disconnect / reboot the router, gateway, etc.
Every time it happens, two situations occurred:
-
gateway didn't report updates to the MQTT server (probably an issue with the gateway as the sensors are meters away and have -25 to -40 RSSI levels, I reseted the gateway in those few circumstances)
-
message reaches the gateway and MQTT server, but the controller didn't record it (Openhab), in which case I rebooted the controller
Many thanks again,
-
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Guys, quick update:
Seems the step-up had a problem. Changed to a new one does not use that much current.
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Hi,
Thanks for all replies.
@skywatch : thanks! I was running a test with a 1 min loop but didn't change the description.
@Yveaux : have you been able to run up to 63% without the booster? my sensor stops working when the battery is at 2.8v (2x AA)
@eiten : this might be the latest issue I'm having. Even with my limited current measurement, the step-up is actually using a crazy 11mA (not uA) when idle. Same current as when not connected with the board.
Will investigate further and post back.
Thanks all,
-
RE: Instable ESP32 MQTT gateway with RFM69
Hi,
How is you sensors powered?
I had the same problem, but the gateway was not reseting as frequently. One thing I noticed, but am still testing is that when the batteries on the node go below 2.8v (on a 3.3V pro-mini), for some reason, the gateway halts (i have to reboot it manually). It seems weird, so I'm still testing.
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
******* IMPORTANTE UPDATE **********
Actually there is also a step-up converter, bought through the MySensors site (DC-DC Step Up Boost Module 3v3).
What's the impact of the step-up converter on power consumption while the circuit is in sleeping mode?
Thanks,
-
RE: [SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Duracell PlusPower (alkaline).
An update: I was able to measure the currency using the powersource below (which is actually very helpful for testing) and it seem to be using 20 mA for 1s between sleeps and less than 1mA as currency is show zero (probably the 120uA estimated by MySensors).
So consumption seem to be as expected.
If I make all calculations with the above values, I should have around 6 months battery life.
I will try to get new batteries, as those are probably +1 year old.
any further thought is welcome.
Thanks
-
[SOLVED] High battery usage (Pro-Mini / RFM69 / Si7021)
Hi all,
A have a plain vanilla Temperature + Humidity sensor using all standard codes from MySensors. I saw a lot of posts mentioning +1year battery life, but I am getting a couple of weeks (11 days actually).
I use a pro-mini 3V (removed the led and regulator), with a RFM69 (433MHz) and the SI7021. I also setup the battery level measurement setup as per the website (2 resistors, but have not used the capacitor).
Below is the code I used. The only customization I made on the regular code was adding a way to measure the RSSI.
I also tried to check the actual current, but without any success with my multimeter (maybe it is not sensible enough). Does disabling DEBUG reduce battery consumption (arduino is not connected to any serial port to receive debug anyway).
Any though is much appreciated.
/** * 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: Yveaux * * DESCRIPTION * This sketch provides an example of how to implement a humidity/temperature * sensor using a Si7021 sensor. * * For more information, please visit: * http://www.mysensors.org/build/humiditySi7021 * */ // Enable debug prints #define MY_DEBUG // Atualizar para nó esperado #define MY_NODE_ID 3 // Enable REPORT_BATTERY_LEVEL to measure battery level and send changes to gateway #define REPORT_BATTERY_LEVEL // Enable and select radio type attached //#define MY_RADIO_RF24 #define MY_RADIO_RFM69 //#define MY_RS485 #define MY_RFM69_FREQUENCY RFM69_433MHZ // Define for frequency setting. Needed if you're radio module isn't 868Mhz (868Mhz is default in lib) //#define MY_IS_RFM69HW // Mandatory if you radio module is the high power version (RFM69HW and RFM69HCW), Comment it if it's not the case #include <MySensors.h> static bool metric = true; // Sleep time between sensor updates (in milliseconds) static const uint64_t UPDATE_INTERVAL = 60000; //10 minutos #include <SI7021.h> static SI7021 sensor; #ifdef REPORT_BATTERY_LEVEL //#include <Vcc.h> //static uint8_t oldBatteryPcnt = 200; // Initialize to 200 to assure first time value will be sent. //const float VccMin = 1.8; // Minimum expected Vcc level, in Volts: Brownout at 1.8V -> 0% //const float VccMax = 2.0*1.6; // Maximum expected Vcc level, in Volts: 2xAA fresh Alkaline -> 100% //const float VccCorrection = 1.0; // Measured Vcc by multimeter divided by reported Vcc //static Vcc vcc(VccCorrection); //Código novo - BatteryPoweredSensor int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int oldBatteryPcnt = 0; #endif #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_RSSI 2 //RSSI #define CHILD_ID_VOLT 3 //Battary Voltage int16_t rssiVal; //RSSI MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgRSSI(CHILD_ID_RSSI,V_VAR5); MyMessage msgVOLT(CHILD_ID_VOLT,V_VOLTAGE); void presentation() { // Send the sketch info to the gateway sendSketchInfo("Si7021_Tem_Hum_v03", "2.0"); // Present sensors as children to gateway present(CHILD_ID_HUM, S_HUM, "Humidity"); present(CHILD_ID_TEMP, S_TEMP, "Temperature"); present(CHILD_ID_RSSI, S_CUSTOM, "RSSI"); present(CHILD_ID_VOLT, S_MULTIMETER, "Voltage"); metric = getControllerConfig().isMetric; } void setup() { while (not sensor.begin()) { Serial.println(F("Sensor not detected!")); delay(5000); } // use the 1.1 V internal reference #if defined(__AVR_ATmega2560__) analogReference(INTERNAL1V1); #else analogReference(INTERNAL); #endif } void loop() { // Read temperature & humidity from sensor. const float temperature = float( metric ? sensor.getCelsiusHundredths() : sensor.getFahrenheitHundredths() ) / 100.0; const float humidity = float( sensor.getHumidityBasisPoints() ) / 100.0; #ifdef MY_DEBUG Serial.print(F("Temp ")); Serial.print(temperature); Serial.print(metric ? 'C' : 'F'); Serial.print(F("\tHum ")); Serial.println(humidity); #endif static MyMessage msgHum( CHILD_ID_HUM, V_HUM ); static MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); send(msgTemp.set(temperature, 2)); send(msgHum.set(humidity, 2)); #ifdef REPORT_BATTERY_LEVEL // get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); // 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; float batteryV = sensorValue * 0.003216031; // medido #ifdef MY_DEBUG Serial.println(sensorValue); 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; static MyMessage msgVolt(CHILD_ID_VOLT, V_VOLTAGE); send(msgVolt.set(batteryV, 2)); } #endif rssiVal = _radio.readRSSI(); send(msgRSSI.set(rssiVal)); #ifdef MY_DEBUG Serial.print("RSSI: "); Serial.println(rssiVal); #endif // Sleep until next update to save energy #ifdef MY_DEBUG Serial.println("Sleep Start"); #endif sleep(UPDATE_INTERVAL); #ifdef MY_DEBUG Serial.println("Wake up!"); #endif }
-
RE: ESP8266 Gateway (RFM69) Soft WDT reset every 5 - 10 min
Hi Sasquatch,
I'm new to mysensors and arduino and not an electrical engineer. Could you the scheme on how to add the capacitor? I really appreciate any "for dummy" explanation.
Thanks!
-
RE: ESP8266 Gateway (RFM69) Soft WDT reset every 5 - 10 min
Hi Stefan,
I'm also facing a similar problem (here), but starting with the second sensor added (not 60 as you).
Do you know what is the reset cause? Mine is rst cause:4, boot mode:(3,7)
In my case I need to switch off all sensors and turn them on only after rebooting the gateway.
Will follow this post to check if there is any help for me.
Thanks,
-
RE: ESP8266 + RFM69 Reset loop (rst cause:4, boot mode:(3,7))
No, actually I use the RPi just as power source. The gateway connects to the hub over WiFi.
The RPi is good (the original one). I will try to move to an independent power source just to test.
Thanks for the reply again.
-
RE: ESP8266 + RFM69 Reset loop (rst cause:4, boot mode:(3,7))
Many thanks for the reply!
You are right, I'm not running the gateway on battery. Not sure if it could impact, but I connected the gateway to one of the USB ports on the Raspberry PI running OpenhabianPi.
Gateway runs a Esp8266 Nodemcu V3 (WeMos LoLin) and HopeRF RFM69HCW Wireless Transceiver - 434MHz
After some testing, it seems that the problem occurs when I have the 2nd started before the gateway. As a matter of fact it runs the HopeRF RFM69CW 433Mhz (not HCW). Would that matter?
Thanks!
-
ESP8266 + RFM69 Reset loop (rst cause:4, boot mode:(3,7))
Hi all,
First of all, thank you for the great project that My Sensors is.
I built my first node and gateway system and it worked well for weeks until I added a second mode. At first it worked well, but when I moved the second mode to batteries (vs. power adaptor) the Gateway started to enter in reboot loop.
The strange part is that it works well for some days and then it stops working.
Apparently (but had mixed results when testing), if I switch off all nodes and then reboot the gateway, it resumes working. If the nodes are kept running, gateway enters in reboot loop:
ets Jan 8 2013,rst cause:4, boot mode:(3,7)
After some testing, it seems that sometimes the gateway can catch up with a running node, sometimes it cannot and enter the reboot loop.
Any help will be much appreciated.