RS485/RS232/Serial transport class for mysensors.org
-
Hi everyone !
I needed a wired solution for my several nodes.
Here is the serial rs485/rs232 wired network transport for mysensors.
https://github.com/leodesigner/mysensors-serial-transport
It is based on the Majenko ICSC serial library.
Can you please test it? It is a beta version - but it is working for me.
(However, I am still waiting for my rs485 boards to arrive)
You can find more technical information at
http://sourceforge.net/p/arduino-icsc/wiki/RS-485/To use it, you have to:
- Put SerialTransport.cpp and SerialTransport.h to folder/directory/path SerialTransport in your library.
- Add #include <SerialTransport.h> to your .ino sketch
- Replace transport class with:
MyTransportSerial transport(Serial,0,-1); // serial port, node, dePin (-1 disabled)
Please let me know about bugs and how it is working for you.
-
so cool :smiley: it seems very interesting, and could be a nice addition. I will look at it. thx for share
:thumbsup: -
-
Woah, nice!! I've thought about doing the same but didn't find the time.
I will try to test, the RS485 are already lying on my desk. -
I have to wait before my Guests will leave, but this is something I'm interested in. Will check it in a week or two. I want to have a sensor that checks whenever I lay in my bed. I'd preffer to transfer this kind of details wired and not wireless ;)
-
I just started a thread on using sensors without a radio. So this really caught my attention. Would it be possible to modify it to use the USB Serial interface for arduinos that have it?
@shabba I am not quite understood what exactly you want to do with USB. You can use arduino nano without any problems at all.
All you have to do just to make sure to disconnect your RS485 bus from RX pin during the time when you will upload your sketch/firmware.
Also it is possible to use this class without any converters at all. See attached simple schematics on github page.
Regarding USB - you can attach an RS485-USB adapter to this bus as well too.
So it is an universal solution for a serial communication between many arduinos via serial port. Please note about possibility to connect this bus to RPi directly. ICSC lib include the library for RPi too.
Also, it's better to disable DEBUG option in mysensors config file to avoid additional traffic on the serial bus. -
@LeoDesigner Sorry for not being clear. I was looking to connect my Arduino Mega (has about a dozen sensors and relays connected to it) to my existing RPi2 sensors serial gateway (using a UNO). I was hoping I could use a second USB/Serial port on the RPi2 to receive messages from the Mega.
-
@LeoDesigner Sorry for not being clear. I was looking to connect my Arduino Mega (has about a dozen sensors and relays connected to it) to my existing RPi2 sensors serial gateway (using a UNO). I was hoping I could use a second USB/Serial port on the RPi2 to receive messages from the Mega.
@shabba Take a look to https://github.com/MajenkoLibraries/ICSC/tree/master/debian
It may be a starting point for you. You can adopt this part of the ICSC library to your RPi2 setup. -
Finally I am received my RS485 modules.
Here is the working example of gateway with two nodes: -
To test this I ordered a few of these..
http://www.ebay.com/itm/381374599127?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AITHope they are the correct model.
-
To test this I ordered a few of these..
http://www.ebay.com/itm/381374599127?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AITHope they are the correct model.
@hek
My modules are from http://www.aliexpress.com/item/FREE-SHIPPING-5PCS-LOT-MAX485-module-RS485-module-TTL-turn-RS-485-module-MCU-development-accessories/1718665649.html
They are the same as yours - based on MAX485.
However, it is possible to run a simple TTL signal level bus on a short distances.
(https://github.com/leodesigner/mysensors-serial-transport/blob/master/sch.png) -
@hek
My modules are from http://www.aliexpress.com/item/FREE-SHIPPING-5PCS-LOT-MAX485-module-RS485-module-TTL-turn-RS-485-module-MCU-development-accessories/1718665649.html
They are the same as yours - based on MAX485.
However, it is possible to run a simple TTL signal level bus on a short distances.
(https://github.com/leodesigner/mysensors-serial-transport/blob/master/sch.png)I've incorporated a slimmed down of the RS485 transport layer in this branch (soon to be merged into development):
https://github.com/mysensors/Arduino/tree/serial-transport/libraries/MySensors
But I've still haven't received my RS485 modules... Do you have time to run a small test?
And a test-motion sensor sketch:
https://github.com/mysensors/Arduino/tree/serial-transport/libraries/MySensors/examples/MotionSensorRS485But you could use any example just replacing
#define MY_RADIO_RF24with#define MY_RS485I've used the AltSerial library for RS485 communication so we can cope with dual serial ports on the serial gateway. This library requires using pins documented in sketch.
-
I've incorporated a slimmed down of the RS485 transport layer in this branch (soon to be merged into development):
https://github.com/mysensors/Arduino/tree/serial-transport/libraries/MySensors
But I've still haven't received my RS485 modules... Do you have time to run a small test?
And a test-motion sensor sketch:
https://github.com/mysensors/Arduino/tree/serial-transport/libraries/MySensors/examples/MotionSensorRS485But you could use any example just replacing
#define MY_RADIO_RF24with#define MY_RS485I've used the AltSerial library for RS485 communication so we can cope with dual serial ports on the serial gateway. This library requires using pins documented in sketch.
@hek
My example boxes are installed right now on the site and doing a daily job :)
It will take time to build a new one. I may try a breadboard, but I am still busy to finish additional improvements to mysensors.org project. (I will share them later - it's will be interesting too - I hope :) )Actually, it's easy to test RS485 transport without a RS485 converters - just use a simple schematics I have been talking before.
Also, you may want to look to this: https://github.com/MajenkoLibraries/ICSC/pulls
It's untested support for SoftwareSerial option for library.
With AltSerial we will be forced to use only a documented pins.Anyway - I am glad to contribute a bit to great mysensors community.
-
Thanks,
@LeoDesigner said:
With AltSerial we will be forced to use only a documented pins.
Yes, I know. But AltSerial can handle higher speeds. I preferred that over the SoftwareSerial flexibility regarding pin selection. Hope I did the right choice ;)
-
Thanks,
@LeoDesigner said:
With AltSerial we will be forced to use only a documented pins.
Yes, I know. But AltSerial can handle higher speeds. I preferred that over the SoftwareSerial flexibility regarding pin selection. Hope I did the right choice ;)
@hek
Speed is one of the reasons why I have decided to use hardware serial. :)
But we should be flexible and universal as much as we can. I had been thinking also to add support for over the wire firmware update. As you have done with wireless. -
@hek
Sure - but it can be possible done with standard bootloader - we just have to emulate standard Arduino sketch upload process on the gateway side. But I am not sure if it's possible to do with half duplex protocol. Just an idea.