I finally got it working reading through google searches. I'd like to provide how I did it for anyone that may run into a similar issue in the future. While looking for this solution, I saw at least one person who had the exact same issue and their problem went unresolved.
Raspberry Pi 3 is connected to Arduino Mega through regular serial link. Raspberry pi uses uart pins that map to Serial0 in raspbian. On Arduino Mega I use Serial2 pins (16,17). There's a voltage divider circuit between the two that reduces 5v to 3.3 for the pi.
I compiled my gateway on pi with below:
./configure --my-transport=rs485 --my-rs485-serial-port=/dev/serial0 --my-rs485-baudrate=9600
On Arduino I have these define lines:
#define MY_DEBUG
#define MY_DEBUGDEVICE Serial
#define MY_RS485
#define MY_RS485_HWSERIAL Serial2
#define MY_NODE_ID 1
#define MY_RS485_BAUD_RATE 9600
#define MY_RS485_DE_PIN -1
I'm not an expert on this by any means, but out of everything I tried, this is what worked for me. There are still some remaining issues:
Possibly due to line noise or voltage being low on Arduino, I've had one crash that made Arduino print gibberish on serial and it stopped transmitting anything at all.
I use Home Assistant and it seems to give up on MySensors if it doesn't receive anything in a while. Requires restart of HA core. Not very reliable.
I still welcome any insight into this process and any alternatives/recommendations. I'd like to make this as reliable as possible, but my knowledge of these systems and electronics is limited.
@BearWithBeard Thank you for sharing this great tip! - It works great and maybe finally I get my lightning detector working!
Thanks @mfalkvidd For putting this in with the docs where it will hopefully help others. We need more examples like this in a knowledge base to save time reading through lots of posts that are many years old.
@virtualmkr That is useflul to know - thanks! - As it happens I think I had my first wdt 'kick' early this morning as the Gateway with the wdt on was showing as up for 3 hours instead of the 4 days I was expecting, so it restarted and all is still working
Thanks ordered these from amazon, hoping to get a functional gateway out of them. I'll try to build it tomorrow according to specs and see if I can finally get some results.
50pcs 100uf 50V Radial Electrolytic Capacitor 8x12mm
ENC28J60 Ethernet LAN Network Module for Arduino SPI 51 AVR PIC LPC STM32
Makerfire 10pcs Arduino NRF24L01+ 2.4GHz Wireless RF Transceiver Module New
ELEGOO UNO Project Basic Starter Kit with UNO R3
Hello,
yes this is possible, here it is
https://www.mysensors.org/apidocs/group__RF24grp.html#gae6a732b8f49a8eb99ef65ae159c65e9c
and you may need to reinit transport layer at some point,
https://www.mysensors.org/apidocs/group__MyTransportgrp.html
https://www.mysensors.org/apidocs/index.html
@karlheinz2000 sounds great that you found the bug. It's always difficult to tell if it is a HW or SW bug on MCUs. From your first description it seems like a SW one to me.
@virtualmkr I have your sketches a quick look. Seems like you have debug enabled on the gateway. Esp8266 has to deal with WiFi stack &mqtt handling despite running on pretty high speed. This may introduce a lot of delays.
And my wild guess would be that that is enough for m328p to chew up.
I'll set up my 'staging' gateway in a radio noisy environment and give your test a spin this weekend.