Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. RS485/RS232/Serial transport class for mysensors.org

RS485/RS232/Serial transport class for mysensors.org

Scheduled Pinned Locked Moved Development
rs485 serialrs485
143 Posts 27 Posters 102.9k Views 27 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • BartB Offline
    BartB Offline
    Bart
    wrote on last edited by Bart
    #99

    How about adding the following define to use the Serial1/2 on Mega. I have not tested yet but assuming the AltSoftSerial lib has the same interface/functionality it should work.

    #define MY_RS485_SERIAL Serial1
    
    diff --git a/core/MyTransportRS485.cpp b/core/MyTransportRS485.cpp
    index 814f721..ea35c9e 100644
    --- a/core/MyTransportRS485.cpp
    +++ b/core/MyTransportRS485.cpp
    @@ -92,7 +92,11 @@ unsigned char _recSender;
     unsigned char _recCS;
     unsigned char _recCalcCS;
     
    +#if defined(MY_RS485_SERIAL)
    +HardwareSerial& _dev = MY_RS485_SERIAL;
    +#else
     AltSoftSerial _dev;
    +#endif
     
     
     unsigned char _nodeId;
    
    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #100

      Looks like a neat solution. If it verifies ok, please create a pull request agains the development branch.

      1 Reply Last reply
      0
      • lanL Offline
        lanL Offline
        lan
        wrote on last edited by
        #101

        I understand that the RS485 is a separate gateway to communicate. Is it also possible to have the wireless gateway and RS485 gateway combined?

        1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #102

          Currently, no..

          lanL 1 Reply Last reply
          0
          • hekH hek

            Currently, no..

            lanL Offline
            lanL Offline
            lan
            wrote on last edited by
            #103

            @hek Thanks for the quick response. I'm looking for some direction (this might not be the right forum).
            I want to create a node to control my Itho Ecofan ventilation box. I now have a working program (thanks to the help of Rogier Reedijk The nodo now uses a CC1101 transceiver to control the box and thus uses the SPI bus. I'm looking for some direction to use this transmitter as part of my sensor network so I can control it from my Domoticz. Hope you can give me some directions how to proceed.

            1 Reply Last reply
            0
            • hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #104

              Why do you need to hook it up to RS485 wired network? Can't you just forwards commands to the CC11001 from any radio node or the gateway?

              1 Reply Last reply
              0
              • lanL Offline
                lanL Offline
                lan
                wrote on last edited by
                #105

                Is it then possible to use the two radio's on one node and share the SPI bus?

                1 Reply Last reply
                0
                • hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #106

                  Yes, if the CC11001 behaves correctly.

                  1 Reply Last reply
                  0
                  • lanL Offline
                    lanL Offline
                    lan
                    wrote on last edited by
                    #107

                    Thanks, will try that

                    1 Reply Last reply
                    0
                    • elektro12345E Offline
                      elektro12345E Offline
                      elektro12345
                      wrote on last edited by elektro12345
                      #108

                      Hello,
                      I have a problem running gatewayserial to rs-485 and the node with the usual lightsensor.
                      NODE # 1 as a gateway and tried to upload a sketch of the library 2.0 and 1.5.4, and the monitor serial I can not see any data, I use to check on the serial PuTTy com6 because the converter rs-485 to USB is connected to the PC.

                      NODE # 2 as a light sensor, during the upload Sketch by arduino programmer for serial monitor can see the data being sent but after plugging arduino to rs-485 as below no longer visible.

                      My question is whether I have something wrong with the connection or sketch, can someone show an example of a complete sketch for the gateway, and a node?

                      Connection mine looks like this:
                      TX and RX Connect was to pins 0 and 1 in arduino or 8 and 9, DE is always PIN 2.

                      alt text

                      BartB 1 Reply Last reply
                      0
                      • hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #109

                        Looks like you got the pins to the Arduino wrong.

                        Pin 9 >>> DI
                        Pin 8 >>> RO
                        Pin 2 >>> DE and RE

                        elektro12345E 1 Reply Last reply
                        0
                        • hekH Offline
                          hekH Offline
                          hek
                          Admin
                          wrote on last edited by
                          #110

                          I need a nice picture done in fritzing (or similar) for an article on the main site on how to connect the RS485 module (atmega 328 enough I guess).

                          Anyone volunteering in making one?

                          1 Reply Last reply
                          0
                          • CrankyCoderC Offline
                            CrankyCoderC Offline
                            CrankyCoder
                            wrote on last edited by
                            #111

                            so this is a 1 to 1 setup right? There is nothing here for multiple serial nodes correct?

                            Home Automation Tinkerer
                            www.CrankyCoder.net

                            Controller: HomeAssistant in Kubernetes
                            Gateway: MQTTClientGateway
                            MySensors: 2.3

                            1 Reply Last reply
                            0
                            • hekH Offline
                              hekH Offline
                              hek
                              Admin
                              wrote on last edited by
                              #112

                              Aren't they just daisy chained?

                              1 Reply Last reply
                              0
                              • hekH hek

                                Looks like you got the pins to the Arduino wrong.

                                Pin 9 >>> DI
                                Pin 8 >>> RO
                                Pin 2 >>> DE and RE

                                elektro12345E Offline
                                elektro12345E Offline
                                elektro12345
                                wrote on last edited by elektro12345
                                #113

                                @hek
                                On the pictures is connect to TX and RX pins arduino but I tried to connect to pins 8,9,2 and result was the same :(
                                On thsi connections with pins 8,9,2 ofcourse and library mysensors 2.0 should works fine ?

                                1 Reply Last reply
                                0
                                • hekH Offline
                                  hekH Offline
                                  hek
                                  Admin
                                  wrote on last edited by
                                  #114

                                  Yes, people have reported the RS485 transport working above.

                                  I just created this article with a summary of this thread
                                  https://www.mysensors.org/build/rs485

                                  1 Reply Last reply
                                  0
                                  • elektro12345E elektro12345

                                    Hello,
                                    I have a problem running gatewayserial to rs-485 and the node with the usual lightsensor.
                                    NODE # 1 as a gateway and tried to upload a sketch of the library 2.0 and 1.5.4, and the monitor serial I can not see any data, I use to check on the serial PuTTy com6 because the converter rs-485 to USB is connected to the PC.

                                    NODE # 2 as a light sensor, during the upload Sketch by arduino programmer for serial monitor can see the data being sent but after plugging arduino to rs-485 as below no longer visible.

                                    My question is whether I have something wrong with the connection or sketch, can someone show an example of a complete sketch for the gateway, and a node?

                                    Connection mine looks like this:
                                    TX and RX Connect was to pins 0 and 1 in arduino or 8 and 9, DE is always PIN 2.

                                    alt text

                                    BartB Offline
                                    BartB Offline
                                    Bart
                                    wrote on last edited by
                                    #115

                                    @elektro12345

                                    So what's with the DE+RE pins on that USB-RS485 converter? Will it even work in this configuration? I do have such converter but so far I've used the arduino as a SerialGateway to connect to RPi.

                                    elektro12345E 1 Reply Last reply
                                    0
                                    • BartB Offline
                                      BartB Offline
                                      Bart
                                      wrote on last edited by Bart
                                      #116

                                      I am not sure if I am seeing a normal behavior. I don't know if it is expected that the sensor is taking such long time to become visible to the GW. I have recreated the examples from https://www.mysensors.org/build/rs485

                                      The only difference is that I've added SketchInfo for the GW and used Serial1 on MEGA board instead of AltSoftSerial.

                                      The debug on the motion sensor is as follows:

                                      MCO:BGN:INIT NODE,CP=RSNNA--,VER=2.0.1-beta
                                      TSM:INIT
                                      TSM:INIT:TSP OK
                                      TSF:ASID:OK,ID=1
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      !TSM:FPAR:NO REPLY
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      !TSM:FPAR:NO REPLY
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      !TSM:FPAR:NO REPLY
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      !TSM:FPAR:FAIL
                                      TSM:FAILURE
                                      TSM:FAILURE:PDT
                                      TSM:FAILURE:RE-INIT
                                      TSM:INIT
                                      TSM:INIT:TSP OK
                                      TSF:ASID:OK,ID=1
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                                      TSF:MSG:FPAR RES,ID=0,D=0
                                      TSF:MSG:FPAR OK,ID=0,D=1
                                      TSM:FPAR:OK
                                      TSM:ID
                                      TSM:ID:OK,ID=1
                                      TSM:UPL
                                      TSF:PING:SEND,TO=0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                                      TSF:CHKUPL:FAIL
                                      !TSM:UPL:FAIL
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                                      TSF:MSG:FPAR RES,ID=0,D=0
                                      TSF:MSG:FPAR OK,ID=0,D=1
                                      TSM:FPAR:OK
                                      TSM:ID
                                      TSM:ID:OK,ID=1
                                      TSM:UPL
                                      TSF:PING:SEND,TO=0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                                      TSF:CHKUPL:FAIL
                                      !TSM:UPL:FAIL
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                                      TSF:MSG:FPAR RES,ID=0,D=0
                                      TSF:MSG:FPAR OK,ID=0,D=1
                                      TSM:FPAR:OK
                                      TSM:ID
                                      TSM:ID:OK,ID=1
                                      TSM:UPL
                                      TSF:PING:SEND,TO=0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                                      TSF:CHKUPL:FAIL
                                      !TSM:UPL:FAIL
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                                      TSF:MSG:FPAR RES,ID=0,D=0
                                      TSF:MSG:FPAR OK,ID=0,D=1
                                      TSM:FPAR:OK
                                      TSM:ID
                                      TSM:ID:OK,ID=1
                                      TSM:UPL
                                      TSF:PING:SEND,TO=0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                                      TSF:CHKUPL:FAIL
                                      !TSM:UPL:FAIL
                                      TSM:FPAR
                                      TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
                                      TSF:MSG:FPAR RES,ID=0,D=0
                                      TSF:MSG:FPAR OK,ID=0,D=1
                                      TSM:FPAR:OK
                                      TSM:ID
                                      TSM:ID:OK,ID=1
                                      TSM:UPL
                                      TSF:PING:SEND,TO=0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
                                      TSF:MSG:PONG RECV,HP=1
                                      TSF:CHKUPL:OK
                                      TSM:UPL:OK
                                      TSM:READY
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=10,sg=0,ft=0,st=OK:2.0.1-beta
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=OK:Motion Sensor
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
                                      MCO:REG:REQ
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                                      TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
                                      TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
                                      MCO:PIM:NODE REG=1
                                      MCO:BGN:STP
                                      MCO:BGN:INIT OK,ID=1,PAR=0,DIS=1,REG=1
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      0
                                      TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
                                      

                                      I don't know how to obtain debug from the Gateway Serial but as far as the GW messages on the console it looked as follows:

                                      0;255;3;0;14;Gateway startup complete.
                                      0;255;0;0;18;2.0.1-beta
                                      0;255;3;0;11;SerialGateway
                                      0;255;3;0;12;0.1
                                      1;255;3;0;6;0
                                      1;255;3;0;11;Motion Sensor
                                      1;255;3;0;12;1.0
                                      1;1;0;0;1;
                                      1;1;1;0;16;0
                                      1;1;1;0;16;0
                                      1;1;1;0;16;0
                                      1;1;1;0;16;0
                                      1;1;1;0;16;0
                                      

                                      As you see it takes a fair amount of time (around 30-40 secs) to obtain the readings from the sensor. This happens each time I reset the sensor node but it works instantly if I reset the GW (i.e. the readings appear instantly after the reset). Is it expected behavior?

                                      1 Reply Last reply
                                      0
                                      • hekH Offline
                                        hekH Offline
                                        hek
                                        Admin
                                        wrote on last edited by
                                        #117

                                        30 seconds sound like a long time.. Not sure what could be wrong. I don't have any test setup here unfortunately.

                                        BartB 2 Replies Last reply
                                        0
                                        • kduinoK Offline
                                          kduinoK Offline
                                          kduino
                                          wrote on last edited by
                                          #118

                                          Hi,
                                          I am wondering if I can just use the mySensors Lib to pass on the data via another connection. Currently I have a Loxone Controller which accepts UDP and TCP/IP connections (and others, but I chose these). As gateway I have an ArduinoMega and the network is running on RS485.
                                          So my understanding is that I can setup the network with the mySensors code and all the data is collected by the gateway which passes the data via UDP to the controller. V.v. the controller sends the data to the gateway which passes tha data on to the correspondent node.
                                          Is there any project similar to this?
                                          Thank you very much for your help!
                                          Best regards Kduino

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          25

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular