Arduino with Ethernet Shield and LoRa Shield

Hi,

I’m trying to build a LoRa Gateway to Blynk with an Arduino Uno, Ethernet Shield and LoRa Shield (Dragino). So, I tested all components by themselves – they work fine. My concern now is to get it running with everything in place. Since the LoRa and Ethernet share the same SPI pins, I must select the device with the chip select (CS) pin.

The idea is, to get any interrupt on new messages from the LoRa device, set a flag, call some Blynk code and then wait again for new messages.

What I did is: setup inits the devices, sets interrupts, interrupt sets flag for loop, loop calls code for transmitting the message value if flag is set.

This doesn’t work as expected – I set the CS pins manually high and low (OFF and ON) so I can use ethernet or LoRa. When I do this, Blynk gets disconnected and crashes at some point. If I don’t set the CS pins, nothing works (both devices talk to the MCU on SPI).

Is there any advice on this? I can also share my code, but I just wanted to explain the context, so maybe someone can help in theory. If I know what to do, coding isn’t the problem, I guess.

Thanks

When Blynk runs on your Uno it needs to be able to constantly communicate with the Blynk server. This is so that the Uno knows when a change of state is made to a widget in the app (a button widget is pressed, or a slider widget is changed etc.).
If the Blynk server and Uno haven’t done a heartbeat handshake with each other for 10 seconds then the server will show the Uno as disconnected, and the Uno will attempt to reconnect with the server

Your hardware setup allows the Uno to only communicate with either the LoRa shield or the Ethernet shield at any one time. To listen for LoRa data, and trigger an interrupt when some data arrives, the Uno needs to have the LoRa shield selected, and the Ethernet shield disconnected. This will disconnect Blynk, and depending on how you’ve written the code then Blynk and LoRa could be trying to run simultaneous operations on the Uno - which could easily crash your device.

In theory I guess you could constantly switch between the LoRa and Ethernet shields, but in practice that isn’t going to end well.

A much better hardware platform for what you are trying to achieve would be one of the ESP32 + LoRa dev boards, but even then there are some programming challenges.

Without knowing what exactly this project is for, and where it fits into the overall infrastructure that you are creating, its difficulty to advise on the best solution.

Pete.

1 Like