Page 1 of 1

[Solved] RPI 3 as MS gateway, arduino Mega as node over USB

Posted: Tuesday 03 April 2018 22:52
by KoenP
Hi Folks,

I've been browsing forums and tutorials, but I couldn't find an working solution.

I run domoticz V3.8153 on a Raspberry Pi 3B, with Stretch OS.

I would like to connect 2 16CH relay boards and 1 8CH relay board to my RPi. One 16CH board is wired directly to the RPi's GPIO and imported in Domoticz using SYSFS. I have a arduino mega clone here that I would like to use to connect the other 16CH and the 8CH relay board to. Since the arduino and the relay boards and the RPi are in the same box, I would like to connect them wired, so not over radio, but USB.(the usb ports have no further use for me on the RPi)

I was thinking of making my RPi with Domoticz also a MySensors gateway without radio, and connect my Mega clone as "node" with the MySensors relay board sketch to the RPi with USB.

Is this possible? If yes, could someone give me a push in the right direction to get this running?

Thanks in advance,
KoenP

Re: RPI 3 as MS gateway, arduino Mega as node over USB

Posted: Wednesday 04 April 2018 18:59
by kisse66
I was earlier testing RS485 node via normal USB serial, so assuming I understood what you want I think you can do it in two ways:

1) make the Mega a serial MYS GW and connect it via USB to RPi. Domoticz can directly use it as serial GW (at /dev/ttyUSB0 or similar). GW should also be able to have sensors as any other node, so just write your relay code on top of the basic GW definitions. Haven't tried myself.

2) run MYS ethernet GW on the RPi with RS485 transport config (!) and make the Mega a normal node with RS485 transport as well. You don't need actual RS485, normal serial works just fine (for one node per GW). Connect GW to Domoticz using MYS GW IP 127.0.0.1.

I compiled MYS eth GW with

Code: Select all

 ./configure --my-transport=rs485 --my-rs485-serial-port=/dev/ttyUSB0 --my-rs485-baudrate=19200 --my-gateway=ethernet --my-port=5003
 make
For the node sketch I used

Code: Select all

#define MY_RS485
#define MY_RS485_DE_PIN 10 // you can ignore this, but set to unused pin, default is 2
#define MY_RS485_BAUD_RATE 19200  // match your serial GW!
#define MY_RS485_HWSERIAL Serial
No radio definitions. The last one makes MYS use the first HW serial port normally used via USB for console, so when you connect it to the RPI they can now talk thinking there is RS485 in between. Additionally you might need to add #define MY_DISABLED_SERIAL
I used Arduino Uno, should apply to Mega as well. Domoticz might provide automatic IDs also using serial, but I hard-coded my test node (#define MY_NODE_ID 99). Try fixed ID if it doesn't seem to do anything.

Re: RPI 3 as MS gateway, arduino Mega as node over USB

Posted: Friday 13 April 2018 15:36
by KoenP
Thanks guys,

I got it up and running!

I made the arduino a serial GW, and wrote the relay code on top like kisse66 sugested., and I commented out the radio definitions.

works perfectly!