Low-cost-LoRa-IoT-step-by-step
Low-cost-LoRa-IoT-step-by-step
a step-by-step tutorial
2
Assembling the hardware
3
Get the Arduino board
You can get the original board designed by Sparkfun or get one of the various clones
available mainly from Chinese manufacturer. The last solution is very cost-effective as the
Pro Mini board can be obtained for less than 2€ a piece. Some boards may not be working
as reported by some people but in my own experience, all the boards I got from Chinese
manufacters have been working great.
4
Prepare the board (1)
When you receive the board, it will probably come with the appropriate
header pins that must be soldered to the board. Just use a regular soldering
station to solder the header pins to the board. The 6-pin header on one side
of the board (see red rectangle) will be used to connect an FTDI cable to
program the board. This will be explained in the « software » section.
5
Prepare the board (2)
You can solder a row of header pins (left) on the ground pin (GND) in order
to have several ground pins for the various sensors that will be connected
to the device. But don’t forget to link all the pins together to get the GND
signal on all the pins (right).
6
Now the radio module (1)
GND
CS
CLK
MISO
MOSI
VCC
If you go for the inAir9 from Modtronix, then the header pins can come fully assembled.
Order with the 6mm header pins to have enough length to connect F/F breadboard
cables (left). Connect the SPI pins with the F/F cables. Try to use different colors. I use
the following colors: MOSI (blue), MISO (green), CS (white), CLK (orange). Then
connect also the VCC (red) and the GND (black or any other dark color) of the radio
board. 7
Now the radio module (2)
GND
MISO
MOSI
CLK
CS VCC
https://github.com/CongducPham/LowCostLoRaGw
10
Connecting the radio
module
GND CAUTION: the radio
module needs 3.3v, not 5v!
Most of Arduino boards
have a 3.3v pin so you can
use this pin to power the
radio module. Example wth
an Arduino Nano:
MISO
CLK
CS
MOSI
VCC
3.3v
GND
CS
Now, just connect the corresponding SPI pins of the radio module
to the SPI pins on the board. MOSI (blue) is pin 11, MISO (green)
is pin 12, CS (white) is pin 10 and CLK (orange) is pin 13 (left
picture). Then connect also the VCC (red) and the GND (black) of
the radio board to the VCC and the GND of the board (right
CLK
MISO
MOSI
VCC
picture). The VCC of the board gets 3.3v from the on-board
voltage regulator.
11
Connecting the radio
module on other boards
13
Low-cost integration
with simple, free PCB
1.5€ https://github.com/CongducPham/LowCostLoRaGw#pcbs
https://github.com/hallard/Mini-LoRa
14
Boards with integrated
LoRa radio module
15
Getting, compiling &
uploading the software
16
Getting the software
Fisrt, you will need the Arduino IDE 1.6.6 or later (left). Get the entire ZIP archive of the
LowCostLoRaGw github repository at https://github.com/CongducPham/LowCostLoRaGw
Unzip the archive and copy the content of the Arduino folder in your Arduino IDE sketch folder
If you already have a libraries folder in your sketch folder, copy the content of the new libraries
folder in your libraries folder
17
Compiling
Open the Arduino_LoRa_Simple_temp sketch and select the Arduino Pro Mini board with its 3.3V
& 8MHz version.
18
Uploading (1)
Some clone version, check the VCC pin
VCC
For the Pro Mini, you need to have an FTDI breakout cable working at 3.3v level (there is also 5v
version but our advised Pro Mini version is running at 3.3v to reduce energy consumption). Be
careful, on some low-cost Pro Mini version (Chinese manufacturer for instance) the pins may be
in reversed order. The simplest way in to check the VCC pin and make it to correspond to the
VCC pin of the FTDI breakout.
19
Uploading (2)
Connect the USB end to your computer and the USB port should be detected in the Arduino IDE.
Select the serial port for your device. It may have another name than what is shown in the
example. Then click on the « upload » button
20
Generic behavior
setup
Physical Physical Physical
sensor sensor sensor measure
reading reading reading xxxxxx
(encrypt)
transmit
wake-up
AES Long-range Logical sensor
encryption transmission management
21
Serial monitor and checking
that device is sending
You can see the output from the sensor if it is connected to your computer. Use the Arduino IDE
« serial monitor » to get such output, just to verify that the sensor is running fine, or to debug new
code. Be sure to use 38400 baud. If you get the "Packet sent, state 0" result, it is most likely that
your device is sending OK, but to be sure, you need to check data reception on the gateway.
22
Setting PA_BOOST
More to come…
Adafruit Feather 32u4/M0
Arduino Due
Arduino MEGA2560 w/Libelium
Arduino Uno Multiprotocol shield
Arduino Due
26
Temperature sensor
OUT
VCC
VCC
GND
RADIO
OUT
For the moment, there is no physical sensor connected to the board, so you will probably get
random value when running the sensor. The Arduino_LoRa_Simple_temp example uses the
LM35DZ physical sensor to get the ambient temperature. The GND should be connected to one
of the board’s GND, the VCC should be connected to digital pin 9 and the OUT pin should be
connected to the analog A0 pin.
27
Understanding analog
output
If 0 means 0V and 1024 means 3300mV (10-bit resolution) then 3300mV/1024=3.22mV is the
granularity of the measure
28
Reading analog pin value
OUT
value = analogRead(A0);
29
Generalization
30
Several physical
sensors per device
For specific sensors, get_value() will simply use specific provided/developped library
31
Running on battery &
using low-power mode
32
Connecting a battery
- +
Remove the power led
GND
VCC
GND
VCC
as explaine here:
http://www.home-automation-community.com/arduino-low-power-how-to-run-atmega328p-for-a-year-on-coin-cell-battery/
The advantage of using the Arduino Pro Mini running at 3.3v is that energy consumption can be
low especially when the board is put in « sleep mode » for low-power operation. Remove the
power led to further reduce consumption.
You can use 4 AA batteries to provide 4x1.5v=6v. Using only 3 batteries may lead to insufficient
voltage difference.This will be injected into the RAW pin of the board, therefore using the on-
board voltage regulator to get the 3.3v.
33
Compiling for low-power
34
Reducing further power
consumption
35
Running for several
years!
Low-Power library from RocketScream
Wakes-up every
10min, take a
measure (temp) and
Can run for more than 1 year send to GW
with 1 measure/10min
37
Default configuration
\!##TC/18.5
#define DEFAULT_DEST_ADDR 1
#define LORAMODE 1
#define node_addr 6
38
Securing with
Application Key (1)
40
How to use app key
41
Securing by encryption
(1)
42
Securing by encryption
(2)
43
Securing by encryption
(3)
44
Gateway to cloud
Data received at the gateway will be pushed to IoT clouds. We provide python script examples
for many IoT cloud platforms. Most of clouds with REST API can be easily integrated.
45