@mfalkvidd hmm, that’s a nice suggestion... I don’t have motion sensors where they are but maybe I can integrate it on the actual node...
Will give it some thought.
Thanks!
@mfalkvidd hmm, that’s a nice suggestion... I don’t have motion sensors where they are but maybe I can integrate it on the actual node...
Will give it some thought.
Thanks!
Hi everyone.
I've introduced a small 0.96" OLED display (based on the SSD1306) on the temperature and humidity node, so you can read directly the values as you enter the house compartment (as you can see above).
Since i dont know the reliability of this kind of displays and they are a bit bright (of if they have some kind of burn-in issue), im asking you guys for some ideas to turn it off and back on, maybe taking into account info got from the controller (and even display other info).
Im using the u8g2 display library wich has the instruction "setContrast", but these displays dont support contrast control. It seems the only way is to turn it off with the instruction "setPowerSave".
I was thinking of displaying the current date also and maybe turn it off at night. For this i was thinking of using the "requestTime()" command…
What do you guys think?
Here is my code so you can take a look and use on your own projects:
// Enable debug prints
//#define MY_DEBUG
#define MY_RADIO_RFM69
#define MY_IS_RFM69HW
#define MY_RFM69_NEW_DRIVER
#define MY_RFM69_FREQUENCY RFM69_433MHZ
#define MY_NODE_ID 15
// #define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, A5, A4); // U8G2 Constructor (A5 - Clock SCL ; A4 - Data SDA)
// 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.
// 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 = 10;
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;
void before(){
u8g2.begin();
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf);
u8g2.drawStr(38,15,"OLED");
u8g2.drawStr(15,35,"Temp+Hum");
u8g2.drawStr(46,60,"v1.2");
} while ( u8g2.nextPage() );
delay(3000);
u8g2.clear();
u8g2.firstPage();
do {
u8g2.drawStr(3, 32, "Connecting...");
} while ( u8g2.nextPage() );
}
void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("TEMPHUM_OLED", "1.2");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
void setup()
{
u8g2.clear();
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_haxrcorp4089_tr); // 7 PIXEL HIGHT
u8g2.drawStr(1,12,"WARNING: UPDATE_INTERVAL");
u8g2.drawStr(1,24,"is smaller than supported by");
u8g2.drawStr(1,36,"the sensor!");
} while ( u8g2.nextPage() );
delay(4000);
}
// 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()
{
while (transportCheckUplink() == false){
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf); // 14 px height
u8g2.drawStr(3, 32, "Disconnected!");
} while ( u8g2.nextPage() );
}
// 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++;
}
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_fub30_tn);
u8g2.setCursor(2, 35);
u8g2.print(temperature, 1);
u8g2.setFont(u8g2_font_inb16_mf);
u8g2.drawGlyph(88, 35, 0x00b0); // degree
u8g2.drawStr(100, 35, "C");
u8g2.setCursor(70, 60);
u8g2.print(humidity, 0);
u8g2.drawStr(100, 60, "%");
u8g2.setFont(u8g2_font_open_iconic_thing_2x_t); // 16 pix height
u8g2.drawGlyph(45, 60, 0x0048); // drop
} while ( u8g2.nextPage() );
// Sleep for a while to save energy
wait(UPDATE_INTERVAL); // POWERED NODE
}
Be advised that this code is almost near the memory capacity of the Nano 328P...
Did some testing today and i can now confirm that this issue with internal messages not getting delivered to the controller is now FIXED with commit 5d159a6 .
Thanks @tekka
Hi everyone,
I'm starting to setup an additional network for my nodes that are very far away from the gateway, using the RFM69HW 433 MHz variety. So ive built another serial gateway using an Uno and a RFM69 module (with the appropriate level converters on the NSS, MOSI and SCK lines) and DI00 pin at the D2 uno pin. The gateway log doesnt report any error and starts up ok.
I had a communication problem with a simple temp+hum node. The node started up ok but it failed to communicate with the gateway. I then forced a node ID to the sensor node and oddly it worked…
Other thing i noticed is that im not getting internal messages delivered to the gateway, only sensor values defined by MyMessage and which are presented.
The sketch info sent with "sendSketchInfo" doesnt show on Domoticz side, neither does battery levels sent with "sendBatteryLevel". If i just change the radio to a NRF24 with the same sketch code, everything works…
I wonder if this has anything to do with Ack collision discussed here ? It seems the fix suggested didnt get implemented yet…
Its odd that it seems that only some info gets transmitted with the RFM69 and all of them with the NRF24...
Thanks for any insights.
@m3nt4lll Try to assign a fixed node ID to your sensors nodes with the line:
#define MY_NODE_ID 12
Change the number to what you like.
I also had the same problem with a serial gateway with RFM69 and a simple temp+hum node. They did startup ok but no communication between them.
I then assigned a node ID to the sensor node and oddly it worked…
Other thing i noticed is that im not getting internal messages delivered to the gateway, only sensor values defined by MyMessage and presented.
The sketch info sent with sendSketchInfo doesnt show on Domoticz side, neither does battery levels sent with sendBatteryLevel. If i just change the radio to a NRF24 with the same sketch code, everything works…
@m3nt4lll If you get communication, see if you have this problem too.
I wonder if this has anything to do with Ack collision discussed here ? It seems the fix suggested by @Koresh didt get implemented yet…
Any ideias guys?
My latest "speedy" design: a small case for an Arduino Nano and a NRF24 module used as a Repeater.
Get it at Thingiverse
@tekka Here it is: REPEATER LOG
It seems to be working ok but there are still some NACKs on the log. Radio issues perhaps? Neverthless, im not getting the node dropouts i got with the 2.3.0 version...
@tekka i didnt save the log from the Repeater but if it helps i'm going to collect it. As for the Repeater sketch, its the default:
// Enable debug prints to serial monitor
//#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_NRF5_ESB
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#define MY_NODE_ID 51 // FIXED NODE ID
#define MY_PARENT_NODE_ID 0
#define MY_PARENT_NODE_IS_STATIC
#define MY_RF24_CHANNEL 1
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
// Enabled repeater feature for this node
#define MY_REPEATER_FEATURE
#include <MySensors.h>
void setup()
{
}
void presentation()
{
//Send the sensor node sketch version information to the gateway
sendSketchInfo("Repeater Node", "1.0");
}
void loop()
{
}```
@tekka Well, im running your beta code and like @itbeyond it seems to be working for 24h now. Uploaded the new compiles with the lib from the RF24Fix branch to all the nodes, gateway and repeater and it seems the drops stopped.
Built a couple of Relay nodes, one of which is connected to the repeater and they also seem to be working correctly.
Im linking the ZIP to the node log file with the RF24 verbose debug (its a tad big), if you want to take a look:
And this is my TEMP+HUM node sketch:
// Enable debug prints
//#define MY_DEBUG
//#define MY_DEBUG_VERBOSE_RF24
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
#define MY_RF24_CHANNEL 1 //////////////
#define MY_RF24_PA_LEVEL RF24_PA_HIGH
// ONLY IF USING FIXED ID REPEATER
//#define MY_PARENT_NODE_ID 0 // REPEATER NODE ID
//#define MY_PARENT_NODE_IS_STATIC // this will force your node to use only the repeater
// #define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#include <U8g2lib.h> //////////////////////
#include <Wire.h> /////////////////////////
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, A5, A4); // U8G2 Constructor (A5 - Clock SCL ; A4 - Data SDA)
#define DHT_DATA_PIN 3
#define SENSOR_TEMP_OFFSET 0
static const uint64_t UPDATE_INTERVAL = 60000;
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;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;
void before(){
u8g2.begin();
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf);
u8g2.drawStr(38,15,"OLED");
u8g2.drawStr(15,35,"Temp+Hum");
u8g2.drawStr(46,60,"v1.2");
} while ( u8g2.nextPage() );
delay(3000);
u8g2.clear();
u8g2.firstPage();
do {
u8g2.drawStr(3, 32, "Connecting...");
} while ( u8g2.nextPage() );
}
void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("TEMPHUM_OLED", "1.2");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
void setup()
{
u8g2.clear();
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_haxrcorp4089_tr); // 7 PIXEL HIGHT
u8g2.drawStr(1,12,"WARNING: UPDATE_INTERVAL");
u8g2.drawStr(1,24,"is smaller than supported by");
u8g2.drawStr(1,36,"the sensor!");
} while ( u8g2.nextPage() );
delay(4000);
}
sleep(dht.getMinimumSamplingPeriod());
}
void loop()
{
while (transportCheckUplink() == false){
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf); // 14 px height
u8g2.drawStr(3, 32, "Disconnected!");
} while ( u8g2.nextPage() );
}
dht.readSensor(true);
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++;
}
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_fub30_tn);
u8g2.setCursor(2, 35);
u8g2.print(temperature, 1);
u8g2.setFont(u8g2_font_inb16_mf);
u8g2.drawGlyph(88, 35, 0x00b0); // degree
u8g2.drawStr(100, 35, "C");
u8g2.setCursor(70, 60);
u8g2.print(humidity, 0);
u8g2.drawStr(100, 60, "%");
u8g2.setFont(u8g2_font_open_iconic_thing_2x_t); // 16 pix height
u8g2.drawGlyph(45, 60, 0x0048); // drop
} while ( u8g2.nextPage() );
// Sleep for a while to save energy
//sleep(UPDATE_INTERVAL);
delay(UPDATE_INTERVAL); // POWERED NODE
}
@itbeyond can you please post the initial code defines for your repeater and a node that connects to it? To see if I’m doing something wrong...
In the meantime I’m going to get the debug log and sketch code for my node.
@tekka the debug log (MY_DEBUG)/sketch from the node that gets disconnected or the repeater?
@tekka well, unfortunately i had the same problem. The far away node connected to the Repeater but after aprox 1h working ok, it stopped being updated at Domoticz with transportCheckUplink() false.
You changed a timing setting, right? With the normal version the node stopped being updated at about 15-16 min and now it changed to about 1 hour…
I have a node connected directly to the gateway with the nrf24L01+ PA+LNA working without problems, so it seems to be some kind of problem with the Repeater code and timings...
@itbeyond Nice! Will test it today and post my results.
@tekka using normal NRF24's on the nodes and a nrf24L01+ PA+LNA on the gateway.
@tekka ok, will test your version tomorrow and collect the node log. Do i need to upload your version to the node, repeater and gateway?
@itbeyond im running 2.3 on gateway, nodes and repeater… Im glad someone showed up with the same issue. The behaviour is similar: everything is ok and, in my case, it starts to "NACK" after around 16 min… Seems to be a software problem then and not the "popular" NRF24 reception issues. What radios are you using? NRF24's?
I know about the power requirements, but only the gateway is amplified. The repeater i was testing was a normal nano with a NRF24 powered by an original LG USB charger. Thats not the point with this issue.
What im saying is that seems the repeater stops to relay messages after about 16 minutes and with an almost direct line of sight to the gateway… If i remove the repeater, the node that is about 2 meters further apart from where the repeater was, still gets signal directly from the gateway and it works normally.
If i put the repeater in between, about 16 minutes later one of the values (temp or hum) doesnt get through to the gateway.
Ive tested different radios, nanos and power supplies but it seems to be a software issue or somekind of interference… I'll have to equate if i put up more gateways with NRF24's or completely ditch them. They seem not to worth all this hassle even if they are cheaper...
Ive been digging around the node logs and i got this after a while:
964875 !TSF:MSG:PONG RECV,INACTIVE
964878 TSF:PNG:SEND,TO=0
964882 TSF:MSG:SEND,3-3-51-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
964917 TSF:MSG:READ,0-51-3,s=255,c=3,t=25,pt=1,l=1,sg=0:2
964922 TSF:MSG:PONG RECV,HP=2
964925 TSF:CKU:OK
964969 !TSF:MSG:SEND,3-3-51-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=NACK:48.7
A bunch of NACK errors and "!TSF:MSG:PONG RECV,INACTIVE". I dont understand why this doesnt happen at the beginning and only after a while (about 16 minutes in this case) and i also dont know if the lack of radio acknowledge is from the repeater to the node or the repeater to the gateway…
Ive now moved the repeater more closer to the gateway but im still getting:
!TSF:MSG:SEND,3-3-51-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=NACK:26.1
Oddly, again after 16 minutes… Im at a loss...
@sundberg84 well, the repeater doesnt "hang" on the literal sense. Here is the initial log from it with the initialization and the acknowledge of one of the nodes:
16 MCO:BGN:INIT REPEATER,CP=RNNRA---,VER=2.3.0
26 TSM:INIT
27 TSF:WUR:MS=0
34 TSM:INIT:TSP OK
35 TSM:INIT:STATID=51
37 TSF:SID:OK,ID=51
39 TSM:FPAR
40 TSM:FPAR:STATP=0
43 TSM:ID
44 TSM:ID:OK
45 TSM:UPL
48 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
59 TSF:MSG:READ,0-0-51,s=255,c=3,t=25,pt=1,l=1,sg=0:1
64 TSF:MSG:PONG RECV,HP=1
66 TSM:UPL:OK
68 TSM:READY:ID=51,PAR=0,DIS=1
97 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
114 TSF:MSG:READ,0-0-51,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
147 TSF:MSG:SEND,51-51-0-0,s=255,c=0,t=18,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
155 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
175 TSF:MSG:READ,0-0-51,s=255,c=3,t=6,pt=0,l=1,sg=0:M
212 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=OK:Repeater Node
222 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
228 MCO:REG:REQ
232 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
242 TSF:MSG:READ,0-0-51,s=255,c=3,t=27,pt=1,l=1,sg=0:1
247 MCO:PIM:NODE REG=1
249 MCO:BGN:STP
251 MCO:BGN:INIT OK,TSP=1
22758 TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
22763 TSF:MSG:REL MSG
22765 TSF:MSG:REL PxNG,HP=1
22770 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:2
22781 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
22787 TSF:MSG:REL MSG
22789 TSF:MSG:REL PxNG,HP=1
22793 TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:2
22799 TSF:MSG:READ,2-2-0,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
22805 TSF:MSG:REL MSG
22817 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
22824 TSF:MSG:READ,0-0-2,s=255,c=3,t=25,pt=1,l=1,sg=0:1
22830 TSF:MSG:REL MSG
22832 TSF:MSG:REL PxNG,HP=1
22857 TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:2
22864 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
22870 TSF:MSG:REL MSG
22874 TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
22880 TSF:MSG:READ,0-0-2,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
22885 TSF:MSG:REL MSG
22889 TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
22896 TSF:MSG:READ,2-2-0,s=255,c=0,t=17,pt=0,l=5,sg=0:2.3.0
22901 TSF:MSG:REL MSG
22905 TSF:MSG:SEND,2-51-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.0
22913 TSF:MSG:READ,2-2-0,s=255,c=3,t=6,pt=1,l=1,sg=0:51
22918 TSF:MSG:REL MSG
22921 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:51
22936 TSF:MSG:READ,0-0-2,s=255,c=3,t=6,pt=0,l=1,sg=0:M
22941 TSF:MSG:REL MSG
22979 !TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=6,pt=0,l=1,sg=0,ft=0,st=NACK:M
22986 TSF:MSG:READ,2-2-0,s=255,c=3,t=11,pt=0,l=12,sg=0:TEMPHUM_OLED
22992 TSF:MSG:REL MSG
23035 !TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=NACK:TEMPHUM_OLED
23044 TSF:MSG:READ,2-2-0,s=255,c=3,t=12,pt=0,l=3,sg=0:1.2
23049 TSF:MSG:REL MSG
23053 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=1,st=OK:1.2
23059 TSF:MSG:READ,2-2-0,s=0,c=0,t=7,pt=0,l=0,sg=0:
23064 TSF:MSG:REL MSG
23067 TSF:MSG:SEND,2-51-0-0,s=0,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
23073 TSF:MSG:READ,2-2-0,s=1,c=0,t=6,pt=0,l=0,sg=0:
23078 TSF:MSG:REL MSG
23083 TSF:MSG:SEND,2-51-0-0,s=1,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK:
25023 TSF:MSG:READ,2-2-0,s=255,c=3,t=26,pt=1,l=1,sg=0:2
25028 TSF:MSG:REL MSG
25032 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
25039 TSF:MSG:READ,0-0-2,s=255,c=3,t=27,pt=1,l=1,sg=0:1
25044 TSF:MSG:REL MSG
25074 TSF:MSG:SEND,0-51-2-2,s=255,c=3,t=27,pt=1,l=1,sg=0,ft=0,st=OK:1
27297 TSF:MSG:READ,2-2-0,s=1,c=1,t=0,pt=7,l=5,sg=0:25.8
27302 TSF:MSG:REL MSG
27307 TSF:MSG:SEND,2-51-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:25.8
27314 TSF:MSG:READ,2-2-0,s=0,c=1,t=1,pt=7,l=5,sg=0:50.2
When the nodes give the "disconnected" signal, the log from the repeater gives this block over and over:
11917643 TSF:MSG:REL MSG
11917645 TSF:MSG:REL PxNG,HP=1
11917649 TSF:MSG:SEND,2-51-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:2
11919709 TSF:MSG:READ,2-2-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
I cant see anything on the log that the repeater lost connection to the gateway so i guess its not a radio problem. But answering your question, when i collected the log, the repeater (arduino nano) was connected/powered via a USB 3.0 port and the NRF was power by the 3v3 pin.
Im now collection the log from one of the nodes to see what it gives.
Thanks!
Well, that didn’t solve it... got both nodes disconnected as before. It seems the repeater hangs for some reason...
I’ve also noticed that the “last seen” time for the repeater that appears in Domoticz is the time it was powered up and presented to the gateway. It doesn’t get updated.
I guess the only way to debug this is to collect all the log from the repeater until the nodes get disconnected...
@sundberg84 hmmm, nope… I only have this line:
#define MY_NODE_ID 51
So you're saying you've solved your problem by also adding:
#define MY_PARENT_NODE_ID 0
At the repeater?
So, to try to solve the range issues of the NRF24 node networks deployed inside masonry-mortar buildings, i've setup a repeater on my first floor. I have a serial gateway with an amplified NRF24 at the groundfloor and a node that works normally.
At the first floor i have 2 nodes (temp+hum) where only one is able to connect to the gateway in this normal setup. Ive then installed a repeater with a fixed ID which gets connection to the gateway without problems.
Ive then forced the nodes at the first floor to connect to the repeater with:
#define MY_PARENT_NODE_ID 51
#define MY_PARENT_NODE_IS_STATIC
Everything works ok for an hour or so, and then i begin to notice in Domoticz that the time the nodes were "seen" starts to be 20, 30, 50 minutes without reporting the readings and i get the info on my nodes that transportCheckUplink() is false. If i restart the repeater, everything starts to work but the same issue happens again… Has anyone come across something similar? Ive checked the log of the repeater but since this issue takes a bit of time to show up, ill need to plug it to a laptop and collect the full log.
Im now trying to setup one of the temp+hum nodes also as a repeater, but since my nodes have a small OLED im trying to implement a delayed display update since ive removed the "sleep" function. I hope this doesnt spam the gateway…
As always, any insights are more than welcome.
Thank you.
Its a very nice one and i also like designs without screws. But since im not very confortable with my printer tolerances, im not thinking (at the moment) with that kind of parts inter-connections…
And i have a pack of those tiny screws…
@yveaux well, i thought about that. a ground problem. But since the Arduino is powered via USB (+5V), should i also connect the ground from the 3.3v power supply to a ground pin on the arduino? how about the ground pin of the NRF24?
Thanks
@Mathea90 Thanks for your input. As for the wifi, im not using my router wifi network, i disabled it. My home wifi is a mesh of Ubiquiti Unifi APs managed by me... Cant remember if the channels are on auto though…
You also did an outstanding work with power supplies and filtering… Congratulations.
This week i received my NRF24/PA/LNA so today i began testing range issues again. Well, i have a weird problem that i dont know if you guys already came across: since it is the amplified version, ive bought a dedicated power converter, something like this:
Ive tested it and its giving a constant voltage of 3.38v. I've connected it to the NRF24/PA/LNA (+ and ground) but the gateway (an Arduino UNO powered via USB) gave me an initialization error:
0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RNNGA---,VER=2.3.0
0;255;3;0;9;4 TSM:INIT
0;255;3;0;9;6 TSF:WUR:MS=0
0;255;3;0;9;14 !TSM:INIT:TSP FAIL
0;255;3;0;9;17 TSM:FAIL:CNT=1
0;255;3;0;9;19 TSM:FAIL:DIS
0;255;3;0;9;22 TSF:TDI:TSL
I've then connected the radio to the 3.3v and ground pins on the UNO and it works! What am i missing here?
For the time being the gateway is working ok but its being powered via USB (altough its a 3.0 port). Anyone tried this little modules before? It would suck if i discover i cant use it with the NRF24/PA/LNA...
As for the range, im now getting good connection to a node that needed a repeater in between without the NRF24/PA/LNA so, so far so good.
@pihome Sure! Its no trade secret.
Ive used the U8g2lib for the display which is connected at A4 and A5, as defined in the code.
You should power the display directly to a good power source (3.3 ~ 5.5V) since you are also powering a radio module.
Its basically the temp+hum sketch where Ive included some lines of code for the display. At boot it displays the message "Connecting…". If the gateway or repeater is offline or out of range, it wont do anything else unless MY_TRANSPORT_WAIT_READY_MS is of a different value than the default (not pretty sure but ive read that the default is to wait forever).
It will then display temp + hum with a small chain icon at the bottom (connected). If the gateway goes offline it displays "Disconnected!"
Im not sure if this is bug free, so feel free to debug and add new functionalities.
// Enable debug prints
//#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
//#define MY_RS485
#define MY_RF24_CHANNEL 1 //////////////
#define MY_RF24_PA_LEVEL RF24_PA_HIGH //////////////
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#include <U8g2lib.h> //////////////////////
#include <Wire.h> /////////////////////////
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, A5, A4); // U8G2 Constructor (PINS: A5 - Clock SCL ; A4 - Data SDA)
// 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.
// 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 = 10;
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
DHT dht;
void before(){
u8g2.begin();
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf);
u8g2.drawStr(38,15,"OLED");
u8g2.drawStr(15,35,"Temp+Hum");
u8g2.drawStr(46,60,"v1.2");
} while ( u8g2.nextPage() );
delay(3000);
u8g2.clear();
u8g2.firstPage();
do {
u8g2.drawStr(3, 32, "Connecting...");
} while ( u8g2.nextPage() );
}
void presentation()
{
// Send the sketch version information to the gateway
sendSketchInfo("TEMPHUM_OLED", "1.2");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = getControllerConfig().isMetric;
}
void setup()
{
u8g2.clear();
dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_haxrcorp4089_tr); // 7 PIXEL HIGHT
u8g2.drawStr(1,12,"WARNING: UPDATE_INTERVAL");
u8g2.drawStr(1,24,"is smaller than supported by");
u8g2.drawStr(1,36,"the sensor!");
} while ( u8g2.nextPage() );
delay(4000);
}
// 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()
{
while (transportCheckUplink() == false){
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_helvR14_tf); // 14 px height
u8g2.drawStr(3, 32, "Disconnected!");
} while ( u8g2.nextPage() );
}
// 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++;
}
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_fub30_tn);
u8g2.setCursor(2, 35);
u8g2.print(temperature, 1);
u8g2.setFont(u8g2_font_inb16_mf);
u8g2.drawGlyph(88, 35, 0x00b0); // degree
u8g2.drawStr(100, 35, "C");
u8g2.setCursor(70, 60);
u8g2.print(humidity, 0);
u8g2.drawStr(100, 60, "%");
u8g2.setFont(u8g2_font_open_iconic_thing_2x_t); // 16 pix height
u8g2.drawGlyph(45, 60, 0x0048); // drop
u8g2.setFont(u8g2_font_open_iconic_www_2x_t); // 16 pix height
u8g2.drawGlyph(2, 60, 0x004f); // CONNECTION ICON
} while ( u8g2.nextPage() );
// Sleep for a while to save energy
//sleep(UPDATE_INTERVAL);
delay(UPDATE_INTERVAL); // POWERED NODE
}
Today i made another couple of tests with a repeater to see if i can get signal from my first floor to the ground floor (where is the gateway) with promising results. Still waiting for my NRF24/PA/LNA to arrive still.
I was wondering if its ok to set the MY_RF24_PA_LEVEL to HIGH on all powered nodes (sensors, repeater and gateway), or the performance will be degraded?
Talking about the frequency ranges, i have a mesh of wifi Ubiquiti Unifi AP's in my house, which are able to do a RF scan and show me the channels that are more utilized. It seems the more crowded channels here are (20 MHz): 5 (2421-2443), 6 (2431-2453 MHz), and (40 MHz): 3 (2401-2443), 5 (2411-2453) and 9 (2431-2473).
With this in mind, im setting up my nodes on channel 2 (MY_RF24_CHANNEL 1 if im correct) where there is 0% utilization.
PS: i have an original Nokia charger rated at 5v on the label but actually gives out 7v dc... Had another one rated at 5.4v but i measured aroud 7.6. Are these chargers supposed to work with a pre-determined load?
Hi everyone,
Already posted this over at the troubleshooting section, so im posting here also for whoever is interested. My "compact" temperature + humidity node enclosure with a little window for a 0.96" OLED display.
Every part is in place using the printed spacers and the back is attached with 2 self drilling screwers.
https://www.thingiverse.com/thing:3019468
Hi everyone,
As promised, the box over at Thingiverse (smaller version):
https://www.thingiverse.com/thing:3019468
@sundberg84 said in Introductions and Range Issues:
I have around 25 nodes using Nrf24 radio. Once you have found your way and how to test them before deployment they work very good. Sure, its easier with the RFM69 but expensive and as @Yveaux said not 5v tolerant.
Yeah, they are really more expensive than the NRF24. But still cheaper than the cost of a repeater node (NRF24 + Nano) even without considering the power supply... Well, i guess that each case is different.
As for the 5v logic vs 3.3 thats also a problem with 5v Nanos. I think they need something like "this" ?
I'll still do tests with the NRF24/PA/LNA and with repeater nodes but i think i wont be so lucky with a weather station node (needs to be outside) that im planning to add to the system. Lets wait and see.
I'll also prepare the STL files to upload to Thingiverse of my box. Need to take some pictures of the assembly first.
Thanks for the input!
Thanks for all the input guys and the vote of confidence regarding the NRF24!
So, since there are a lot of people telling to go for the RFM69, I've ordered a couple of them to do some testing. Im still going to test the NRF24/PA/LNA but after all you guys said, im not feeling very confident…
If everything doesnt go according to pIan, i guess im going to have to try to fit the RFM69 inside my already printed boxes and have an antena protruding out of the box… not very pretty… Ah well. Nothing is perfect.
Anyway, I think there should be somekind of note on the radio page of the main website, stating this kind of problem regarding range and construction type.
Will keep in touch.
Hi everyone.
Thanks for all the info! I appreciate it, really.
Well, today i did additional testing and its a range problem since 2 nodes have the same behaviour on the same location. If i move them closer to the gateway, they get connected.
Since i already have a bunch of NRF24 modules (and integrated them on my little boxes), ill try to make this work with them. If i knew that using RFM69 would be better across physical barriers, i would go for them… In reality we are trying to build the network inside a house... Anyway, thanks for the tip @kimot . Will change to them if i dont get the NRF24 network to work properly.
So, i already orderer a NRF24/PA/LNA for my gateway and an independent switching power supply. Hope that boosts the gateway.
Today i programmed a Nano to be a repeater but it seems i cant find a guide to set this properly since the node further away doesnt get connected. The gateway sees the repeater though… Do i need to change anything on the original example repeater code? As setting up NODE_ID and CHILD_ID? Ive read somewhere here in the forum thats just uploading the example code to an arduino and thats it… Will try to get the debug output of the repeater (need to connect it to a laptop).
Other thing, what type of 5v power supplies do you guys recommend? And 3.3v step down modules?
I will also upload my boxes stl to Thingiverse if your interested. Ive made a more compact model...
Thanks again.
Hi everyone,
I've discovered the My Sensors project a couple of months ago and decided to get to work and start to automate my house. It's a very nice colaborative project so i hope to also help. I have reasonable knowledge of electronics, electricity and Arduino programming, so finding MySensors was a great find.
So, i got to work and started building temperature + humidity nodes based on Arduino Nano and NRF24 radio modules. Did a trial run with one node and a LAN Uno Gateway and it worked.
Since i have a 3D printer i designed these little boxes for the nodes and added to them a little 0.96" OLED display, so you can see the values when you enter the room where the node is located:
Everything is in place without fasteners (except for the back plate) and the radio module is at the top of the box, on an horizontal position. At the back i added a custom power connector based on jumper pins, where you can connect the power to a secondary module (i hope i can add to it a module to control my air conditioning).
I then installed Domoticz on an Intel NUC running W10 and attached to it a serial gateway via USB (running on an Uno). I started to place my nodes but alas, im running into the usual range problems…
I've read a lot here on the forum and throughout the internet, made the dipole antenna modification on the radio module attached to the gateway, changed the radio channel (found out that around 2401 MHz i had an unused spectrum) but my range is about 6-8 meters. Im even having difficulty receiving the signal from a node on the upper flor, placed almost on top of the gateway. I live in Europe where there is a more "dense" type of construction so i guess thats a problem too and i'm even trying to hide the gateway inside a cabinet…
I know the NRF24 module is allegedly sensible to the power supply so im including the capacitor between Vcc and ground but im using the 3.3v pin from the Arduino Nano (5v version) to power the radio… And trying to re-use old Nokia phone chargers (yeah, not regulated but they seem to work).
I would like your experienced advice guys, regarding the nodes and gateway placement (antenna placed outside cabinets and orientation), should i build repeater nodes, recommended 5v power supplies (and 3.3v regulators) that you think should be used, should the radio be connected to its own power supply (or through a regulator) and not the 3.3v Nano pin and what kind of range you get indoors because for a 60 m range radio module, 1/10th of this with just 1 wall in between is just disappointing…
Thanks a lot for your attention!