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.

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.

Altium Designer + Altium 365 + Octopart:

Arduino LoRa Free SMS

Altium 365 lets you hold the fastest design reviews ever. Share your designs from anywhere and with anyone with a single click. it’s easy, leave a comment tagging your teammate and they’ll instantly receive an email with a link to the design. Anyone you invite can open the design using a web browser. Using the browser interface, you’re able to comment, markup, cross probe, inspect, and more. Comments are attached directly to the project, making them viewable within Altium designer as well as through the browser interface. Design, share, and manufacture, all in the same space with nothing extra to install or configure. Connect to the platform directly from Altium Designer without changing how you already design electronics. Altium 365 requires no additional licenses and comes included with your subscription plan.

Get real-time component insights as you design with Octopart built into Altium 365. Octopart is the fastest search engine for electronic parts and gives you the most up-to-date part data like specs, datasheets, cad models, and how much the part costs at different amounts etc. Right in the design environment so you can focus on your designs. Start with Altium Designer and Activate Altium 365. Search for electronic parts on Octopart.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:

SSD1306 Oled display Module

LM75A I2C supported Temperature Sensor

5V buzzer

ESP8266 D1 Mini

ESP8266 Nodemcu

LoRa SX1278 Module

Arduino Nano

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!

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:

PinFunctionESP-8266 mini Pin
A0Analog input, max 3.2VA0
D3IO, 10k Pull-upGPIO0
D8IO, 10k Pull-down, SSGPIO15


  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


  • 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


  • 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:

//Lora with Transmitter arduino nano

#include <SPI.h>              // include libraries
#include <LoRa.h>
 #include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <LM75A.h>
LM75A lm75a_sensor(false,  // A0 LM75A pin state (connected to ground = false)
                   false,  // A1 LM75A pin state (connected to ground = false)
                   false); // A2 LM75A pin state (connected to ground = false)
// Equivalent to "LM75A lm75a_sensor;"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)

String outgoing;              // outgoing message
byte msgCount = 0;            // count of outgoing messages
byte MasterNode = 0xFF;     
byte Node1 = 0xBB;
float ctemp; 
float ftemp;
String Mymessage = "";
void setup() {
  Serial.begin(9600);                   // initialize serial
  if (!LoRa.begin(433E6)) {       
    Serial.println("LoRa init failed. Check your connections.");
    while (true);                       // if failed, do nothing
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
void loop() {
  float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees();

  if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE)
    Serial.println("Error while getting temperature");
//    Serial.print("Temperature: ");
//    Serial.print(temperature_in_degrees);
//    Serial.print(" degrees ");
    ftemp= LM75A::degreesToFahrenheit(temperature_in_degrees);
//    Serial.print(ftemp);
//    Serial.println(" fahrenheit)");
  display.println(" Temperature");
  //display.print("C: ");
  //display.print("F: ");

    Mymessage = Mymessage + temperature_in_degrees + "," + ftemp;  
    Mymessage = "";
void sendMessage(String outgoing, byte MasterNode, byte otherNode) {
  LoRa.beginPacket();                   // start packet
  LoRa.write(MasterNode);              // add destination address
  LoRa.write(Node1);             // add sender address
  LoRa.write(msgCount);                 // add message ID
  LoRa.write(outgoing.length());        // add payload length
  LoRa.print(outgoing);                 // add payload
  LoRa.endPacket();                     // finish packet and send it
  msgCount++;                           // increment message ID

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:

 ESP8266 LoRa Gateway, receiver side

#include <SPI.h>              // include libraries
#include <LoRa.h>
#include <Wire.h>
#include <BlynkSimpleEsp8266.h>

#define Nss 15 // D8 pin CS
#define rst 16 // D0 
#define dio0 2 // D4
int buzzer = D3;
char auth[] = "-HrsXL8bXKhJrZdFOmVQgK6VfzGoVQqv";

 ///Connect SCL to D1 and Connect SDA to D2
/* WiFi credentials */
char ssid[] = "AndroidAP3DEC";
char pass[] = "electroniclinic";

byte MasterNode = 0xFF;     
byte Node1 = 0xBB;
String SenderNode = "";
String outgoing;              // outgoing message
byte msgCount = 0;            // count of outgoing messages
String incoming = "";
float ctemp; 
float ftemp; 

void setup() {
  Serial.begin(9600);                   // initialize serial
 LoRa.setPins(Nss, rst, dio0);

  if (!LoRa.begin(433E6)) {             // initialize ratio at 915 MHz
    Serial.println("LoRa init failed. Check your connections.");
    while (true);                       // if failed, do nothing

 // Serial.println("LoRa init succeeded.");
   Blynk.begin(auth, ssid, pass);


void loop() {;
  // parse for a packet, and call onReceive with the result:

void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  // read packet header bytes:
  int recipient =;          // recipient address
  byte sender =;            // sender address
  if( sender == 0XBB )
  SenderNode = "Node1:";
  byte incomingMsgId =;     // incoming msg ID
  byte incomingLength =;    // incoming msg length

  while (LoRa.available()) {
    incoming += (char);

  if (incomingLength != incoming.length()) {   // check length for error
    //Serial.println("error: message length does not match length");
    return;                             // skip rest of function

  // if the recipient isn't this device or broadcast,
  if (recipient != Node1 && recipient != MasterNode) {
   // Serial.println("This message is not for me.");
    return;                             // skip rest of function

  // if message is for this device, or broadcast, print details:
  //Serial.println("Received from: 0x" + String(sender, HEX));
  //Serial.println("Sent to: 0x" + String(recipient, HEX));
  //Serial.println("Message ID: " + String(incomingMsgId));
 // Serial.println("Message length: " + String(incomingLength));
 // Serial.println("Message: " + incoming);
  //Serial.println("RSSI: " + String(LoRa.packetRssi()));
 // Serial.println("Snr: " + String(LoRa.packetSnr()));
 // Serial.println();

 String q=getValue(incoming, ',', 0); 
String r =getValue(incoming, ',', 1); 
ctemp = q.toFloat();
  Serial.println(" C");
ftemp = r.toFloat();
  Serial.println(" F");
 if (ctemp >= 45 )
      Blynk.notify("Temperature Exceeded!!!"); 
      digitalWrite( buzzer, HIGH);
  if (ctemp < 45 )
      digitalWrite( buzzer, LOW);

incoming = "";


String getValue(String data, char separator, int index)
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;
    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";

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


  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