IOT ProjectsLORA PROJECTSSTM32

Lora SX1278 and STM32 based Temperature and Humidity Monitoring using Arduino IDE

Lora SX1278 and STM32, Description:

 

In my previous tutorial, I interfaced the DHT11 Temperature and Humidity Sensor with the STM32F103C microcontroller board and displayed the temperature and humidity values on the I2C supported SSD1306 Oled display Module. Today, I am going to modify this project by adding the Lora SX1278 long range wireless transceiver module.

Lora SX1278 and STM32

allpcb circuit


So, on the transmitter side I am using the Lora SX1278 with the STM32 and on the receiver side I am using the Lora SX1278 with the Arduino Nano. You might be thinking why STM32 on the Transmitter side and Arduino Nano on the receiver side? The answer is pretty straightforward, if you have been using Arduino boards then you should know the Arduino boards hangs a lot in the long run and for me it’s quite difficult to go and manually reset the Arduino board, so I decided to use the STM32F103C which is very fast as compared to the Arduino boards, stm32 may also get stuck but not as frequently as the Arduino boards. The reason I am using Arduino on the Receiver side is that, I have only one STM32 controller board, and moreover the receiver side will be in my room, and I will use it with my laptop to monitor the temperature and humidity values on the Serial monitor. So, most of the time the receiver side will be OFF. But the transmitter will remain ON. As the transmitter will remain ON for months so there is a high chance of the stm32 may get hanged, so this issue can be solved by using the watchdog timer, so if the stm32 gets hanged for the predefined time, the stm32 will automatically reset. I will make another tutorial about this, for now let’s forget about the watchdog timer.

So, before I am going to explain the Lora SX1278 interfacing with the STM32 and its programming; first let’s practically see how this system works. So, let’s go ahead and start with the Transmitter side.

Lora SX1278 and STM32

You can clearly see the Temperature and Humidity values on the Oled display module. As, I am near to the transmitter side, so there is no need to use the receiver, I can directly read the Temperature and Humidity values. Now, let’s say I am away from the transmitter then I can connect my receiver circuit with the laptop and then using the Serial monitor I can read the temperature and humidity values.

Lora SX1278 and STM32



You can see the temperature and Humidity values are comma separated, I used comma as the delimiter which will help me in splitting the values.

Lora SX1278 and STM32

In the next example I will convert this into a Lora Gateway that is we will be sending the temperature and humidity values to the IoT platform and this way we will be able to monitor the temperature and humidity values from anywhere in the world. Without any further delay let’s get started!!!


Amazon Links:

LoRa SX1278 Module

STM32F103C

DHT11 Temperature and Humidity Sensor

Arduino Nano

Arduino Uno

SSD1306 128×64 Oled i2c display Module

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


Transmitter side circuit diagram:

Lora SX1278 and STM32

This is the transmitter side circuit diagram which explains how the Lora SX1278, DHT11, and Oled display modules are interfaced with the STM32 microcontroller board. A 10K ohm resistor is connected between the VDD and DATA pin of the DHT11 Temperature and Humidity Module.

The SSD1306 Oled display module Power supply pins are connected with the 3.3V and GND pins of the STM32 microcontroller board. The SCL and SDA pins of the Oled display module are connected with the B6 and B7 pins of the STM32. B6 is the SCL and B7 is the SDA.

The VCC and GND pins of the Lora module are connected with the 3.3V and GND pins of the STM32 controller board. MISO pin is connected with PA6, MOSI pin is connected with PA7, SLCK pin is connected with PA5, and the NSS pin is connected with the PA4 pin of the STM32. So, that’s all about the Transmitter side circuit diagram. Now, let’s take a look at the receiver side circuit diagram.


Receiver side circuit diagram:

Lora SX1278 and STM32

The VCC of the LoRa module is connected with the 3.3V of the Arduino. The MISO Pin of the LoRa module is connected with the Arduino’s pin 12. The MOSI pin is connected with the Arduino’s pin 11. The SCLK pin of the SX1278 LoRa module is connected with the Arduino’s pin 13. The NSS pin is connected with the Arduino’s pin 10 and the ground pin of the LoRa module is connected with the Arduino’s GND.

In the circuit diagram you can also see the SSD1306 I2C supported Oled display Module. I added this if incase you want to print the values on the Oled display module. The VCC and GND pins of the SSD1306 Oled display module are connected with the Arduino’s 3.3V and GND pins. The SDA and SCL pins of the Oled display module are connected with the Arduino’s I2C pins A4 and A5.

On the top you can see is the 5V regulated power supply based on the 7805 voltage regulator. You will need this power supply if you want to power up your Arduino using an external 12V power supply or a solar panel.



STM32 with Arduino IDE:

In order to program the STM32 microcontroller board using the Arduino IDE, first you will need to flash the bootloader, and you will also need to install the STM32 board, and some drivers. I have a very detailed tutorial on this and I highly recommend you should read this article. Now, let’s take a look at the programming. Now, let’s take a look at the programming.

Arduino Libraries:

Download: LoRa.h

Download: Adafruit_GFX.h

Download: Adafruit_SSD1306.h

STM32 Libraries:

Arduino Lora STM32 Library:

DHT Library for STM32:

STM32 and Arduino Programming:

As this project is based on the wireless communication so, we have two programs, one program is written for the Transmitter side and the other program is written for the Receiver side. So, let’s first start with the Transmitter side programming.


STM32, SX1278 Lora, and DHT11 Programming:


As you can see, this is the same exact program from my previous tutorial, this time I added code for the Lora SX1278 module. I started off by adding the library and defined some pins and variables.

Inside the loop() function,

I only added this code which sends the humidity and temperature values. If you find it confusing then you can watch my complete series of videos on the Arduino and Lora SX1278. The programming style of the Arduino and STM32 is almost the same. Now, let’s take a look at the receiver side programming.


SX1278 Lora Arduino Programming:

On the receiver side, I didn’t even change a single instruction. This is the same exact program which I explained in my Arduino and Lora based getting started tutorial. So, that’s all for now.



Watch Video Tutorial:

 

Related Articles

3 Comments

  1. Your needs come first! Purplewaveindia has no agendas, and no loyalties to anyone other than you, our client. Purplewaveindia was established in 2018. And in a short span of 4-years, Purplewaveindia has become one of the prominent players in the Indian Audio Video Manufacturing and Integration Industry.

  2. Hello! Could you make changes to the receiver sketch to connect the SSD1306 Oled and display the data received on it? Your project is amazing, don’t abandon this project because you can add functions for turning on a relay (fan or heater) and feedback that controls the operation of these relays. My knowledge is only enough to repeat your project, and not change it. Good luck to you!

  3. Hi,
    Thank you for this post, its very good example to start lora communication with different platform,
    I tried and its working for me,

    My question, from Tx side, can I use stm8l ic to send data Arduino based Rx.
    For reference of stm8l with lora, I want to use “https://github.com/Exboom/LoRa_STM8/tree/master”

    Please suggest.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button