ESP8266 WiFi gateway port for MySensors
-
Playing with AES signing and encryption I enabled verbose debug.
#define MY_DEBUG_VERBOSE
The sketch crashes with this setting but seems to work fine without verbose debug.
Is this a problem of my setup or a problem in the code?
The log pf the serial terminal:
write_register(0x04,0x5F) write_register(0x06,0x27) write_register(0x06,0x07) write_register(0x00,0x0C) write_register(0x07,0x70) write_register(0x05,0x4C) write_register(0x00,0x0E) write_register(0x00,0x0E) STATUS 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 0x0E0E0E0E0E 0303030303 RX_ADDR_P2-5 0xC3 C4 C5 C6 TX_ADDR 0x0E0E0E0E0E RX_PW_P0-6 0x00 00 00 00 00 00 EN_AA 0x3F EN_RXADDR 0x03 RF_CH 0x4C RF_SETUP 0x07 CONFIG 0x0E DYNPD/FEATURE 0x00 00 Data Rate 1MBPS Model nRF24L01+ CRC Length 16 bits PA Power PA_MAX write_register(0x01,0x3F) write_register(0x01,0x3B) write_register(0x1D,0x06) FEATURE=0x06 write_register(0x1C,0x03) write_regis
-
@FotoFieber said:
Is this a problem of my setup or a problem in the code?
I'll opt for the first, but lets see:
- What ESP hardware are you using?
- Which Arduino/ESP8266 port/MySensors version are you using?
- Did you define both DEBUG and MY_DEBUG_VERBOSE?
- What did you do to 'Play with AES signing and encryption' ?
- AES stuff is untested for ESP8266, however, you don't seen to get that far as it crashes during startup.
- My startup log (see here ) shows what it shoes during startup with DEBUG and MY_DEBUG_VERBOSE enabled.
-
- ESP12E
- Development Version
- Defined both DEBUG AND VERBOSE
- Playing with AES:
#define MY_RF24_CHANNEL 13 #define MY_RF24_BASE_RADIO_ID ((uint64_t)0xF8A813FC09CL) #define MY_RF24_ENABLE_ENCRYPTION #define MY_RF24_ENCRYPTKEY secret.... #define MY_SIGNING_SOFT // Software signing enabled #define MY_SIGNING_SOFT_SERIAL secret.... // Key to use for HMAC calculation in soft signing (32 bytes) #define MY_SIGNING_SOFT_HMAC_KEY secret
It seems to work perfect without the verbose debug.
I will test now without AES. My gut tells me, I should look inside the AES stuff.
-
@Yveaux said:
@joshmosh You cannot have multiple gateways in a single MySensors network. The node-ID of the gateway is always hardcoded to 0.
If you want to run multiple networks, each should have a unique RF24_CHANNEL & RF24_BASE_RADIO_ID combination. For best results make sure to have a separate RF24_CHANNEL for each network, and don't use directly adjacent channels.@Yveaux
Thank you for this piece of information - I was not aware of this fact.
My idea was to reduce cost and parts count for sensors by using ESPs instead of nRF plus Arduino. Since I have Domoticz as controller, there is pehaps no need for an additional gateway, because Domoticz can handle TCP-attached sensors. Of course this would require to use WiFi instead of nRF24 as underlying transport for MySensors. My interpretation of some of hek's contributions is that he is working on it for realisation in version 1.6.
-
@Yveaux
Downloaded the development branch again and used the sketch included as example. The sketch is hanging too. My gut was wrong, AES is not the problem.
-
Hi.
I am having an issue with my ESP8266 gateway. I have tried all versions of mysensors including developmental versions, but my esp8266 does not show any serial debug, nor it gets connected to my router. I also enabled debug in configuration file. When I install AT firmware, it replies to AT command, it also works with nodemcu firmware, but it does not respond with Arduino firmware. May someone help me?
-
Finally I got my NodeMCU and tried the WiFi gateway too. But I get the following messages (with Serial.setDebugOutput(true);):
ESP8266 MySensors Gateway Connecting to WLAN scandone f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ..................rm 0 pm close 7 0 0/9299504 ..reconnect f -240, ....scandone no WLAN found, reconnect after 1s .reconnect f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ................rm 0 pm close 7 0 0/8288631 ..reconnect f -240, ....scandone no WLAN found, reconnect after 1s .reconnect f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ................rm 0 pm close 7 0 0/8124923 ..reconnect
Additionally I tried to use
IPAddress ip(192, 168, 38, 18); /* Set to whatever IP address you'd like the gateway to have */ WiFi.config(ip);
to avoid DHCP, but that gives error during compiling:
no matching function for call to 'ESP8266WiFiClass::config(IPAddress&)'
Any hints how to solve?
Thanks
Edit:
to find the problem I tested to connect the ESP to the wifi-hotspot of my smartphone... worked. Is it maybe a problem if the password contain special characters which behave strange during compiling?
-
@Anduril said:
no WLAN found, reconnect after 1s
That's a clear indication the ESP cannot connect to your WiFi accesspoint.
Is the SSID matching your accesspoint ('WLAN')?
Is the encryption supported by the ESP (see e.g. https://nurdspace.nl/ESP8266#Features -- not sure if it is accurate)
Weird characters in the password could be problematic (and of course the password is case-sensitive).Changing between DHCP/Fixed IP won't make a difference here, as the ESP doesn't even connect. IP configuration starts once connected.
-
@Yveaux
SSID is 'WLAN' (all capital). Encryption is WPA2 which should be supported. The password contains '|' (don't know the name, vertical line) and 'ß' (german character). I use them among other more common ones to raise the complexity of the encryption. As I am using a bunch of wifi devices I don't want to go around and change passwords for all if not absolutely necessary. Is there a way to specify these 'weird characters' e.g. by ASCII codes or anything else?Changing the IP was not to solve this problem but for future use, as my DHCP is not very good. Can you tell me how to fix IP else?
-
@Anduril try to print your password to the serial console and see if it matches the password you entered in the sketch.
-
good idea @Yveaux, seems that 'ß' is the problem. serial.print shows ß at that position. Do you know how to avoid that?
-
@Anduril probably Unicode problem of the editor. I assume you use the Arduino editor? Try a simple editor like notepad to type the problematic character, or directly type it in windows by setting your keyboard in numpad mode and type it's ascii code: alt+225
-
@Yveaux tried with a nano to print out "ß" to serial, no problems. After that I tried that sketch on ESP:
void setup() { Serial.begin(115200); const char *pass = "ß1ß"; Serial.println(" "); //to break line after rubbish at init Serial.println(pass); }
[not readable/copyable stuff] ß1ß
So in general it should be no problem compiling the char 'ß' even on ESP.. Also in the ESPGateway sketch I don't see anything that is changing the *pass, but maybe you know what is going on with this string in more detail.
edit: it seems to happen even before void setup in the gw sketch. I uncommented everything in setup, loop and output, but still get the distorted serial print of pass.
-
@Anduril I guess it shouldn't make a difference. What happens if you copy/paste the "ß1ß" string from your test sketch into the ESP gateway sketch as password and print that to serial? (make sure to use the same editor on both sketches)
-
@Yveaux already tried that. When using my own sketch I get "ß1ß", when using the gw sketch (with really everything commented out, so no functionality) I get "ß1ß". I thought that it might be a problem of UFT encoding, had this issue with transfering LaTeX files created on linux system to windows system and vice versa: the system that creates the file sets the charset.
But I also created a completely new .ino with the gateway-code inside and new created gatewayutil.h with data copied in notepad++, but no succes.
And yes I use Arduino IDE as editor. Is there a good way to use another editor and compile/upload without the IDE?
-
@Anduril I'm still convinced it has something to do with Unicode, but very hard to nail from a distance without the actual files...
Maybe @hek has seen this before?
-
Nope, not the slightest idea.
@Anduril
Couldn't you just temporarily change password on router to rule out other stuff?
-
@hek yeah already did this, when leaving out ß it works perfect. So no problem with router or ESP hardware. But changing the wifi password would be the worst case, as I have to reassign that to squeezeboxes, smartphones, laptops, wifi printer,... (and all guest devices of friends/familie) but still possible if all other things fail.
@Yveaux Would it help if I send you the files for verification? Is it possible inside this forum or only via email?
-
@Yveaux thank you very much for offering help with verification, but something strange happened during preperation of files: I took an example sketch and modified it to print the "ß1ß" on serial --> working fine.
But after saving the file I tried again, only reading rubbish. Thats strange! So it has something to do with saving the file and maybe setting a special encoding. Maybe thats related to the editor? Could you please try to redo what I explained and see if you get the same results? Thank you. @hek have you ever had such a problem of a sketch behaving differently after saving?
-
@Anduril Ok, did some tests:
Copied your problematic example string from this topic into Arduino IDE (1.6.5), on Windows 10:
Saved the sketch.
Viewed sketch.ino in notepad:
Newlines are f*cked up, but "ß1ß" can clearly be recognized.Viewed the same sketch in HxD hex viewer:
And there we are! The string is stored as Unicode characters!
Reading it back in Arduino IDE:
Everything looks fine again.
Apparently the unicode string gets compiled directly and shows as multiple, wrong characters in your sketch when used/printed...
Ok, one more idea: you can try to store the ß character as an escaped ASCII character in you string (refer to this ).
This will look strange in the code, but should print correctly to the console:The ASCII escape sequence for ß is \xE1 Your test sequence "ß1ß" then becomes "\xE11\xE1"
Please try this...
-
@Yveaux
hi
there is problem for sensor library when we intend use the its examples as following
In file included from \libraries\MySensors\MyGateway.cpp:13:0:\libraries\MySensors\utility/MsTimer2.h:7:2: error: #error MsTimer2 library only works on AVR architecture
#error MsTimer2 library only works on AVR architecture
^
In file included from \libraries\MySensors\MyGateway.cpp:14:0:
\libraries\MySensors\utility/PinChangeInt.h:103:19: fatal error: new.h: No such file or directory
#include <new.h>
^
compilation terminated.
Error compiling.
-
@mkeyno did you change anything to the gateway code, and which version of MySensors are you running?
I've ported the gateway code to ESP8266. That doesn't mean any sensor code will also automatically run on an ESP.
Packaged with MySensors are a lot of libraries that will not compile on ESP, so if you try to use one (pinchange int or timers) it will likely fail to compile.
-
@Yveaux SUCCES!!! Thank you very much, your way worked nearly perfect. ONly small change: "ß" is represented by hexcode DF, so using \eDF gives the correct wifi password for me.
Now a last thing as bonus: how to setup a fixed ip and not using dhcp? My dhcp is not very usable as it reassigns all IPs on reboot (stupid firmware by Deutsche Telekom).
-
@Anduril Great to hear you got it to work!
how to setup a fixed ip and not using dhcp?
Google'd a bit. Seems like Wifi.config requires 3 parameters:
// static ip, gateway, netmask WiFi.config(IPAddress(192,168,1,100), IPAddress(192,168,1,1), IPAddress(255,255,255,0));
Make sure to call it after WiFi.begin().
Btw. ESP8266 Arduino port follows the Arduino WiFi library API.
-
You can set static ip in the dev-branch.
-
-
@Yveaux no buddy I used the last update of your repository, my question is , are you aware that your esp8266 sample sketch call library that wont work with esp architecture? I've compare last update with previous library and I've find the for couple of header file following code has been added
#ifdef AVR
#include <avr/interrupt.h>
#else
#error MsTimer2 library only works on AVR architecture
#endifand I was wondering why your sample sketch call such file into the compiling
-
Hi @Yveaux
could you please assist in the error.
ESP8266 MySensors Gateway Connecting to HoUsEoFcLoWnS scandone f 0, scandone .add 0 aid 5 pm open phy_2,type:2 0 0 cnt connected with HoUsEoFcLoWnS, channel 11 dhcp client start... .ip:192.168.0.23,mask:255.255.255.0,gw:192.168.0.1 .Connected! IP: 192.168.0.23 ets Jan 8 2013,rst cause:4, boot mode:(3,7) wdt reset load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld
The gateway just keeps looping and connecting.
I'm using a NodeMCU with a NRF ( both from ebay),
Using the Regular library, and default sketch with SSID/pass updated.i tried checking the error "rst cause:4, boot mode:(3,7)" but wasn't able to find something.
I even tried to power it using a USB cellphone charger, but i was unable to telnet so that rules out the power issue
Thanks in advance
-
update,
the error changed to "rst cause:4, boot mode:(3,6)" once i added a capacitor.
-
@D_dude said:
These ESP's seem to walk in mysterious ways...
A lot of people have them, running without any issues (including myself and hek) and some people can't seem to get them to run stable.
On the net, a lot of stability/reset issues are are claimed to have a relation to power supply.I even tried to power it using a USB cellphone charger, but i was unable to telnet so that rules out the power issue
There are a lot of assumptions in this sentence
What current rating is the cellphone charger? I'd advise one with at least 1amps, and a stable output.
Not being able to telnet to the gateway can have more issues then just the ESP crashing...
-
@Yveaux
Thank you for the response.As for the cell phone charger, I'm using a tablet charger Specifically original HP stream 7 charger, and it is able to provide more that 1amp. I Will try to use other charger/power supply to see if that helps.
PS: I reloaded the gateway sketch and the error went back to boot mode (3,7) even with cap present.
-
@D_dude I searched the net for a description of reset causes and boot modes but failed to find one.
I have no clue of what they mean.
-
@Yveaux
thank you for your assistance. I will try adding some debug in the code on the weekend to see what exactly is not running and possibly causing crash.
-
I got a suggestion here to erase the flash before flashing. Haven't tried it yet, but it might help you @D_dude
-
@mfalkvidd
Thank you, i will try this and post results.
-
@mfalkvidd
tried erasing the flash using the method suggested but doesn't seem to be working for me. same result.
Thanks for the tip though.
-
Too bad. Thanks for posting your results.
-
here is my ESP8266 wifi gateway installed in wifi repeater box, taking the advantage that its has a 5 volts power supply.
-
@luisgcu Nice housing!
Thanks for the pics!
-
I'd been using the ESP gateway for several weeks, but recently was having trouble adding a new sensor I am developing.
Since the copy of dev I built it with was now out of date, I went ahead and updated... still wasn't working right so while I had the serial link to it I checked and noticed it was crashing and cycling. It would work for hours, until I fired up my new node, then crash about immediately. A few dozen debug(PSTR())'s later, I found a cause.
In core/MySensorsCore.cpp the result of _msg.getConfig() is dereferenced in a comparison, and it's possible it could return NULL ( like when it's a new node ). I put a check around that and it's not crashing anymore. Which is more than what I can say for my new sensor node....
I have not tested this change with an AVR.
I submitted PR 264.
-
Great work @soward !
-
on some basic debugging, seems like my sketch is crashing in setupGateway.
infact even adding a print statement, it only prints first 3 chars.
My question is setupGateway takes output as an arg, which in turn is a function, should there be some parameters for this function?
also "Serial.print(serialBuffer);" does not print anything i added prints above and before and they don't show up either.va_end (args); Serial.print("A1"); Serial.print(serialBuffer); Serial.print("A2");
any suggestions?
-
@D_dude flush the serial output after each print.
The ESP will output the serial data in the background while your programm continues and then it crashes.
-
Hi,
I'm getting all the time this:ESP8266 MySensors Gateway
Connecting to layla
......Connected!
IP: 192.168.0.102
0;0;3;0;9;gateway started, id=0, parent=0, distance=0Then it got stuck so I do reset and getting this in loop:
ESP8266 MySensors Gateway
Connecting to layla
..Connected!
IP: 192.168.0.102
0;0;3;0;9;radio init failSoft WDT reset
ctx: cont
sp: 3ffefe70 end: 3fff00a0 offset: 01b0stack>>>
3fff0020: 00000000 00000000 3ffeed74 40203665
3fff0030: 0000007f 3ffef074 40205ba0 3ffef080
3fff0040: 40202114 00000001 00000000 40205c10
3fff0050: 6600a8c0 00ffffff 0100a8c0 3ffef074
3fff0060: 3ffe84ac 3ffeee8c 3ffeefb0 4020256b
3fff0070: 3ffe86b8 6600a8c0 00000000 00000000
3fff0080: 3fffdc20 00000000 3ffef06d 40205bde
3fff0090: 00000000 00000000 3ffef080 40100114
<<<stack<<<ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
-
@Yht 0;0;3;0;9;radio init fail
Means there's something wrong with your nRF communication. The WDT reset following this is normal.
-
i have been using wifi gateway with Domoticz controller without any problems until recentely. After the last update to beta version of the controller, the gateway crashes when the controller request gateway version:
Gateway startup complete.
Client 0: 0;0;3;0;2;Exception (28):
epc1=0x4000bf80 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000ctx: cont
sp: 3ffebf60 end: 3ffec1f0 offset: 01a0I have tested with telnet client with the same request and it was ok. Then I saw that the request from controller was terminated with only <LF> and not with <CR><LF> and this is why it crashed. I have added the following to the sketch:
-
if (inChar == '\n') { if (inputString[i].string[inputString[i].idx-1] != '\r') { // if the last char is not CR then add it inputString[i].string[inputString[i].idx++]='\r'; } // a command was issued by the client // we will now try to send it to the actuator
and now it seems to work.
Is this the right way to go?
Thanks
-
-
Are you talking abut this line of code?
https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyGatewayTransportEthernet.cpp#L194
-
@hek My code is from GatewayESP8266.ino example in Mysensors 1.5, line 234.
-
Ok! Mis-read this line---
After the last update to beta version....
Thought you were talking about the development branch. Sorry.
-
Hi all,
First, I have to say this is awsome what @Yveaux did, thank you!Sorry if this question takes you back in time. I don't know what channel and id to use for the nodes,I tried channel 97 and id from 1-5 but it is not working..
are you using mesh lib?
-
@Yht said:
I don't know what channel and id to use for the nodes
Just leave the default channel untouched for both sensors and gateway. It should be fine.
The gateway will automatically be assigned ID 0, the nodes can have any fixed ID.
Dynamic ID assignment requires some extra software, as the gateway does not support it.
-
I'm also seeing my ESP8266 gateway crash when the controller requests its version.
I had not seen this thread so I started a new topic here: http://forum.mysensors.org/topic/2493/esp8266-wifi-gateway-crashes-and-reboots-when-controller-connects
-
hi,
maybe you have already seen it...but you can get cheap and smaller nodemcu. crazy price! I have ordered some, and waiting for them...
http://fr.aliexpress.com/item/D1-mini-Mini-NodeMcu-4M-bytes-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/32529101036.html?spm=2114.06010108.3.1.04LsjX&ws_ab_test=searchweb201556_2_79_78_77_80,searchweb201644_0,searchweb201560_9
-
@scalz Nice! Thanks for the link!
-
Just wanted to chime in and say thank you for this gateway script @Yveaux
I originally had an ethernet gateway for the longest time. But when I changed over to an OnHub router, it stopped working because it doesn't like to handle static IP, and the current branch sketch is too large to enable DHCP. This worked wonderfully with the OnHub out of the box (ver 7390.62.2) and shows up with a hostname of ESP_DA7D8B.
Thanks again!
-
Hi,
When testing the ESP8266MQTTClient (downloaded latest version of the library today) and compiled with the NodeMCU 1.0 ...... option I get an odd result. The message at startup is (please disregard the "Radio init fail" - the radio was not yet connected. I just wanted to check the WiFi2dO,4`lLMØl 8ðÿ0;0;3;0;9;Starting gateway (RNNGE-, 1.6.0-beta)
0;0;3;0;9;Radio init failed. Check wiring.
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
pm open phy_2,type:2 0 0
cntconnected with XXXyyy, channel 1
dhcp client start...
ip:192.168.1.167,mask:255.255.255.0,gw:192.168.1.1I can see from the router that the connection to 192.168.1.167 is successful but the oddity is that I have set the gateway to use a static address and also connect to a SSID which is not XXXyyy. The defines are:
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 192,168,1,22
// If using static ip you need to define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 192,168,1,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0So the ESP8266 uses dhcp when it should have a static address and connects to a SSID which is not given but may have been previously used at earlier tests.
I have looked at the code and tried a few changes to defines but none resulted in the override of dhcp.
Anyone have a clue?
-
I have the exact hardware in this setup but can't even get to the point where the hardware is a problem! I'm having compile errors during verify that make no sense and that I can't seem to find in the forums using search:
In file included from Esp8266Gateway.ino:69:0:
C:\Users\xxxxx\Documents\Arduino\libraries\SPI/SPI.h:982:8: error: 'SPIClass' does not name a type
extern SPIClass SPI;Any suggestions? I'm running windows 10 and Arduino 1.6.5 with the most current esp8266 board files through board manager.
Apparently me and anything arduino related are like oil and water, yet I keep buying the stuff.
-
@bp_968 said:
I have the exact hardware in this setup but can't even get to the point where the hardware is a problem! I'm having compile errors during verify that make no sense and that I can't seem to find in the forums using search:
In file included from Esp8266Gateway.ino:69:0:
C:\Users\xxxxx\Documents\Arduino\libraries\SPI/SPI.h:982:8: error: 'SPIClass' does not name a type
extern SPIClass SPI;Any suggestions? I'm running windows 10 and Arduino 1.6.5 with the most current esp8266 board files through board manager.
Apparently me and anything arduino related are like oil and water, yet I keep buying the stuff.
I tried this on my laptop and it worked fine (the compile verify did anyway) so I'll be reinstalling the IDE and trying again and hopefully that resolves my issues!
-
Yesterday I have successfully installed the ESP8266 module and it works fine, but the Vera3 show something strange now.
Has anyone experienced this?
-
@tjay4x4 Seems like to be an issue again when going from 8-bit to 32-bit architecture.
Can you connect the ESP to your PC and capture the serial output when connecting to your lights and controlling them?
-
@Yveaux Thank you for reply. Here is the serial monitor.When I put 100% light it shows Ok. But 70% and others, shows some digitals. But all working fine!
Insert Code Here.................Connected! 0;0;3;0;9;gateway started, id=0, parent=0, distance=0 0;0;3;0;9;read: 1-8-0 s=0,c=1,t=0,pt=7,l=5,sg=0:33.1 1;0;1;0;0;33.1 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.2 1;1;1;0;0;44.2 0;0;3;0;9;read: 1-8-0 s=2,c=1,t=0,pt=7,l=5,sg=0:32.2 1;2;1;0;0;32.2 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.3 1;1;1;0;0;44.3 Client 0 connected 0;0;3;0;14;Gateway startup complete. Client 0 disconnected 0;0;3;0;9;read: 9-8-0 s=4,c=1,t=0,pt=7,l=5,sg=0:27.0 9;4;1;0;0;27.0 0;0;3;0;9;read: 9-8-0 s=3,c=1,t=1,pt=7,l=5,sg=0:21.0 9;3;1;0;1;21.0 Client 0 connected 0;0;3;0;14;Gateway startup complete. Client 0: 0;0;3;0;2;Get Version 0;0;3;0;2;1.5.1 Client 0: 11;0;1;1;3;1090519100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=10,sg=0,st=ok:1090519100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=10,sg=0:1090519100 11;0;1;1;3;1090519100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:805306369 11;0;1;0;2;805306369 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:805306428 11;0;1;0;3;805306428 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:805306368 11;0;1;0;2;805306368 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:805306368 11;0;1;0;3;805306368 Client 0: 11;0;1;1;3;100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=3,sg=0,st=ok:100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=3,sg=0:100 11;0;1;1;3;100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:100 11;0;1;0;3;100 Client 0: 11;0;1;1;3;80 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:80 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:80 11;0;1;1;3;80 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:80 11;0;1;0;3;80 0;0;3;0;9;read: 1-8-0 s=2,c=1,t=0,pt=7,l=5,sg=0:32.3 1;2;1;0;0;32.3 Client 0: 11;0;1;1;3;70 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:70 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:70 11;0;1;1;3;70 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1107296257 11;0;1;0;2;1107296257 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:1107296326 11;0;1;0;3;1107296326 Client 0: 11;0;1;1;3;1107296326 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=10,sg=0,st=ok:1107296326 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=10,sg=0:1107296326 11;0;1;1;3;1107296326 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:922746881 11;0;1;0;2;922746881 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:922746950 11;0;1;0;3;922746950 0;0;3;0;9;read: 9-8-0 s=3,c=1,t=1,pt=7,l=5,sg=0:20.0 9;3;1;0;1;20.0 Client 0: 11;0;1;1;3;922746950 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=9,sg=0,st=ok:922746950 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=9,sg=0:922746950 11;0;1;1;3;922746950 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:922746881 11;0;1;0;2;922746881 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:922746950 11;0;1;0;3;922746950 Client 0: 11;0;1;1;3;922746950 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=9,sg=0,st=ok:922746950 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:922746880 11;0;1;0;2;922746880 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:922746880 11;0;1;0;3;922746880 Client 0: 11;0;1;1;3;100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=3,sg=0,st=ok:100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=3,sg=0:100 11;0;1;1;3;100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:100 11;0;1;0;3;100
-
@tjay4x4 which version of MySensors are you running?
-
@Yveaux I use https://github.com/mysensors/Arduino/archive/master.zip
Just reupload library
Some additionl information.
100%-90%-80%70%-60%-50%- OK 40%-bug
10%-20%-30%-40% -OK 50%-bugESP8266 MySensors Gateway Connecting to 1111 ................Connected! IP: 192.168.1.44 0;0;3;0;9;gateway started, id=0, parent=0, distance=0 0;0;3;0;9;read: 9-8-0 s=3,c=1,t=1,pt=7,l=5,sg=0:20.0 9;3;1;0;1;20.0 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.5 1;1;1;0;0;44.5 Client 0 connected 0;0;3;0;14;Gateway startup complete. Client 0: 0;0;3;0;2;Get Version 0;0;3;0;2;1.5.1 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:536870912 11;0;1;0;2;536870912 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:536870912 11;0;1;0;3;536870912 Client 0: 11;0;1;1;3;100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=3,sg=0,st=ok:100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=3,sg=0:100 11;0;1;1;3;100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:100 11;0;1;0;3;100 Client 0: 11;0;1;1;3;80 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:80 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:80 11;0;1;1;3;80 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:80 11;0;1;0;3;80 Client 0: 11;0;1;1;3;70 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:70 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:70 11;0;1;1;3;70 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:70 11;0;1;0;3;70 Client 0: 11;0;1;1;3;60 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:60 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:60 11;0;1;1;3;60 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:60 11;0;1;0;3;60 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.6 1;1;1;0;0;44.6 Client 0: 11;0;1;1;3;50 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:50 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:50 11;0;1;1;3;50 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1107296257 11;0;1;0;2;1107296257 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:1107296306 11;0;1;0;3;1107296306 0;0;3;0;9;read: 7-5-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.7 7;0;1;0;0;30.7 0;0;3;0;9;read: 3-2-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.2 3;0;1;0;0;30.2 0;0;3;0;9;read: 7-5-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.6 7;0;1;0;0;30.6 0;0;3;0;9;read: 3-2-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.1 3;0;1;0;0;30.1 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.5 1;1;1;0;0;44.5 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1107296256 11;0;1;0;2;1107296256 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:1107296256 11;0;1;0;3;1107296256 Client 0: 11;0;1;1;3;100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=3,sg=0,st=ok:100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=3,sg=0:100 11;0;1;1;3;100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:100 11;0;1;0;3;100 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:0 11;0;1;0;2;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:0 11;0;1;0;3;0 Client 0: 11;0;1;1;3;10 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:10 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:10 11;0;1;1;3;10 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:10 11;0;1;0;3;10 Client 0: 11;0;1;1;3;20 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:20 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:20 11;0;1;1;3;20 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:20 11;0;1;0;3;20 Client 0: 11;0;1;1;3;30 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:30 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:30 11;0;1;1;3;30 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:30 11;0;1;0;3;30 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.6 1;1;1;0;0;44.6 Client 0: 11;0;1;1;3;40 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=2,sg=0,st=ok:40 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=2,sg=0:40 11;0;1;1;3;40 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1107296257 11;0;1;0;2;1107296257 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:1107296296 11;0;1;0;3;1107296296 Client 0: 11;0;1;1;3;100 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=3,sg=0,st=ok:100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=3,sg=0:100 11;0;1;1;3;100 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:1 11;0;1;0;2;1 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:100 11;0;1;0;3;100 Client 0: 11;0;1;1;3;0 0;0;3;0;9;send: 0-0-11-11 s=0,c=1,t=3,pt=0,l=1,sg=0,st=ok:0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=0,l=1,sg=0:0 11;0;1;1;3;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=2,pt=2,l=2,sg=0:0 11;0;1;0;2;0 0;0;3;0;9;read: 11-11-0 s=0,c=1,t=3,pt=2,l=2,sg=0:0 11;0;1;0;3;0 0;0;3;0;9;read: 7-5-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.7 7;0;1;0;0;30.7 0;0;3;0;9;read: 1-8-0 s=1,c=1,t=0,pt=7,l=5,sg=0:44.5 1;1;1;0;0;44.5 0;0;3;0;9;read: 9-8-0 s=3,c=1,t=1,pt=7,l=5,sg=0:21.0 9;3;1;0;1;21.0 0;0;3;0;9;read: 3-2-0 s=0,c=1,t=0,pt=7,l=5,sg=0:30.2 3;0;1;0;0;30.2 0;0;3;0;9;read: 1-8-0 s=0,c=1,t=0,pt=7,l=5,sg=0:33.4 1;0;1;0;0;33.4 0;0;3;0;9;read: 9-8-0 s=3,c=1,t=1,pt=7,l=5,sg=0:20.0 9;3;1;0;1;20.0
-
@Yveaux Now everything working! I reinstall all "Arduino-master" to Arduino 1.6 folder and now ALL Ok. Sorry for disturb. Thank you!!!
-
@tjay4x4 try development version of MySensors. This thread discussions a similar issue:
http://forum.mysensors.org/topic/2118/esp8266-wifi-gateway-issue/2
-
@tjay4x4 Just crossed my reply! Great it's working now!
-
Yesterday I switched gateway hardware from serial gateway based on arduino pro mini 3.3V and nrf24l01+ (connected directly to uart port of my mikrotik router) to esp8266 nodemcu and nrf24l01+ (exactly as at this page: http://www.mysensors.org/build/esp8266_gateway, using GatewayESP8266 sketch from 1.6 branch, revision https://github.com/mysensors/Arduino/tree/1035f84a431a8f591d31100c3e73e99a8245e345).
I have 4 nodes with ~27 sensors total, half of sensors sending data every 10 seconds, another sensors send data only if environment changed.
After switching to esp8266 my gateway started loosing packets (messages) from my sensor nodes:
Left side of graphs is esp8266, right side is old pro mini serial gateway, sensors sending data every 10 seconds. Distance between gateways is about 5-10 centimeters. Both nrf24l01+ boards oriented in the same direction.nrf24l01+ board isn't changed at all (I'm using old board from pro mini serial gateway).
Also, I have tried different nrf24l01+ boards (different PCBs and different chip revisions, but seems like all of them are fake china chips). I have tried soldering 220 uF electrolytic and 0.1 uF ceramic capacitors directly to nrf24l01+ power pins. But nothing changed. Esp8266 gateway is losing messages.
Switching back to pro mini serial gateway is completely solves issue (as shown in graph above).
What else can I try to fix this? Could it be interference between wifi chip and nrf24? Or, maybe, this is software problem? Maybe non-interrupt driven polling of nrf24l01 causes loosing messages coming too often?
-
Interesting graph... But I have no immediate answer to you.
-
@hek graphs are drawn by Zabbix. My own Perl script connects directly to gateway, reads sensor data and sends this data directly to Zabbix.
Also, I have tried to write raw data from gateway directly to file and execute "tail -f logfile.txt | grep sensor-specific-id". With old pro mini gateway data from sensor comes every 10 seconds. From esp8266 gateway sensor data comes very irregular.
Also, every send() call in all my nodes followed by wait(25) call to reduce possible power issues and interference issues.
UPDATE: I have recompiled esp8266-gateway sketch with debugging enabled, but I get the same results with loosing messages then I connecting directly to uart port of esp8266 uart-usb converter.
-
@robosensor What strikes me is the fact that most of the time not all sensor values seem to disappear at the same time. A failing WiFi connection would be the most likely cause when all dis/reappear at the same time (like at 13:44 and 13:22).
However, most of the time at least one sensor seems to report its values correctly. IMO This rules out the radio.
Is there anything interesting in the serial logs?
-
@Yveaux thank you for your reply. It is not failing wifi connection, as the same problem exists then I using serial connection to esp8266 (via on-board usb-uart converter on nodemcu board).
Nothing interesting in the serial logs (with debug mode enabled), just random absence of sensor data. Seems like I should connect sensor node to collect debug logs from node side.
Also speed is changed - much faster CPU (80 MHz vs 8 MHz) and much faster connection (wifi vs uart 9600 bps). Maybe this affects.
-
Seems like problem with loosing messages is gateway firmware related.
Then I connect two controllers (my own perl script and MYSController 0.1.2.282) to esp8266 gateway (#define MY_GATEWAY_MAX_CLIENTS 2), both controllers receiving exactly the same data from gateway, but messages lost even more.
1 on graphs = one controller connected
2 on graphs = two controllers connected.I'm not familiar with esp8266 network programming, but could it be that firmware looses incoming packets from nrf24l01+ due to blocking call to wifi-related network functions? Seems like during sending data to wifi network firmware does not have time to pick up all incoming packets from nrf24l01+ chip.
-
I think I found problem. As I said before, seems like WiFi's clients[i].write() call blocks thread for a very long time.
I added logging of write() time:
// Send message to connected clients #if defined(MY_GATEWAY_ESP8266) unsigned long start_time = hwMillis(); for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (clients[i] && clients[i].connected()) { clients[i].write((uint8_t*)_ethernetMsg, strlen(_ethernetMsg)); } } debug(PSTR("WiFi transaction time: %u ms\n"), hwMillis() - start_time); #else _ethernetServer.write(_ethernetMsg); #endif
And got following results:
For Perl script from FreeBSD server in another country (ping to server is about 55 milliseconds):0;0;3;0;9;WiFi transaction time: 141 ms 0;0;3;0;9;read: 2-2-0 s=1,c=1,t=23,pt=2,l=2,sg=0:98 0;0;3;0;9;WiFi transaction time: 141 ms 0;0;3;0;9;read: 2-2-0 s=6,c=1,t=43,pt=3,l=2,sg=0:2 0;0;3;0;9;WiFi transaction time: 140 ms 0;0;3;0;9;read: 1-1-0 s=105,c=1,t=0,pt=7,l=5,sg=0:27.5000 0;0;3;0;9;WiFi transaction time: 136 ms 0;0;3;0;9;read: 1-1-0 s=106,c=1,t=0,pt=7,l=5,sg=0:52.8750 0;0;3;0;9;WiFi transaction time: 140 ms 0;0;3;0;9;read: 1-1-0 s=107,c=1,t=0,pt=7,l=5,sg=0:45.9375 0;0;3;0;9;WiFi transaction time: 142 ms 0;0;3;0;9;read: 1-1-0 s=108,c=1,t=0,pt=7,l=5,sg=0:34.4375 0;0;3;0;9;WiFi transaction time: 137 ms 0;0;3;0;9;read: 1-1-0 s=1,c=1,t=16,pt=0,l=1,sg=0:0 0;0;3;0;9;WiFi transaction time: 143 ms
Connection from LAN (windows telnet client):
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=23,pt=2,l=2,sg=0:61 0;0;3;0;9;WiFi transaction time: 209 ms 0;0;3;0;9;read: 4-4-0 s=1,c=1,t=24,pt=2,l=2,sg=0:152 0;0;3;0;9;WiFi transaction time: 201 ms 0;0;3;0;9;read: 4-4-0 s=2,c=1,t=24,pt=2,l=2,sg=0:43 0;0;3;0;9;WiFi transaction time: 212 ms 0;0;3;0;9;read: 4-4-0 s=3,c=1,t=24,pt=2,l=2,sg=0:129 0;0;3;0;9;WiFi transaction time: 209 ms 0;0;3;0;9;read: 4-4-0 s=4,c=1,t=24,pt=2,l=2,sg=0:147 0;0;3;0;9;WiFi transaction time: 208 ms 0;0;3;0;9;read: 2-2-0 s=102,c=1,t=0,pt=7,l=5,sg=0:4.2500 0;0;3;0;9;WiFi transaction time: 221 ms 0;0;3;0;9;read: 2-2-0 s=103,c=1,t=0,pt=7,l=5,sg=0:27.4375 0;0;3;0;9;WiFi transaction time: 208 ms 0;0;3;0;9;read: 2-2-0 s=104,c=1,t=0,pt=7,l=5,sg=0:23.3750 0;0;3;0;9;WiFi transaction time: 210 ms 0;0;3;0;9;read: 2-2-0 s=3,c=1,t=1,pt=7,l=5,sg=0:99.9 0;0;3;0;9;WiFi transaction time: 208 ms
Seems like many packets coming to NRF24L01+ in this time interval (140-200 milliseconds) and this causes NRF buffer overflow and packet loss.
-
Damn, 200 msec is a pretty long time.
-
@hek Yeah, but is this significantly longer than for a wired connection?
Only real solution would be to switch to interrupt based message handling for the MySensors network (hopefully the ESP stack can handle this...)
@robosensor Are these long delays (only) caused by the fact that this is a long distance connection?
How is your mileage for a server on e.g. the same lan?
-
Exactly same problem here with RFM69W Radio. With 2 clients, i loose more packets. Both controller and ESP are on the same LAN. No probelm with Serial Gateway on Jeelink v3.
-
@Yveaux seems like delays caused by low-level network/tcp code or settings of receiving side (maybe something as TCP ACK packet delays or Nagle algorithm or something like this).
ESP8266 connected directly to Mikrotik RB2011 router.
Then I connect from external server (ping to server is about 55 milliseconds, FreeBSD 9.3, Perl), delays about 140 milliseconds.
Then I connect from windows-based computer, connected directly to router, delays about 200 milliseconds (both windows telnet and PuTTy).
For 2 parallel above connections delays about 350 milliseconds.Then I connect from router's internal telnet client, delays about 1-2 milliseconds
Then I connect from android-based phone (phone connected to router via wifi, using ConnectBot software), delays vary from 3-5 milliseconds (mostly) to 100-150 milliseconds (less frequently).Seems like interrupts for nrf24 is the only solution.Seems like esp8266 gateway with such delays is completely unusable with high packet rates. With ~150 milliseconds delays no more than 6 messages/second packet rate allowed.Just to reference: I'm using Arduino 1.6.5 with esp8266 libraries version 2.0.0 installed.
-
@robosensor @Fabien Please understand that this issue is not related to ESP8266. I expect delays to be nearly identical when using the Ethernet gateway (wired ethernet) and ATMega microcontroller. Of course the serial gateway will not suffer from these delays as it doesn't use ethernet as transport medium -- it is a direct connection.
Switching to interrupt-based message handling for the MySensorts stack is not a simple task. It will require locking and buffering, and footprint of the library (especially RAM) will increase.
Furthermore I don't know how the ESP's network stack handles interrupts during ethernet processing. Worst case it will just block interrupts or run from a higher-priority interrupt than the nRF and all efforts of making the MySensors library interrupt based will be in vain.
I personally would try to reduce the latency in your server connection by choosing a server nearby or by buffering your traffic by a server in your LAN. MQTT for example can easily be buffered by a local broker which then uses the slow connection to sync with another server.
Another option is switching to a serial gateway, but again you need a local server inbetween.
A simple Raspberry Pi or so could act as a server for these scenarios.Another option would be to implement a retry mechanism on your sensors. If the gateway does not confirm reception of your message, then resend it.
-
@Yveaux I completely agree with you. Rewriting gateway code to support interrupts is not very easy task and it is not clear what problems you will encounter. Furthermore, rewriting will not solve the problem of delays, this only can solve packet loss problem.
Just tried to connect from RPi 2 (connected using WiFi directly to router), average delay is 2-5 milliseconds, sometimes 5-10 ms. Seems like this is good temporary solution.
-
@Yveaux said:
@D_dude flush the serial output after each print.
The ESP will output the serial data in the background while your programm continues and then it crashes.Finally was able to get everything working.
Ordered a fresh nRF from Itead and started from scratch. everything worked fine first time. seems like the nRF from ebay was causing issues.
-
Just tried old version of esp8266 libraries (1.6.5-947-g39819f0 instead of 2.0.0) with old version of esp8266 gateway (master branch, commit 9ef2604c81d2fea5d646a9a194f312192833a79b) and got exactly the same results.
WiFi write() time is about 150-200 milliseconds for remote server in another country, 200-210 milliseconds for windows7-based computer in local area network and 0-4 milliseconds for Raspberry Pi 2 in local area network.
To show transaction times just replace original
output
function inEsp8266Gateway.ino
with following code:void output(const char *fmt, ... ) { char serialBuffer[MAX_SEND_LENGTH]; va_list args; va_start (args, fmt ); vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args); va_end (args); Serial.print(serialBuffer); unsigned long start_time = millis(); for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (clients[i] && clients[i].connected()) { // Serial.print("Client "); Serial.print(i); Serial.println(" write"); clients[i].write((uint8_t*)serialBuffer, strlen(serialBuffer)); } } start_time = millis() - start_time; Serial.print("WiFi transaction time: "); Serial.print(start_time); Serial.println(""); }
Also disconnection of client during
clients[i].write()
call causes reboot by watchdog:ets Jan 8 2013,rst cause:4, boot mode:(3,7) wdt reset load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld
-
@robosensor said:
WiFi write() time is about 150-200 milliseconds for remote server in another country, 200-210 milliseconds for windows7-based computer in local area network and 0-4 milliseconds for Raspberry Pi 2 in local area network.
So another confirmation of what we knew already.
Do you know how many nRF messages are actually sent during this wifi write call?
The nRF has a rx buffer for 3 messages -- not sure if MySensors uses all 3 of them.Also disconnection of client during clients[i].write() call causes reboot by watchdog
I guess this is ESP core related. Is this fixed in code 2.0.0?
-
@Yveaux said:
So another confirmation of what we knew already.
Yes. It seems that I now understand what is happening. WiFiClient::write() blocks thread until TCP ACK packet received or until timeout (5 seconds). Windows sending TCP ACKs after 200ms timeout. That's why write() delayed for ~200 milliseconds for windows-based controller. More information (and link to non-blocking library) is available here: https://github.com/esp8266/Arduino/issues/922
Do you know how many nRF messages are actually sent during this wifi write call?
The nRF has a rx buffer for 3 messages -- not sure if MySensors uses all 3 of them.Nodes sending 3-7 (sometimes more) messages with 35 ms delay between messages, so in my case 3-packet hardware buffer in nrf24 is overflowed after 105-140 milliseconds of write() call.
Also disconnection of client during clients[i].write() call causes reboot by watchdog
I guess this is ESP core related. Is this fixed in code 2.0.0?I did not tried to check this reboots in 2.0.0, but 2.0.0 is much more stable and I never seen any reboots/resets.
-
@robosensor said:
2.0.0 is much more stable and I never seen any reboots/resets.
That sounds promising! I'll have to give the 2.0.0 core a try myself then.
-
Thanks for your work!
I made my wifigateway today and added variables for a static IP Adress.
I also tried to add an DHT11 to the wifi gateway, but it didn't work. I cannot include those sensors because I need to startup while inclusion and this would restart the gateway.
Mabe someone has an Idea how to add a sensor to the wifi gateway. edit: I found this thread on the forum ... http://forum.mysensors.org/topic/1387/sensors-on-gateway/** * 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 * Contribution by a-lurker and Anticimex, * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de> * Contribution by Ivo Pullens (ESP8266 support) * * DESCRIPTION * The EthernetGateway sends data received from sensors to the WiFi link. * The gateway also accepts input on ethernet interface, which is then sent out to the radio network. * * VERA CONFIGURATION: * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003 * * LED purposes: * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly * - ERR (red) - fast blink on error during transmission error or recieve crc error * * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions. * The ESP8266 however requires different wiring: * nRF24L01+ ESP8266 * VCC VCC * CE GPIO4 * CSN/CS GPIO15 * SCK GPIO14 * MISO GPIO12 * MOSI GPIO13 * * Not all ESP8266 modules have all pins available on their external interface. * This code has been tested on an ESP-12 module. * The ESP8266 requires a certain pin configuration to download code, and another one to run code: * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch') * - Connect GPIO15 via 10K pulldown resistor to GND * - Connect CH_PD via 10K resistor to VCC * - Connect GPIO2 via 10K resistor to VCC * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch') * * Inclusion mode button: * - Connect GPIO5 via switch to GND ('inclusion switch') * * Hardware SHA204 signing is currently not supported! * * Make sure to fill in your ssid and WiFi password below for ssid & pass. */ #define NO_PORTB_PINCHANGES #include <SPI.h> #include <MySigningNone.h> #include <MySigningAtsha204Soft.h> #include <MyTransportNRF24.h> #include <MyTransportRFM69.h> #include <EEPROM.h> #include <MyHwESP8266.h> #include <ESP8266WiFi.h> #include <MyParserSerial.h> #include <MySensor.h> #include <stdarg.h> #include "GatewayUtil.h" const char *ssid = "yourSSID"; // cannot be longer than 32 characters! const char *pass = "yourPassword"; // IPAddress local_ip(192,168,0,6); IPAddress dns_address(192,168,0,1); IPAddress gateway_ip(192,168,0,1); IPAddress subnet(255,255,255,0); //Code for DHT Temp and Hum /*#include <DHT.h> #define CHILD_ID_HUM 9 #define CHILD_ID_TEMP 10 #define HUMIDITY_SENSOR_DIGITAL_PIN 1 long intervall = 300000; //read Temp and Hum every 5 minutes long last_millis = -300000; DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); //End of Temp and Hum */ #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled #define INCLUSION_MODE_PIN 5 // Digital pin used for inclusion mode button #define RADIO_CE_PIN 4 // radio chip enable #define RADIO_SPI_SS_PIN 15 // radio SPI serial select #ifdef WITH_LEDS_BLINKING #define RADIO_ERROR_LED_PIN 7 // Error led pin #define RADIO_RX_LED_PIN 8 // Receive led pin #define RADIO_TX_LED_PIN 9 // the PCB, on board LED #endif // NRFRF24L01 radio driver (set low transmit power by default) MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW); //MyTransportRFM69 transport; // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) #ifdef MY_SIGNING_FEATURE MySigningNone signer; //MySigningAtsha204Soft signer; #endif // Hardware profile MyHwESP8266 hw; // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h) // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h MySensor gw(transport, hw #ifdef MY_SIGNING_FEATURE , signer #endif #ifdef WITH_LEDS_BLINKING , RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN #endif ); #define IP_PORT 5003 // The port you want to open #define MAX_SRV_CLIENTS 5 // how many clients should be able to telnet to this ESP8266 // a R/W server on the port static WiFiServer server(IP_PORT); static WiFiClient clients[MAX_SRV_CLIENTS]; static bool clientsConnected[MAX_SRV_CLIENTS]; static inputBuffer inputString[MAX_SRV_CLIENTS]; #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) void output(const char *fmt, ... ) { char serialBuffer[MAX_SEND_LENGTH]; va_list args; va_start (args, fmt ); vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args); va_end (args); Serial.print(serialBuffer); for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (clients[i] && clients[i].connected()) { // Serial.print("Client "); Serial.print(i); Serial.println(" write"); clients[i].write((uint8_t*)serialBuffer, strlen(serialBuffer)); } } } void setup() { // Setup console hw_init(); Serial.println(); Serial.println(); Serial.println("ESP8266 MySensors Gateway"); Serial.print("Connecting to "); Serial.println(ssid); (void)WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("Connected!"); Serial.print("IP: "); Serial.println(WiFi.localIP()); Serial.flush(); (void)WiFi.config(local_ip, dns_address, gateway_ip, subnet); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("Connected!"); Serial.print("IP: "); Serial.println(WiFi.localIP()); Serial.flush(); setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output); // Initialize gateway at maximum PA level, channel 70 and callback for write operations gw.begin(incomingMessage, 0, true, 0); // start listening for clients server.begin(); server.setNoDelay(true); /* //Code for Temp and Hum dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID_HUM, S_HUM); gw.present(CHILD_ID_TEMP, S_TEMP); metric = gw.getConfig().isMetric; //End of Temp and Hum */ } void loop() { gw.process(); checkButtonTriggeredInclusion(); checkInclusionFinished(); // Go over list of clients and stop any that are no longer connected. // If the server has a new client connection it will be assigned to a free slot. bool allSlotsOccupied = true; for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { if (!clients[i].connected()) { if (clientsConnected[i]) { Serial.print("Client "); Serial.print(i); Serial.println(" disconnected"); clients[i].stop(); } //check if there are any new clients if (server.hasClient()) { clients[i] = server.available(); inputString[i].idx = 0; Serial.print("Client "); Serial.print(i); Serial.println(" connected"); output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY); } } bool connected = clients[i].connected(); clientsConnected[i] = connected; allSlotsOccupied &= connected; } if (allSlotsOccupied && server.hasClient()) { //no free/disconnected spot so reject Serial.println("No free slot available"); WiFiClient c = server.available(); c.stop(); } // Loop over clients connect and read available data for (uint8_t i = 0; i < ARRAY_SIZE(clients); i++) { while(clients[i].connected() && clients[i].available()) { char inChar = clients[i].read(); if ( inputString[i].idx < MAX_RECEIVE_LENGTH - 1 ) { // if newline then command is complete if (inChar == '\n') { // a command was issued by the client // we will now try to send it to the actuator inputString[i].string[inputString[i].idx] = 0; // echo the string to the serial port Serial.print("Client "); Serial.print(i); Serial.print(": "); Serial.println(inputString[i].string); parseAndSend(gw, inputString[i].string); // clear the string: inputString[i].idx = 0; // Finished with this client's message. Next loop() we'll see if there's more to read. break; } else { // add it to the inputString: inputString[i].string[inputString[i].idx++] = inChar; } } else { // Incoming message too long. Throw away Serial.print("Client "); Serial.print(i); Serial.println(": Message too long"); inputString[i].idx = 0; // Finished with this client's message. Next loop() we'll see if there's more to read. break; } } } /* //Code for Temp and Hum if (millis() >= last_millis + intervall) { float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT"); } else if (temperature != lastTemp) { lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } gw.send(msgTemp.set(temperature, 1)); Serial.print("T: "); Serial.println(temperature); } float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum) { lastHum = humidity; gw.send(msgHum.set(humidity, 1)); Serial.print("H: "); Serial.println(humidity); } last_millis = millis(); } //End of Temp and Hum */ }
-
Any chance to achieve some success using ESP-01 or I really have to buy ESP-07/12?
I just have some ESP-01 modules already and I wonder if I can use them
-
@Alex-B-Goode the Spi bus is not available on the esp01 header, so you won't be able to connect the radio then...
-
But I guess you could use it as a sensor node (mqtt/ethernet).
-
@Yveaux said:
@krajcl Does it only crash when sending this particular message?
It's late (early morning) I did not want to read over all the last three months posts so my question... is there a solution for this problem? I just downloaded the latest library and found the NodeMCU will reboot when a node initializes. Data below. Just point me to the solution if you would please. Thanks very much.
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.54
3;1;1;0;0;21.54
0;0;3;0;9;read: 3-3-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
3;2;1;0;38;3.44
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.76
3;1;1;0;0;21.76
0;0;3;0;9;read: 3-3-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
3;2;1;0;38;3.44
0;0;3;0;9;read: 1-1-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.11
1;1;1;0;0;21.11
0;0;3;0;9;read: 1-1-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
1;2;1;0;38;3.44
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.76
3;1;1;0;0;21.76
0;0;3;0;9;read: 3-3-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
3;2;1;0;38;3.44
0;0;3;0;9;read: 0-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.1
0;255;0;0;17;1.5.1
0;0;3;0;9;read: 0-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0Exception (28):
epc1=0x40203911 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000ctx: cont
sp: 3ffefe50 end: 3fff00e0 offset: 01a0stack>>>
3ffefff0: 3ffeef14 3ffeee8b 3ffeee84 402037d5
3fff0000: 000000ff 00000003 00000006 00000001
3fff0010: 00000001 00000000 3ffeeed8 00000030
3fff0020: 00000000 3fffdc20 3ffef0ac 00000030
3fff0030: 00000003 00000001 00000001 00000000
3fff0040: 00000000 00000000 000000ff 00000023
3fff0050: 00000006 40209ee1 3ffeee64 3ffeee64
3fff0060: 00000000 00000000 3ffeee84 3ffeee84
3fff0070: 3fffdc20 00000000 3ffef0a4 40202582
3fff0080: 402020cc 3ffeee64 3fff1720 402051e6
3fff0090: 00000000 00ffffff 0100000a 3ffef0ac
3fff00a0: 00000000 00000000 00000016 40101941
3fff00b0: 40205499 1100000a 00000000 3ffef0ac
3fff00c0: 3fffdc20 00000000 3ffef0a4 402054c1
3fff00d0: 00000000 00000000 3ffef0c0 40100114
<<<stack<<<ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ldESP8266 MySensors Gateway
Connecting to TESTNETWORK
....Connected!
IP: 10.0.0.17
0;0;3;0;9;gateway started, id=0, parent=0, distance=0
0;0;3;0;9;read: 0-0-0 s=6,c=0,t=13,pt=0,l=0,sg=0:
0;6;0;0;13;
0;0;3;0;9;read: 0-0-0 s=1,c=1,t=16,pt=2,l=2,sg=0:0
0;1;1;0;16;0
0;0;3;0;9;read: 0-0-0 s=4,c=1,t=2,pt=2,l=2,sg=0:0
0;4;1;0;2;0
0;0;3;0;9;read: 0-0-0 s=5,c=1,t=2,pt=2,l=2,sg=0:0
0;5;1;0;2;0
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.76
3;1;1;0;0;21.76
0;0;3;0;9;read: 3-3-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
3;2;1;0;38;3.44
0;0;3;0;9;read: 3-3-0 s=1,c=1,t=0,pt=7,l=5,sg=0:21.97
3;1;1;0;0;21.97
0;0;3;0;9;read: 3-3-0 s=2,c=1,t=38,pt=7,l=5,sg=0:3.44
3;2;1;0;38;3.44
-
@Yveaux
Is there any specific reason on why CE is plugged on D2?
I'm asking as I want to add a BME280 sensor directly on my gateway and by default the I2C bus is on D2/D1. It can be changed to any pin with Wire.begin(SDA,SCL) so it is not a major problem, but for user friendliness it would be nicer id CE was plugged on D9 or eventually D4 or D3.If there is no specific reason can I change MyConfig.h line 329 to #define MY_RF24_CE_PIN 3 safely?
Thanks again for this gateway!
-
-
Switching it to D9 and adding #define MY_RF24_CE_PIN 3 directly to the program worked indeed.
Now everything seems to work either by moving the I2C bus or the CE. It may be nice to officially free up the I2C port on the next versions of the library by default? It could be easier than to modify each I2C sensor or even display libraries individually.
I will let it run a little while and if I don't see any major problem I will try to put the code in a new topic. Thanks for your fast answer @Yveaux !
-
Hi,
I have added som support, where the gateway can upload data to emoncms, transparant to other functions (not fully testet):
in gatewayutil add this in top of file, after the ARDUINO check:
#define EMONCMS #ifdef EMONCMS static WiFiClient emon_client; const char* emon_host = "emoncms.org"; const int emon_httpPort = 80; const int emon_addr_offset = 10; #endif
Change this function to:
void incomingMessage(const MyMessage &message) { // if (mGetCommand(message) == C_PRESENTATION && inclusionMode) { // gw.rxBlink(3); // } else { // gw.rxBlink(1); // } // Pass along the message from sensors to serial line serial(PSTR("%d;%d;%d;%d;%d;%s\n"),message.sender, message.sensor, mGetCommand(message), mGetAck(message), message.type, message.getString(convBuf)); #ifdef EMONCMS if (!emon_client.connect(emon_host, emon_httpPort)) { Serial.println("emoncms connection failed"); } emon_client.print(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n")); Serial.println(String("GET /emoncms/input/post.json?&node="+ String(message.sender+emon_addr_offset)+"&json={"+String(message.sensor)+":"+message.getString(convBuf)+"}&apikey=XXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n")); #endif }
It will upload data with NODE ID and Sensor ID from the network, with an offset of emon_addr_offset...
/Rapzak
-
hi.
Has someone already thought about using websockets with wifiGW ??? before I start to reinvent the wheel!
I have already made some tests with websockets but it was not with mysensors. it was not big tests too but I was able to have an html5 client with js. it was a simple test like blink led+serial monitor, receive/sending serial things. very simple!
I did this because I would like to have sort of display on my phone even if there are no controller. and I don't want to use spiffs and webserver. I prefer to have the stuff on client side and esp8266 acting as a simple websocket server. More lightweight I think, to handle something more complex if needed...For the client, then it could be html+boostrap or something more hybrid. I am not expert at this but I should be able to make some poc..but I don't want to waste my time if it already exists! I have lot of other projects so I don't know how long it could take, and maybe someone is faster on this, so it depends..but it's a feature I would like to have in future and I will make it when neededSo what do you think ??? dumb idea?
-
Yeah, thought about it the other day and found this.
https://github.com/Links2004/arduinoWebSockets
Would have been fun to create something cloud.mysensors.org where people could share sensor data (and of course make it embeddable on the forum). Creating a websocket gateway-variant would probably be my first choice if I decide going down that path.
It also seems to support wss which is kind of nice.
-
@hek : cool so you think it could be useful too.
yes I use this lib, nice features and simple to use.
so, even if someone has already done something, maybe I will dig a little for fun, time to time...
-
I haven't done anything yet. The old head is just constantly spinning ideas you know
So please go ahead and see if you can create a MyGatewayTransportWebsocket.cpp
-
-
@ErrK said:
Yep, use it on my dayjob. Allows downgrade to polling which (I guess) the Arduino library doesn't support. Might be better to use raw websocket on the server side in this case.
-
@ErrK : yes I saw it too. but here a discussion about socket.io with esp websockets https://github.com/Links2004/arduinoWebSockets/issues/42
very interesting