@Jstoaks no, I did not. I gave up. After some research I found better solution:
Raspberry PI zero + mysgw (485) + Mqtt + Node Red with Dashboard UI. It works great. I use mqtt for both mysensors and wifi devices (esp32/esp8266).
Node Red handles my home automation very well.
Posts made by Konrad Winiarski
-
RE: mysgw not responding on RS485 data - raspberry pi zero
-
RE: mysgw not responding on RS485 data - raspberry pi zero
I have checked with ethernet port instead of serial:
sudo ./configure --my-debug=enable --my-config-file=/etc/mysensors.conf --my-transport=rs485 --my-gateway=ethernet --my-port=5003 --my-rs485-de-pin=7 --my-rs485-serial-port=/dev/ttyS0 --my-rs485-baudrate=9600 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18
The results is:
-
The gateway works with nodes as expected - no need to hit Enter for updates. It works as daemon as well.
So why it not works on gateway with serial? My suspicious is the port - I was using fake ones (/dev/ttyMySensorsGateway and /dev/ttyUSB020) and the real one /dev/ttyAMA0. Always the same. I tried to listen the (fake) port with "screen" command - nothing was there. -
I have another finding/problem. When the gateway starts:
Sep 21 14:20:57 ERROR Failed to open log pipe. Sep 21 14:20:57 INFO Starting gateway... Sep 21 14:20:57 INFO Protocol version - 2.3.2 Sep 21 14:20:57 DEBUG MCO:BGN:INIT GW,CP=RSNGL---,FQ=NA,REL=255,VER=2.3.2 Sep 21 14:20:57 DEBUG TSF:LRT:OK Sep 21 14:20:57 DEBUG TSM:INIT Sep 21 14:20:57 DEBUG TSF:WUR:MS=0 Sep 21 14:20:57 DEBUG Serial port /dev/ttyS0 (9600 baud) created Sep 21 14:20:57 DEBUG TSM:INIT:TSP OK Sep 21 14:20:57 DEBUG TSM:INIT:GW MODE Sep 21 14:20:57 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Sep 21 14:20:57 DEBUG MCO:REG:NOT NEEDED Sep 21 14:20:57 DEBUG Listening for connections on F▒▒:5003 Sep 21 14:20:57 DEBUG MCO:BGN:STP Sep 21 14:20:57 DEBUG MCO:BGN:INIT OK,TSP=1 Sep 21 14:20:57 DEBUG TSM:READY:NWD REQ Sep 21 14:20:57 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Sep 21 14:21:10 DEBUG TSF:MSG:READ,50-50-0,s=0,c=1,t=23,pt=2,l=2,sg=0:58
... you can find that instead of IP address (I was expecting 127.0.0.0 or 0.0.0.0) I get a garbage:
DEBUG Listening for connections on F▒▒:5003
After another trial (make clean -> ./configure .... -> make I get similar but with different "garbage":
DEBUG Listening for connections on ▒ݾ:
Home Assistant is unable to find the gateway on ports 127.0.0.1 and 0.0.0.0. I tried local network IP (static) - it was "accepted" (no connection error returned), but no Nodes has been found.
I'm really stubborn to find single board solution for Gateway (RS485 nodes) and Controller but I'm getting tired :(. -
-
mysgw not responding on RS485 data - raspberry pi zero
Hi!
I set up MySensors gateway on RPI Zero. The goal is to have a gateway for RS485 nodes and a HomeAsisstant on the same board.
I set up the UART like described here:
https://di-marco.net/blog/it/2020-06-06-raspberry_pi_3_4_and_0_w_serial_port_usage/... and tested using Python script and separate TTL<->USB converter to view what is going on on TX/RX pins of RPI and Arduino (Node).
- (irrelevan for this topic) What is interesting - I have two systems set up (two SD cards) based on the same instruction. First I tried to install MySensors first (plain system) - the right device is /tty/AMA0. Second, I installed HomeAsisstant (Docker) first, then prepared ports and install MySensors - the right device is /ttyS0.
The installation process for the gateway was as follows:
sudo apt-get install git git clone https://github.com/mysensors/MySensors.git --branch master cd MySensors sudo touch /dev/ttyUSB020 && sudo chmod 660 /dev/ttyUSB020 && sudo chown root:dialout /dev/ttyUSB020
and the configuration as follows:
sudo ./configure --my-debug=enable --my-config-file=/etc/mysensors.conf --my-transport=rs485 --my-gateway=serial --my-port=/dev/ttyUSB020 --my-serial-baudrate=115200 --my-serial-is-pty --my-rs485-de-pin=7 --my-rs485-serial-port=/dev/ttyAMA0 --my-rs485-baudrate=9600 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18
After I started the gateway using
sudo ./bin/mysgw
It started as follows:
Sep 21 12:43:27 ERROR Failed to open log pipe. Sep 21 12:43:27 INFO Starting gateway... Sep 21 12:43:27 INFO Protocol version - 2.3.2 Sep 21 12:43:27 DEBUG MCO:BGN:INIT GW,CP=RSNGL---,FQ=NA,REL=255,VER=2.3.2 Sep 21 12:43:27 DEBUG TSF:LRT:OK Sep 21 12:43:27 DEBUG TSM:INIT Sep 21 12:43:27 DEBUG TSF:WUR:MS=0 Sep 21 12:43:27 DEBUG Serial port /dev/ttyAMA0 (9600 baud) created Sep 21 12:43:27 DEBUG TSM:INIT:TSP OK Sep 21 12:43:27 DEBUG TSM:INIT:GW MODE Sep 21 12:43:27 DEBUG TSM:READY:ID=0,PAR=0,DIS=0 Sep 21 12:43:27 DEBUG MCO:REG:NOT NEEDED 0;255;3;0;14;Gateway startup complete. 0;255;0;0;18;2.3.2 Sep 21 12:43:27 DEBUG MCO:BGN:STP Sep 21 12:43:27 DEBUG MCO:BGN:INIT OK,TSP=1 Sep 21 12:43:28 DEBUG TSM:READY:NWD REQ
Then I turned on the Node and it could not get response from gateway:
227278 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 229287 TSM:UPL 229306 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 231314 TSM:UPL 231332 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 233341 TSM:UPL 233360 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1 235368 !TSM:UPL:FAIL 235370 TSM:FPAR 235371 TSM:FPAR:STATP=0 235373 TSM:ID 235375 TSM:ID:OK 235376 TSM:UPL
..untill I pressed <Enter>
Sep 21 12:49:40 DEBUG TSM:READY:NWD REQ Sep 21 12:49:40 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK: Sep 21 12:49:40 DEBUG TSF:MSG:READ,50-50-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1 Sep 21 12:49:40 DEBUG TSF:MSG:PINGED,ID=50,HP=1 Sep 21 12:49:40 DEBUG TSF:MSG:SEND,0-0-50-50,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1
and on the node:
388210 TSF:MSG:BC 388353 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0 388360 TSF:MSG:READ,0-0-50,s=255,c=3,t=25,pt=1,l=1,sg=0:1 388365 TSF:MSG:PONG RECV,HP=1 388368 TSM:UPL:OK 388369 TSM:READY:ID=50,PAR=0,DIS=1 388391 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100 390421 TSF:MSG:SEND,50-50-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2 390446 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0 392480 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Light Sensor 392508 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0 392531 TSF:MSG:SEND,50-50-0-0,s=0,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=OK: 392538 MCO:REG:REQ 392557 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 394582 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 396605 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 398628 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2 400635 MCO:BGN:INIT OK,TSP=1
So it seems fine - there is communication etc... The problem is that nothing happens on the gateway side untill I press <Enter>. It does not work "by it self". After I hit the key again (in putty) the program shows all data sent by Node since last press.
Same problem seems to be when the mysgw is stared as daemon (--daemon or as service) - there is no reaction on Nodes. I waited 45min :(.
Any idea for that?
Regards!
Konrad -
ESP32/ESP8266 RS485 gateway - example needed
Hi there!
Did anyone tried (successfuly) to use ESP32 as gateway for RS485 nodes?
So far I tried to (testing on ESP8266):- ...use example for Serial Gateway: https://www.mysensors.org/build/rs485 but no success. AltSoftwareSerial is not working with ESP32, it won't compile,
- ...search for solution to replace AltSoftwareSerial to EspSoftwareSerial - but nothing found,
- ...change to HWSerial (#define MY_RS485_HWSERIAL Serial1 // also checked with Serial) but there is no data "comming out" from TX pin (except ESP "junk" and the start),
Some debug info:
- The node (Arduino) is the code from example: https://www.mysensors.org/build/rs485:
381282 TSM:FAIL:RE-INIT 381284 TSM:INIT 381285 TSM:INIT:TSP OK 381287 TSF:SID:OK,ID=10 381290 TSM:FPAR 381308 ?TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 383316 !TSM:FPAR:NO REPLY 383319 TSM:FPAR 383337 ?TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 385345 !TSM:FPAR:NO REPLY 385347 TSM:FPAR 385366 ?TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 387374 !TSM:FPAR:NO REPLY 387376 TSM:FPAR 387394 ?TSF:MSG:SEND,10-10-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK: 389402 !TSM:FPAR:FAIL 389404 TSM:FAIL:CNT=7 389406 TSM:FAIL:DIS 389408 TSF:TDI:TSL
- the data is transmitted out to RS485 (checked with another TTL-USB converter), hex:
01 FF 0A 58 07 02 0A 0A FF 02 03 07 FF 03 86 04
- the data is received from RS485 (same content) as above - DE/RE pins are controlled from ESP (at least Low State is set)
- RO is connected to RX pin at ESP32
- no response is comming out from TX pin (except junk at start)
The code:
Thanks in advance for hints!
Konrad -
RE: Corrupted data from RS485 Sensor Node
Yes, I realized that last Sunday. I went through the code of library. I had to switch to another project for a week or so, then I come back to it. Thanks!
-
RE: Corrupted data from RS485 Sensor Node
Hi Cabat. Both checked. I wrote my own code to test it. I'm having my own working RS485 network at home already. I did it by myself and I'm pretty experienced in debugging ;). I want to switch to MySensors now due to more flexibility.
So to summarize:- it is not a RS485 issue, tested,
- it is not a USB/TTL converter issue, tested,
- it is not an UART bitrate issue, not on the PC side at least,
- there is no difference if I use hardware or software serial - same content.
I have conserns about the Library. According to this page:
https://www.mysensors.org/download/serial_api_20
the typical frame sent by a node should be like this:
12;6;0;0;3;My Light\n
12;6;1;0;0;36.5\n
13;7;1;0;2;1\nAs you can see on picture in firs post, when I configured to use HWSerial for RS485 and DEBUG set ON, I shall expect both - Communication and Debug on the same line. Debug data is correct, but the frame is nothing like a text message - looks like the content is sent in HEX not ASCII.
I learned there is no encryption, so it is not an encrypted data I assume. -
Corrupted data from RS485 Sensor Node
Hello. I'm using Arduino Pro Mini (atmega328) and checking one of basic examples (MotionSensorRS485). The gateway is connected via same RS485 converter. Unfortunately they do not communicate.
First I checked connection (direct TX-RX/RX-TX) connection - with failure. Then I took another USB/TTL converter to check what is on the output of softserial - and I found some kind of garbage data. It looks like wrong baudrate so I checked all "standard" speeds from 2400 up to 115200. (Configured to 9600).
Then I enabled DEBUG, enabled HWSERIAL and set to Serial. Both baudrates set to 9600. So I have now both, the communication frame and debug. See screenshot below.When I disable DEBUG, only corrupted frame left:
The code:
//#define MY_DEBUG //#define MY_DEBUG_LOCAL // Enable RS485 transport layer #define MY_RS485 // Define this to enables DE-pin management on defined pin #define MY_RS485_DE_PIN 2 // Set RS485 baud rate to use #define MY_BAUD_RATE 9600 #define MY_RS485_BAUD_RATE 9600 //19200 //57600 //38400 //9600 #define MY_RS485_SOH_COUNT 1 #define MY_RS485_HWSERIAL Serial #define MY_SPLASH_SCREEN_DISABLED //#define MY_PASSIVE_NODE #define MY_NODE_ID 10 #include <MySensors.h> uint32_t SLEEP_TIME = 3000;//+120000 // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define CHILD_ID 1 // Id of the sensor child // Initialize motion message MyMessage msg(CHILD_ID, V_TRIPPED); void setup() { pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input } void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo("Motion Sensor", "1.0"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID, S_MOTION); } void loop() { // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. //sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME); }
An Idea? Arduino board is not corrupted, any short sketch with SoftSerial library works fine. Haven't checked MySensors with SoftSerial though. MySensors version 2.3.2. Checked on Arduino IDE and VSC.
Cheers!