Arduino ProjectsESP8266IOT ProjectsLORA PROJECTS

ESP8266 LoRa Gateway for Arduino and LM75 Temperature Sensor

ESP8266 LoRa Gate, Description:

 

ESP8266 LoRa Gateway for Arduino and LM75 Temperature Sensor- In this article, you will learn how to make ESP8266 LoRa Gateway for Arduino and LM75A I2C supported temperature sensor. Since this is an IoT or internet of things based project; so the temperature can be monitored from any part of the world provided if the internet connection is available.




allpcb circuit

For this project, you will need an Arduino board, it depends on you which Arduino board you select, you can use Arduino Uno, Arduino Nano, and Arduino Pro Mini. These are available in different sizes, so if you are planning on reducing the project size and cost then you can go for the Arduino pro mini. But in my case, I will continue with the Arduino Nano and I will use my designed development board.

ESP8266 LoRa Gateway

You will also need an ESP8266 board, again you have two choices, you can use Nodemcu ESP8266 WiFi Module or you can use the Mini D1 version of the ESP8266 WiFi module. You may also call this as the mini Nodemcu ESP8266 WiFi module. The only difference between the two boards are d1 mini is smaller in size, it has less IO pins, and is obviously low-cost. The programming is 100% the same. Any program which is written for the Nodemcu ESP8266 WiFi module will also run on the D1 Mini version of the ESP8266. Just don’t use the pins which are not available in D1 Mini version of the ESP8266. So, for this project, I will use this Mini version of the ESP8266 WiFi module.

You will also need a pair of SX1278 LoRa transceiver modules, SSD1306 I2C supported Oled display module, an LM75A temperature sensor that supports I2C communication, I have already explained this sensor in quite a detail, and you will also need a 5V Buzzer which is optional.

ESP8266 LoRa Gateway

Anyway, here is a prototype model of my ESP8266 LoRa Gateway for Arduino and LM75 Temperature Sensor, I have connected everything as per the circuit diagrams which I will explain in a minute.



On the right side is the transmitter, along which an LM75A temperature sensor, SX1278 LoRa transceiver module, and SSD1306 Oled display module, are connected with the Arduino Nano. The Arduino reads the LM75A temperature sensor and prints the temperature reading in Celsius and Fahrenheit on the Oled display module and the same time it also sends the temperature readings to the remote side receiver using the LoRa.

And on the left side is the receiver’s. ESP8266 D1 mini has been connected with a 5V buzzer and an SX1278 LoRa transceiver module. This is the ESP8266 LoRA Gateway. The ESP8266 takes the temperature readings from the LoRa and then sends these readings to the Blynk application which is an IoT platform.

You guys might be thinking, that the same thing can be done while only using the ESP8266 WiFi module. We can directly connect the LM75A temperature sensor with the ESP8266 and then we can send the temperature readings to the Blynk IoT platform. If you guys are thinking in the same way then you are 100% right.

But have you ever thought about, why do we need the LoRa Gateway in the first place? Well, we only use the LoRa Gateway, when the sensor is installed in such a location where no internet facility is available. Then in a situation like this, we connect a LoRa or any other wireless device with the remote side controller, with the help of which, then we can send the sensors data to a location where the internet facility is available. And then from there, the readings are sent to IoT platforms. I have covered almost 90% of the IoT platforms, just go ahead and check my playlist dedicated to IoT projects. I hope, now, you might have fully understood why do we need and use the LoRa Gateway.

Anyway, before I am going to explain the circuit diagrams and programs; first, let’s watch the ESP8266 LoRa Gateway for Arduino and LM75 Temperature Sensor in Action.



ESP8266 LoRa Gateway

I have powered up the transmitter as well as the receiver’s side. You can see the temperature readings in Celsius and Fahrenheit on the Oled display module and you can also view the same temperature readings on the Blynk application.

The receiver side programming, I have done in such a way that when the temperature exceeds a set value a notification message is sent to the Blynk application and at the same time buzzer is also turned ON. For now, I have selected 45 degrees Celsius as the threshold value.

ESP8266 LoRa Gateway

I applied some heat and when the temperature exceeded the threshold value I got a notification on the Blynk application and also the Buzzer turned ON.

ESP8266 LoRa Gateway

You can make a whole LoRaWAN network consisting of multiple LoRa nodes installed at different locations. You can read my article on LoRAWAN, in which I have demonstrated how to send sensors data from multiple LoRa nodes to the Master LoRa node.

I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!



Amazon Links:

Arduino Nano USB-C Type (Recommended)

SSD1306 Oled display Module

LM75A I2C supported Temperature Sensor

5V buzzer

ESP8266 D1 Mini

ESP8266 Nodemcu

LoRa SX1278 Module

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

