I have a Raspberry Pi 3B+ Buster (RPi) set up with a Modbus device working fine through Nodered read and write. The system is hard wired like this RPi—USBxRS485---ModbusRTU device slave (MDS). RPi works as Master and MDS as slave.
Now I want to go a step further to split the hard wired connection into and remotely read write over LoRa Node to LoRa node in this manner.
RPi1 + LoRa1 HAT Serial ttyS0 (Master Nodered) @@@@@wireless@@@@@@ LoRa2 HAT Serial ttyS0 (Slave Nodered)+RPi2—USBxRS485---MDS.
I have the serial enabled on raspi-config on both RPis and the LoRa HATs 1 & 2 communicate transparently and perfectly well. I am just not able to get the Nodered Red Flows right on the Master and Slave RPi to be able to interchange Modbus Read and Write Commands wirelessly over LoRa.
Have been trying to do work on it for many days now but just not able to get it right. RPI1 sends Modbus Read Hex Data to RPI2 (Slave address1, FC3, holding register 256) to RPi2 and I can see the Hex data come in perfectly on the RPi2 terminal. I do not have any idea of how to further fetch this incoming Hex data, send it to the MDS over serial, read and send msg.payload back to the Master RPI1 over LoRa (as if they are working perfectly hard wired mentioned in para1). I do not intend to use LoRaWAN Gateway, my aim is to use only LoRa node to LoRa node transparent communication. Any one has suggestion or example flow of how to achieve this?
I can see RPi2 this object coming in on the terminal sudo cat /dev/ttyS0:-{"fc":3,"unitid":1,"address":256,"quantity":1}
But when I use the "serial in" node set to /dev/ttyS0 on Node-RED. It shows green, serial port connected but do not see anything coming out of the debug node. Not sure why?
What LoRa Hat are you using ? link to product would help
Assume your are using AT commands ?
If so what is your "Split input" setting
\n = Line Feed
\r\n = Carriage Return Line Feed
@iiLaw . Using Waveshare LoRa HAT on each Raspberry Pi 3B+ (Master RPi1 and Slave RPi2).
'''SX1262 LoRa HAT for Raspberry Pi, Spread Spectrum Modulation, 868MHz Frequency Band'''
Managed to send and receive over LoRa based on your suggestion but there is an issue at the end:
- RPi1- Master Send to slave Modbus instruction fc=3, unitid=1, holding register address=256, qty=1 over ttyS0, 9600,8N1 is fine
- RPi2 - Slave Receive over ttyS0 then reads from device using Modbus Flex Read from ttyUSB0 is fine, reads 302 (30.2degC)
- RPi2 - Slave Send back value 302 to Master over ttyS0 is fine
- RPi1 - Master Receive Reply is NOT FINE, received message but shows as split message separated character by character on the debug window (see debug window on the picture)
How do I resolve this? Tried many options but could'nt get it right.
Ok you need to play with the split options as you NOT set any Master Receive Reply input node
If you always have a fixed number of characters coming back you can use
"into a fixed length of"
Or you can set
"after a timeout of" try 10 ms e.g. 10ms after first character arriving
"after a silence of" try 10 ms
You are nearly there just keep testing the options on Master Receive
Finally got it. Used "Join" + "Change" node from String to Number and it worked. Thank you.
Hi @Mansur,
I also have a project that I want to do with the SX1262 on Pi4 but the node that will talk to it is a Maduino LoRa Radio v2.0.
The Maduino is configured with the Transmit example code.
I need a bit of assistance with the SX1262 side. Did you still have to use the Python Code outside of Node-red or were you able to do everything in Node-red?
Any guidance will be much appreciated.
Hi @hermannvos,
I purely used Node-RED nodes to communicate between the two SX1262 modules on my experiment.
The trick is to get both Radios talk to each other with matching serial and radio configurations. Once they are able to talk to each other, then you can configure nodes on Node-RED to transmit and receive data as if they are physically connected. As a matter of fact you may also use python codes to do so as long as they are able to communicate with each other. The pictures on my previous posts on this thread shows which nodes I used on the flow.
Steps:
- Configure SX1262 and Maduino independantly using proprietary/recommended softwares to match the radio and serial configurations.
- Connect them both to your Laptop on USB ports. For example RPi4+SX1282-----USB1 and Maduino-ttlxUSB----USB2. Open two serial terminals (SSCOM or Arduino Serial console) each separately connected to USB1 COMM port and USB2 COMM port. Try to send messages in either direction from the dedicated serial terminals. Once you are able to send data back and forth, then you are all set to go. Then you can use any method such as Node-RED or python or any other platform, it does not matter as long as the virtual radio pipe is connected over the air. I have not used Maduino (ATMega328+RFM9xW) but I am sure it should work as long as the LoRa frequencies match.
Hope I have understood your question correctly and have replied to what you were looking for, If not please feel free to write again.
Hi @Mansur,
Thank you for your reply and help. I couldn't get the RF96 chip to talk to the SX1262 chip as they are setup differently and after trying a few times to get it to work we decided to get another Maduino to connect via USB to the Pi and it is working. Thank you again for the assistance and insight.
, Good to know it worked
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.