Spresense Header CodeSpresense Header Code

Spresense - 低功耗下的边缘计算

在干电池供电的Spresense板上体验正真的边缘计算

!
无中文翻译

How to equip Spresense with LoRa connectivity

LoRa (Long Range) is a good connectivity option if your application requires longer range connectivity with low power consumption. However, the data throughput is relatively low and the transmission is bound to certain transmission slots. A suitable use case is to read simple sensor data that is not super time critical.

Equipping the Spresense main board with LoRa

It’s very easy to set up Spresense with LoRa and do a basic transmission. For this tutorial, we'll be using two Spresense main boards with a LoRa module on each board. One will be the transmitting side and one will be the receiving side with an Arduino sketch controlling each board.

List of components:

  • 2 Spresense main boards
  • 2 LoRa modules (for this example we’re using Adafruit RFM95W)
  • An 8.2 cm wire to solder on the LoRa module to use as the antenna

1Step 1

Cut a stranded or solid core wire to 8.2 cm length. Strip off 1-2 mm at the end of the wire, tin and solder it into the ANT pad on the LoRa board.

LoRa AntennaLoRa Antenna

2Step 2

Connect the LoRa module to the Spresense main board using the following pins:

LoRa Schematics PinningLoRa Schematics Pinning

3Step 3

To test LoRa with the Spresense board, we’d need some simple-to-use Arduino sketches fit for the purpose. Go to https://github.com/sandeepmistry/arduino-LoRa and download the ZIP.

In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library.

Navigate to the .zip file's download location on your computer and open it.

4Step 4

In the Arduino IDE, go to Open File > Examples > LoRa > LoRaReceiver.

To set up the communication between Spresense and the LoRa module, we need to add the following two lines of code before “LoRa.begin(915E6)”:

LoRa.setSPI(SPI5); // SPI of the Spresense main board rather than the extension board.

LoRa.setPins(18, 26, 25); // Pins connected to the LoRa module.

Lora Setup Code LinesLora Setup Code Lines

Upload this sketch to first Spresense board.

5Step 5

Next, Open File > Examples > LoRa > LoRaSender.

Add the same two lines of code for the sender sketch before “LoRa.begin(915E6)”:

LoRa.setSPI(SPI5);

LoRa.setPins(18, 26, 25);

Upload this sketch to second Spresense board.

6Step 6

Open the serial monitor connected to first Spresense board and set the baud rate to 9600. You should now see information being sent from the sending Spresense board to the receiving board through LoRa.

LoRa Serial CommunicationLoRa Serial Communication

For a more advanced LoRa communication with Spresense, please check out the “Spresense GPS tracker” project which tracks the Spresense unit on an online map: www.hackster.io/141676/spresense-gps-tracker-5e4fe8