LM75A Temperature Sensor:

ESP8266 LoRa Gateway

This is the CJMCU-75 I2C supported temperature sensor which is also known as LM75 or LM75A temperature sensor. With this temperature sensor, you can read temperature in both Celsius and Fahrenheit. The temperature range is from -55 Celsius to +125 degree Celsius.

The LM75A is an industrial standard digital temperature sensor with an integrated sigma-delta analog-to-digital converter (ADC). The LM75A provides 9-bit digital temperature readings with an accuracy of ±2°C from –25°C to 100°C and with an accuracy of ±3°C over –55°C to 125°C.

The LM75A operates with a single supply from 2.7 V to 5.5 V. Due to this wide range of input voltages it can be easily used with 3.3V compatible controller boards like esp8266, ESP32, etc., and 5V compatible controller boards.

ESP8266 LoRa Gateway

Communication is accomplished over a 2-wire interface which operates up to 400 kHz. LM75A has three selectable logic address pins A0, A1, and A2, allowing up to eight LM75A devices to operate on the same 2-wire bus. A0, A1, and A2 can be used to set an I2C address. You can short any of these address pins with the VCC or ground. This way you will be able to connect 8 temperature sensors without any address conflict.

The LM75A has a dedicated over-temperature output (O.S.) with programmable limit and hysteresis.

LM75A temperature sensor can be used in base stations, electronic test equipment, office electronics, personal computers, Environmental Monitoring, and any other system in which thermal management is critical to performance.




ESP8266 D1 mini (Wemos Lolin):

ESP8266 LoRa Gateway

The D1 Mini V2 NodeMcu is 4M Bytes Lua WIFI Internet Of Things Development Board Based ESP8266, it is a mini WIFI board based on ESP-8266EX. 11 digital input/output pins, all pins have interrupt/PWM/I2C/one-wire supported(except D0) 1 analog input(3.3V max input) and a Micro USB connection.

The development board features WiFi-SoC ESP8266 and is made for fast Internet-of-Things (IoT) prototyping. It is flashed with the latest firmware version and can be set up and programmed right away with the onboard micro USB connection. With only a few lines of code, the NodeMCU Dev Kit connects to your local network and ready for control by other network members like computers and smartphones.

The d1 mini is an ESP8266 development board that is compact, versatile and very easy to use with the Arduino IDE. It supports natively by the Expressive SDK.

Pins Description:

Pin Function ESP-8266 mini Pin
TX TXD TXD
RX RXD RXD
A0 Analog input, max 3.2V A0
D0 IO GPIO16
D1 IO, SCL GPIO5
D2 IO, SDA GPIO4
D3 IO, 10k Pull-up GPIO0
D4 IO, 10k Pull-up, BUILTIN_LED GPIO2
D5 IO, SCK GPIO14
D6 IO, MISO GPIO12
D7 IO, MOSI GPIO13
D8 IO, 10k Pull-down, SS GPIO15
G Ground GND
5V 5V
3V3 3.3V 3.3V
RST Reset RST

Features:

  1. 11 digital input/output pins
  2. Interrupt/PWM/I2C/one-wire
  3. 1 analog input(3.2V max input)
  4. 16M bytes(128M bit) Flash
  5. External antenna connector
  6. Built-in ceramic antenna
  7. New CP2104 USB-TO-UART IC



SX1278 LoRa Module:

In this project we are using the same SX-1278 LoRa modules for the transmitter and receiver. In order to use it as a receiver and transmitter we will make change in the code. Lora SX-1278 long distance wireless transceiver module integrates Semtech RF transceiver chip SX1278, which adopts LoRa TM Spread Spectrum modulation frequency hopping technique. The features of long distance and high sensitivity (-139dBm) make this module perform better than FSK and GFSK module. Multi-signal won’t affect each other even in crowd frequency environment; it comes with strong anti-interference performance. This module is 100mW and ultra small size, widely used in AMR , remote industrial control filed.

ESP8266 LoRa Gateway

Features:

  • Frequency Range: 868 / 915 MHz
  • Sensitivity up to -139dBm @Lora
  • Maximum output power: 20 dBm
  • 13mA@receiver mode
  • Sleep current <200 nA
  • Data transfer rate: @FSK,1.2-300 Kbps
  • @Lora TM, 0.018-37.5 Kbps
  • Lora TM, FSK, GFSK & OOK Modulation mode
  • Built-in ESD Protection
  • 127 dB Dynamic Range RSSI
  • Packet engine up to 256 bytes with FIFO and CRC
  • Hopping frequency
  • Built-in temperature sensor and low battery indicator
  • Excellent blocking immunity
  • Operating Temperature Range:-40 ~ + 85 °C

