Ever wondered how to get Arduino to communicate wirelessly over hundreds of meters? Ever wanted to create a small IoT device, but then bit discouraged by just how much power the long range communication takes? Or do you just want to build a robot that could be controlled from your comfy chair while it drives outside and explores the world? Well, there is a solution! Here I present to you “LoRenz – Arduino shield” that can do all of that and much more. And the best part of LoRenz is that both the software AND the hardware are completely open-source!
2x Arduino UNO/Mega
2x LoRenz Rev. B shield and module breakout board (Eagle and Fritzing files available on GitHub)
2x SX1278 module
What exactly can this shield do? It is compatible with both Arduino UNO and Mega, and provides means of communication over several hundreds of meters, while keeping the power cost as low as 80 mA while transmitting. That is about as much as 5 average LEDs – all of that packaged together with a library that makes the whole thing extremely easy to use, even for beginners. Really! You want to send a message? Type a command! Boom, done!
Before we get started, there is something that has to be said: even though LoRa technology operates in the license-free bands like 433 or 868 MHz (usually called ISM – Industrial, Scientific and Medical), some legal restrictions may apply in your area of residence. These may include power output restrictions, bandwidth limits, or even restrictions on the type of data you can transmit and receive. Since I don’t know which state or country you live in, I can only give you the most general advice:
Always follow the current legal regulations in your area of residence!
Neither the author, nor DevicePlus.com takes any responsibility for your actions while using LoRenz shield or LoRaLib.
Now that we have the legalities out of the way, let’s start at the core of this shield functionality – the LoRa modulation.
LoRa – an obvious shorthand for Long Range – is a clever type of modulation of electromagnetic signals. Modulation of a signal is itself a really clever way of encoding more information into wireless signals. Different types of modulation have been around for quite a while, in fact, they date back all the way to the late 1800s and the invention of the radio. In fact, most people are familiar with the term modulation precisely because of radio: ever heard of AM (amplitude modulation) or FM (frequency modulation)? With amplitude modulation, the information is encoded by changing the amplitude of the carrier wave. Similarly, with frequency modulation, only this time, the frequency of the carrier wave is being changed. The main reason for using modulation is that we can “fit” low-frequency information – like voice or music – into a high-frequency carrier wave.
Figure 1. Amplitude and frequency modulation
So then, which one of these is LoRa? Well, none of them. LoRa is a different type of modulation, although it shares some similarities with FM. LoRa is actually a CSS – Chirp Spread Spectrum modulation. The technology itself is proprietary and patented, but the basic principle is that information is encoded using chirp – a gradual increase or decrease in the frequency of the carrier wave over time.
Figure 2. Chirp spread spectrum modulation
This modulation is extremely resistant to noise and even to the Doppler effect, making it really useful when communicating over long distances using low power. Fortunately for us, modules incorporating this technology are very cheap and easily available. The most widely used one is the SX1278 chip manufactured by Semtech and modules with this chip can be bought as cheap as 7 USD. Just google the phrase “SX1278 module”, I’m sure you’ll see a lot of shops selling them.
Now that we have a basic idea of what LoRa is and how to get it, let’s take a look at the shield itself – for start, how do you actually get your hands on one?
Unfortunately, you can’t just buy one of these shields in a store, simply because no one is actually producing them. This shield is completely custom, so if you want to get one, you will have to download the Eagle files from my GitHub, buy all the components, get a PCB manufactured somewhere and solder everything together. The total price for components on this shield should be around 20 USD, so it’s not the most expensive shield out there. In fact, while I was developing this, the most expensive part was actually shipping the PCBs. But even including that, the total price per one shield should not exceed 30 USD – depending on where you live, of course.
Let’s go through all the parts on this shield, to see what they actually do:
3.3 V power regulator. Because Arduino onboard power source can only provide 150 mA of current, I decided to add a separate 1117 regulator, which will be able to provide at least 800 mA. This gives us much more power than we should need in theory, but it’s always better to have some extra.
Screw terminal. This terminal allows you to power the shield with virtually any type of battery! The accepted range is 6 – 20 V, however, this will also power the Arduino, so I suggest using batteries between 7 and 12 V.
UNO/Mega header. The SX1278 modules use SPI bus to communicate with Arduino. On Arduino UNO, SPI is located on pins 10 – 13, but on Mega, it is moved to 50 – 53. I wanted to make this shield as universal as possible, so I added this pin header. When using Arduino UNO, just leave all three pairs shorted out. When you need to use Mega, remove the shorting jumpers and connect the pins just like you see on the following picture.
Figure 3. Connecting LoRenz shield to Arduino Mega.
Slave select header. This might be a bit of an overkill, but what if you for whatever reason wanted to use more than one LoRenz shield on a single Arduino? Well, you can use up to four (!) shields! Just short a different position on each of them.
SX1278 module slot. This slot allows you to connect any type of SX1278 module to this shield. Just make sure it uses 3.3 V power. I recommend using precision headers for the slot, to keep the overall shield height down.
Logic level converters. As far as I know, all the SX1278 modules currently on the market use 3.3 V logic. When interfacing 3.3 V stuff with 5 V Arduino, it’s always better to have some sort of logic level conversion going on. That’s what these two ICs do. One of them converts Arduino output from 5 V to 3.3 V, the other converts SX1278 output from 3.3 V to 5 V. The resulting system is extremely robust, even when the battery power starts to reach the lower thresholds.
Indicator LED. To get some sort of an indication when the SX1278 is being active, there is a spot for LED on the shield.To enable the LED, you also have to short the EN pads with solder. If you then decided that you don’t need the LED indication anymore, just remove the solder from EN pads and the LED will no longer consume precisou milliamps of current.
Prototyping area. I had a bit of extra space left on the shield, so I added a prototyping area, just in case you wanted to add some extra stuff to the shield. And to make your life even easier, there are 3.3 V, 5 V and GND connections in the area itself!
Figure 4. LoRenz Rev.B shield
Another part you will need is what I call a breakout board. Since there are several different types of SX1278 modules on the market, we need some sort of an “adapter” to allow you to connect any of them to the LoRenz shield. That’s where this little guy comes in. The breakout board is a PCB onto which you solder the SX1278 module and then simply insert the whole thing into the slot on the shield. These breakout boards also feature a small connector for coaxial cable, so you can connect an external antenna for even longer range!
Figure 5. Empty breakout board (left) and breakout board with SX1278 module soldered onto it (right).
All of that sounds pretty good, right? Well, there’s still one more very important part missing. Hardware is usually pretty useless without software. In the next part, I’ll introduce LoRaLib, an open source Arduino library I developed for the SX1278. With its user-friendly API, we can start experimenting with LoRa communication.
Jan is currently studying Electrical Engineering at Brno University of Technology. He has many years of experience building projects using Arduino and other microcontrollers. His special interest lies in mechanical design of robotic systems.