Send Senser Datas via LoRa and Internet (IoT)

Posted by AlexChu, 20/11/2019

This is a demo project to show you how to use our Lora module + PsyFi32 board (ESP32 based) to make a LoRa + IoT project. The LoRa Dev Board (LoRa + Atmel Mega32u4) connects to a SHT31 temperature and humidity sensor, collects temperature and humidity data, and then sends the data out via LoRa module.


The other side uses a PsyFi32 board connected to a Lora module, that receives data from the sensor and updates the data to an IoT platform via internet; with this we'll be able to capture and log data to a ThingSpeak IoT Channel, and create various graphs.

 

Parts and components:

 

Connection:
As we've used Qwiic modules in this project, the LoRa Dev board and SHT31 sensor connections are super easy with just a couple of Qwiic cables. The Psyfi32 board and LoRa module connection (SPI) requires jumper-wire connections, you can refer to the following image, and table for the correct connections:

 

Psyfi32 Dev BoardLoRa module (Ra-01)
Pin 4IO0
Pin 25RST
Pin 26NSS
GNDGND
3V33.3V
Pin 18SCK
Pin 19MISO
Pin 23MOSI

 

Code

Please download the full code from this link. The "arduino-LoRa-master" is LoRa library, you'll need to add it into your Arduino library. "SHT31_32U4_LoraSender" is for LoRa dev board, "ThingSpeak_ESP32_SHT31_Lora" is for Psyfi32 board.


In the "SHT31_32U4_LoraSender" code, note that “field1” is for temperature, the “field2” is for humidity (Float values "t" and "h" respectively), so later in the ThingSpeak platform when you create fields in the channel, remember "field1" needs to be temperature, and "field2" humidity.


Next, in the "ThingSpeak_ESP32_SHT31_Lora" code, since the PsyFi32 board is based on ESP32 MCU, you'll need to choose ESP32 as your dev board in the Arduino IDE.

 

You will also need to change the internet setting (Router name and password) and the ThingSpeak channel ID here.


In this demo, we'll write data to a ThingSpeak channel, so we'll need to use the “Write API Key”. Refer to comments within the code on what to do with the API Key.

 

 

Next we'll set the fields for our data, as we mentioned previously with, our demo code. Field 1 is temperature, Field 2 is humidity.  

 


Thingspeak IoT is an extremely easy and intuitive tool, with tons of tutorials on YouTube if you want to learn more. Just setup a free account, create a channel and channel ID, then use this ID in the Psyfi32 code, and you're good to go!

 

 

Leave a Comment