Applications:

  • Remote control
  • Remote meter reading
  • Home security alarm and remote keyless entry
  • Industrial control
  • Home automation remote sensing
  • Individual data records
  • Toys control
  • Sensor network
  • Tire pressure monitoring
  • Health monitoring
  • Wireless PC peripherals
  • Tag reading and writing



LM75A, Oled, & LoRa with Arduino:

ESP8266 LoRa Gateway

The SCL and SDA pins of the LM75A temperature sensor and Oled display module are connected together and then connected with the Arduino A5 and A4 pins. A5 is the SCL and A4 is the SDA. While the VCC and GND pins are connected with the Arduino 3.3V and GND pins.

The VCC of the LoRa module is connected with 3.3V of the Arduino. The MISO Pin of the LoRa module is connected with the Arduino pin 12. The MOSI pin is connected with pin 11. The SCK pin of the LoRa module is connected with 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.

On the left side, you can see a 5V regulated power supply based on the LM7805 voltage regulator. We use this regulated 5 volts to power up the Arduino and all the other electronics.

ESP8266 LoRa Gateway:

ESP8266 LoRa Gateway

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

The 5V buzzer is controlled using the digital pin D3 of the ESP8266 WiFi module. We use 2n2222 NPN transistor and a 10K ohm resistor to control the 5V buzzer. The transistor and resistor make the driver circuit. Now, let’s working on the Blynk application. Follow the same exact steps.



Creating a Dashboard in Blynk application:

Open the Blynk application and click on the New Project.

ESP8266 LoRa Gateway

As we are using ESP8266, so click on the ESP8266 and give name to the project which is LM75 Temp monitor.

ESP8266 LoRa Gateway

After that click on the create button, an authentication token will be sent on a registered email id.

ESP8266 LoRa Gateway

After that click on the add button and add the gauge for the Centigrade.

ESP8266 LoRa Gateway

The gauge name will be Centigrade and in pin select virtual pin V1 and set the maximum value to 200.

ESP8266 LoRa Gateway

Similarly, add another gauge for the Fahrenheit and set the pin to V2 and the maximum value to 200.

ESP8266 LoRa Gateway




After that, we will add a notification widget in order to receive the exceeded temperature notification.

ESP8266 LoRa Gateway

My dashboard is completed, as you can see in the image given below.

ESP8266 LoRa Gateway

 My Blynk application is ready and now let’s take a look at the programming.

ESP8266 LoRA Gateway Programming:

Required Libraries:

Before, you start the programming, first of all, make sure you download all the necessary libraries. The loRa.h, Adafruit_GFX.h and Adafruit_SSD1306.h libraries I have been using for quite a long time and I have already explained how to download and use these libraries.

Download: LoRa.h

Download: Adafruit_GFX.h

Download: Adafruit_SSD1306.h

I have also a very detailed getting started tutorial on the ESP8266 WiFi module, in which I have explained how to install the ESP8266 using the Boards manager URL link and how to install and use the BlynkSimpleEsp8266.h.

You will also need the LM75A library.

Download LM75A

ESP8266 LoRa Gateway



To add this library simply click on the Sketch menu and then go to Include Library and click on the Add ZIP library… browse to the desired location and select the zip folder and then finally click on the open button.

ESP8266 LoRa Gateway

As I have already added this library so I will click on the cancel button.

Arduino, LoRa, &  LM75A- Tx Code:

Maximum of the code, I have already explained in my previous LoRa based projects. The purpose of this program is to read the LM75A temperature sensor. And then to print the temperature readings on the Oled display module and also to send these values to the remote side receiver. Now, let’s take a look at the ESP8266 LoRa gateway programming.



ESP8266 LoRa Gateway Programming:

I started off by defining the pins. This is the Authentication code which is sent while making the Blynk application. These are the WiFi credentials and some variables which I have been using in almost all of my LoRa-based projects. The code inside the setup() function is exactly the same.

Inside the loop() function, we have only two functions Blynk.run() and onReceive() functions…

The purpose of this code is to split the string message using the getValue() and then the readings are stored in the corresponding variables. The readings are converted back to float type and then finally these readings are sent to the Blynk application through virtual pins V1 and V2. At the same time the controller also checks if the temperature reading is above or below the set value and accordingly controls the buzzer. So, that’s all about the programming.  



Now, to upload the program, go to the Tools menu, then to boards, and select LOLIN(WEMOS) D1 R2 & mini.

ESP8266 LoRa Gateway

Again go to the Tools menu and this time check if the correct communication port is selected. Finally, click on the upload button and wait for a while.

Watch Video Tutorial:

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...

Related Articles

2 Comments

  1. Hello, this guide works for the older version of the Blynk app, however, how would I construct the same mobile dashboard on the newer version of the mobile Blynk app?

Leave a Reply

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

Back to top button