ESP8266 Lora Gateway for STM32 and DHT11 Sensor, IoT Gateway

(Last Updated On: November 21, 2021)

ESP8266 Lora Gateway, Description:

ESP8266 Lora Gateway

ESP8266 Lora Gateway for STM32 and DHT11 Sensor, IoT Gateway- Before, I am going to explain how to make your own ESP8266 Lora Gateway; first, I am going to talk about my previous tutorial, because today’s tutorial is entirely based on my previous tutorial. So, in my previous tutorial I explained how to interface the Lora SX1278 with the STM32 and Arduino Nano.

ESP8266 Lora Gateway

On the Transmitter side I used the Lora SX1278 with the STM32 and on the receiver side I used the same Lora SX1278 with the Arduino. So, it really doesn’t matter which controller board you use on the receiver side. To explain this, today, I will replace the Arduino Nano with the Nodemcu ESP8266 WiFi module to convert it into ESP8266 Lora Gateway. Anyways, in this tutorial, I was simply sending the temperature and humidity values from the transmitter side (which is based on the STM32, Lora SX1278, DHT11, and I2C supported Oled display module) to the receiver side (which is based on the Arduino Nano and Lora SX1278 module).

ESP8266 Lora Gateway

To separate the Temperature and Humidity values I used comma as the delimiter, and today you will practically see how we split the two values on the receiver side and then how these values are sent to the IoT Platform.


Today, we are going to make an IoT gateway for this STM32 based Temperature and Humidity project. We will go with the same project, the transmitter side will remain exactly the same, we are not going to change anything on the Transmitter side. But on the Receiver side we will replace the Arduino Nano with the Nodemcu ESP8266 WiFi Module with the help of which we will send the temperature and humidity values to the Blynk IoT platform and this way we can monitor the temperature and humidity values from anywhere in the world. So, before I am going to explain the interfacing and programming, first, let’s watch the ESP8266 Lora Gateway in action.

ESP8266 Lora Gateway

You can clearly see the transmitter side (LoRa Node) is exactly the same. The DHT11 Sensor, Lora SX1278, and the same Oled display modules are still connected with the STM32 microcontroller board. You can directly read the temperature and humidity values on the Oled display module when you are near to the Transmitter side or the LoRa Node. But if the same LoRa Node is installed at a different location where you have no access to the internet or you have multiple LoRa Nodes then, first you will need to transmit the sensors data to the LoRa Gateway and then from there you can send the sensors values to the IoT Platform which in my case is the Blynk application. For now, you can only see the values on the Oled display module.

Let’s go ahead and turn ON the ESP8266 Lora Gateway, you will get the notification as soon as the Nodemcu ESP8266 is connected with the WiFi, then you can simply click the play button on the App and you are good to go.

ESP8266 Lora Gateway

The same values which you can see on the Oled display module are also displayed on the Gauges. So, how it’s doing this? The STM32 sends a message consisting of the comma separated Temperature and Humidity values to the ESP8266 Lora Gateway. The Gateway splits the message using comma as the delimiter and store the sensors values in variables and then finally the values are sent to the Blynk IoT Platform. Now with this setup I can monitor the Temperature and Humidity values from anywhere in the world. You can connect multiple Lora Nodes with the Lora Gateway which I have already explained in my previous tutorial. Anyways, my ESP8266 Lora Gateway is working perfectly; you can go ahead and replace the DHT11 sensor with other sensors as per your requirement. Now, you have got an idea of what you are going to learn after reading this article. Without any further delay, let’s get started!!!

Altium Designer:

775 Motor

Altium Designer is the world’s most trusted PCB design system. Altium Designer enables engineers to effortlessly connect with every facet of the electronics design process. Over 35 years of innovation and development focused on a truly unified design environment makes it the most widely used PCB design solution. With Altium Designer you can create PCB designs with an intuitive and powerful interface that connects you to every aspect of the electronics design process. Route it your way through any angle, tune for delay, Push, Slide, and Walkaround faster than ever. Interact and collaborate with mechanical designers like never before in a photo-realistic, 3D design environment. If you want to get started with the Altium designer, you can click on the get started.



Amazon Links:

LoRa SX1278 Module

STM32F103C

Nodemcu ESP8266 WiFi Module:

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!


Lora SX1278 Interfacing with STM32:

ESP8266 Lora Gateway

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 circuit diagram of the ESP8266 Lora Gateway.


ESP8266 Lora Gateway Circuit Diagram:

ESP8266 Lora Gateway

This is the circuit diagram of the ESP8266 Lora Gateway. The MISO pin of the Lora SX1278 Module is connected with the D6 pin of the Nodemcu ESP8266 WiFi Module. The MOSI pin of the Lora module is connected with the D7 Pin. The SLCK pin is connected with the Nodemcu ESP8266 pin D5, and the NSS pin of the Lora SX1278 Transceiver module is connected with the pin D8 of the Nodemcu ESP8266 module. While the VCC and GND pins of the Lora module are connected with the 3.3V and GND pins of the Nodemcu module.

On the top is the 5v regulated power supply based on the LM7805 voltage regulator. You can use this regulated power supply to power up your Nodemcu module using a 12V adaptor or a solar panel. Don’t forget to add these 470uF decoupling capacitors at the input and output of the 7805 regulator. Now you have multiple options, you can use an adaptor, or you can use a power bank, or you can also use a cell phone charger. So, that’s all about the circuit diagrams.


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. You will also need to install the Nodemcu ESP8266 board in the Arduino IDE. Now, let’s take a look at the programming.

Lora library for ESP8266:

Download: LoRa.h

STM32 Libraries:

Arduino Lora STM32 Library:

DHT Library for STM32:

ESP8266 Lora Gateway Programming:

As this project is based on the wireless communication so, we have two programs, one program is written for the Transmitter side (Lora Node) and the other program is written for the Receiver side (ESP8266 LoRa Gateway) which is the Master Node. So, let’s first start with the Transmitter side programming.



STM32 DHT11, Transmitter Side Programming:

As I said earlier, I am using the same transmitter connections and the same programming and as you can clearly see, I have not even changed a single instruction. For detailed explanation read my previous article. Now, let’s take a look at the ESP8266 Lora Gateway programming.


ESP8266 Lora Gateway, Receiver Side programming:


Code Explanation:

This is the same LoRa library which I have been using with the Arduino. This LoRa library also works with the Nodemcu ESP8266.

Next, you will also need to add these two libraries if you are using ESP8266 controller board and the Blynk application.

This is the Authentication token which you get while making the Blynk application.

These are the WiFi credentials.

I also defined two variables of the type float for storing the humidity and temperature values.

The code which you can see inside the setup() function is exactly the same code as explained in my previous Lora based projects. This time I only added Blynk.begin(auth, ssid, pass); this line of code.

Inside the loop() function we run the Blynk and rest of the code is from my multiple sensors monitoring project the only modification is the addition of these two instructions

Which are used to send the humidity and temperature values to the Blynk application using the virtual pins V2 and V3.

The getValue() function is a user-defined function and I have been using it for years in different projects for splitting the sensors values and string messages. So, that’s all about the programming.



Blynk App for the ESP8266 Lora Gateway:

For the Blynk application designing watch my video tutorial given below. Or you can do it yourself, all you need is to add two gauges and assign the virtual pins V2 and V3.

Watch Video Tutorial:

 

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

%d bloggers like this: