Skip to content
  • 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
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

RS485/RS232/Serial transport class for mysensors.org

Scheduled Pinned Locked Moved Development
rs485 serialrs485
143 Posts 27 Posters 102.8k 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.
  • karlheinz2000K Offline
    karlheinz2000K Offline
    karlheinz2000
    wrote on last edited by
    #124

    @Bart
    Does it work with serial1 on mega2560?

    I can't get a single bit out of the harware serial1.
    Is it only the smal patch in MyTransportRS485.cpp?

    BartB 1 Reply Last reply
    0
    • karlheinz2000K karlheinz2000

      @Bart
      Does it work with serial1 on mega2560?

      I can't get a single bit out of the harware serial1.
      Is it only the smal patch in MyTransportRS485.cpp?

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

      @karlheinz2000
      Yes. Got it working with this patch. Although not reliably when other board was using the altsoftserial.

      1 Reply Last reply
      0
      • karlheinz2000K Offline
        karlheinz2000K Offline
        karlheinz2000
        wrote on last edited by
        #126

        Got it working too :smile:
        Problem was: RX1 and TX1 labels on the chinese Mega2560 board are swapped. :angry:
        All other RX/TX labels are right.

        BartB 1 Reply Last reply
        0
        • karlheinz2000K karlheinz2000

          Got it working too :smile:
          Problem was: RX1 and TX1 labels on the chinese Mega2560 board are swapped. :angry:
          All other RX/TX labels are right.

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

          @karlheinz2000 Are any of your boards using AltSoftSerial instead of HW serial? I was not able to get a reliable connection with software serial library....

          1 Reply Last reply
          0
          • karlheinz2000K Offline
            karlheinz2000K Offline
            karlheinz2000
            wrote on last edited by
            #128

            I use a mega with hw-serial and a nano (gateway) with AltSoftSerial.
            It works fine the last 24 hours. Still running...
            I did not test other configurations.

            1 Reply Last reply
            0
            • hekH hek

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

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

              @hek Looks like something has been fixed in regards to altSoftSerial. Today I've pulled latest development and everything works fine. The gateway has no problem finding nodes and all messages reach their destinations.

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

                Hmm, strange. Wonder if this PR affected the behaviour of AltSoftSerial (in a good way).

                https://github.com/mysensors/MySensors/pull/599

                BartB 1 Reply Last reply
                0
                • hekH hek

                  Hmm, strange. Wonder if this PR affected the behaviour of AltSoftSerial (in a good way).

                  https://github.com/mysensors/MySensors/pull/599

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

                  @hek I will try to check if this change did it.

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

                    I am wondering if a node-2-node communication should be working. I have compiled the ping/pong example for RS485 but it appears the nodes are not communicating.

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

                      Did you set one of them to be repeater (or gateway)?

                      BartB 1 Reply Last reply
                      0
                      • hekH hek

                        Did you set one of them to be repeater (or gateway)?

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

                        @hek ok. all good now - the ping pong example working. I forgot about the gateway flag.

                        BTW, checked to see if the GW has any issues without PR 599 but it seems it is still working OK. I have not changed the HW connections so must be some other change.

                        1 Reply Last reply
                        0
                        • karlheinz2000K Offline
                          karlheinz2000K Offline
                          karlheinz2000
                          wrote on last edited by
                          #135

                          Is any data buffer/FIFO implemented in RS485 gateway?
                          My controller (fhem) is transmitting data too fast to the gateway, so some data is not transmitted on RS485.
                          I checked RX/TX from controller to gateway -> all data is going into gateway. But not all data goes out to my sensor node.

                          I have only one sensor (and gateway) on RS485.
                          Baudrate is 19200 on RS485 and to controller.
                          Sensor node uses HW serial. Gateway is on NANO with AltSoftSerial.

                          L 1 Reply Last reply
                          0
                          • karlheinz2000K karlheinz2000

                            Is any data buffer/FIFO implemented in RS485 gateway?
                            My controller (fhem) is transmitting data too fast to the gateway, so some data is not transmitted on RS485.
                            I checked RX/TX from controller to gateway -> all data is going into gateway. But not all data goes out to my sensor node.

                            I have only one sensor (and gateway) on RS485.
                            Baudrate is 19200 on RS485 and to controller.
                            Sensor node uses HW serial. Gateway is on NANO with AltSoftSerial.

                            L Offline
                            L Offline
                            LeoDesigner
                            wrote on last edited by
                            #136

                            @karlheinz2000
                            I had no chance to look to the AltSoftSerial code, but if we are talking about hardware serial - arduino as a standard has 64 bytes buffer. I think it's possible that your gateway is not fast enough to process packets at high rate from FHEM. Also even if they are processed on time - at 19200 you may loose packets due low serial speed. It's simple no room for next packet.

                            1 Reply Last reply
                            0
                            • karlheinz2000K Offline
                              karlheinz2000K Offline
                              karlheinz2000
                              wrote on last edited by
                              #137

                              @LeoDesigner
                              I did a hardware update. Now sensor and gateway are arduino mega. Everything is running on 115200 hardware serial.
                              RS485 communication looks good. Data is going into sensor node, but does not appear in MySensors.
                              I tried to increase RX buffer via #define SERIAL_RX_BUFFER_SIZE 256, with no effect in functionality. Does this define works as expected? Because this buffer size number has no effect on the 'dynamic memory' usage after compiling the sketch. It shows always the same number of used bytes, independent of the RX buffer size.

                              1 Reply Last reply
                              0
                              • karlheinz2000K Offline
                                karlheinz2000K Offline
                                karlheinz2000
                                wrote on last edited by
                                #138

                                [Solved]
                                Initial Problem were incoming messages at sensor node during reading an image from SD card (170ms). Increase of serial RX buffer size solved the problem.

                                Good to know:
                                The serial buffer size is not defined in:
                                c:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h
                                You can change the numbers with no effect to your sketch.

                                You have to change:
                                c:\Users...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino\HardwareSerial.h

                                Then it will work :smiley:

                                1 Reply Last reply
                                2
                                • AndrewZA Offline
                                  AndrewZA Offline
                                  AndrewZ
                                  wrote on last edited by
                                  #139

                                  I'm curious whether it is possible to use this RS485 transport with Ethernet or MQTT gateway or Serial gateway is the only option?
                                  For example, controller talks with MySensors Gateway over Ethernet,
                                  MySensors Gateway talks with the Nodes over RS485.
                                  Thanks!

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

                                    @AndrewZ

                                    Yes, that should work just fine.

                                    AndrewZA 1 Reply Last reply
                                    0
                                    • hekH hek

                                      @AndrewZ

                                      Yes, that should work just fine.

                                      AndrewZA Offline
                                      AndrewZA Offline
                                      AndrewZ
                                      wrote on last edited by
                                      #141

                                      @hek
                                      thanks for this really fast and motivating response, I will try!

                                      1 Reply Last reply
                                      1
                                      • AndrewZA Offline
                                        AndrewZA Offline
                                        AndrewZ
                                        wrote on last edited by AndrewZ
                                        #142

                                        I'm trying to get my Ethernet gateway (UNO with W5100) working with RS485 transport.
                                        While RS485 part seems to be working fine between the node and gateway, the Ethernet part seems to be dead. I suspect this is related to the fact that Ethernet shield uses pin 10 which is unusable with RS485. Am I right? Any workaround?

                                        1 Reply Last reply
                                        0
                                        • skatunS Offline
                                          skatunS Offline
                                          skatun
                                          wrote on last edited by
                                          #143

                                          Today the new rs485 shield arrived, i will solder it up over the weekend and start testing early next week:)

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


                                          9

                                          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
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular