Saturday, November 23, 2024

ESP32 LoRa Gateway

Comment errors or corrections found for this circuit, and get the chance to win big!

In a boiler safety project, we completed, in which we are collecting 32 thermocouple readings from the deep of a 500 MW boiler 2nd pass area where the ambient temperature on a normal day runs 65 to 70 Degree Centigrade due to hot are leakages in the vicinity of the spot. However, the thermocouples need to measure temperatures ranging from 350 to 150-degree centigrades depending on their positions.

During a boiler shut down, we fixed those Thermocouples in those strategic places, connected the Arduino Mega board, fixed the LoRa radio with only the Antenna sticking outside the IP64 cabinet and then fixed the box on a post. The 220 volt AC supply from a nearby emergency power supply pillar is taken through a smartphone adapter and the 5Volt DC enters the cabinet through the only small hole below the box. The 2 sets of 16 each K-type thermocouples having 32 wires enter the two boxes each through a side slot which is finally sealed with special insulating putty & m-seals. The common thought of providing an LED indicator to indicate healthiness of these devices was turned down due to the fact there is hardly anyone who pays a visit to this place even once in a couple of days and that too to at this height & temperatures! Therefore, finally, we have two black boxes fixed on a pillar board with 32 thermocouple cables entering each box.

It’s truly a fill it – shut it – and forget it project!!!

- Advertisement -

Who uses these data?

All the data flies once in 10 seconds to a nearby service building situated a good 700 meters away where the boiler maintenance guys have their offices. The small hand held Arduino MEGA device beside storing the data in CSV format , portrays it on a small TFT screen in 4 columns. It also has capabilities to demonstrate the rate-of-rise of temperature with audio/visual alarm as well! However, this is not our project. The data arrives in a CSV format like

14-06,23:19:02, 5700 ,1-251.50,2-251.00,3-166.00,4-238.00,5-131.75,6- NAN,7-207.75,8-93.00#
14-06,23:19:12, 5700 ,1-251.25,2-249.75,3-166.00,4-237.75,5-131.75,6- NAN,7-207.75,8-92.00#
14-06,23:19:22, 5675 ,1-251.50,2-251.25,3-166.25,4-237.00,5-131.25,6- NAN,7-207.25,8-92.25#
14-06,23:19:33, 5675 ,1-252.00,2-250.75,3-166.75,4-238.00,5-131.50,6- NAN,7-207.75,8-91.75#
14-06,23:19:43, 5675 ,1-252.00,2-251.75,3-165.75,4-237.75,5-131.00,6- NAN,7-207.75,8-93.25#
14-06,23:19:53, 5675 ,1-252.25,2-251.50,3-165.50,4-237.75,5-131.50,6- NAN,7-207.50,8-93.25#
14-06,23:20:03, 5675 ,1-253.00,2-252.00,3-165.50,4-238.25,5-132.00,6- NAN,7-207.25,8-94.50#
14-06,23:20:13, 5675 ,1-252.25,2-251.75,3-165.75,4-238.50,5-132.25,6- NAN,7-207.75,8-93.50#
14-06,23:20:23, 5675 ,1-252.00,2-251.50,3-166.25,4-238.50,5-131.25,6- NAN,7-207.75,8-93.25#
14-06,23:20:33, 5675 ,1-251.75,2-251.25,3-166.75,4-238.00,5-131.75,6- NAN,7-208.00,8-92.00#
14-06,23:20:44, 5675 ,1-252.00,2-251.00,3-166.00,4-238.50,5-131.25,6- NAN,7-207.25,8-91.75#
14-06,23:20:54, 5675 ,1-252.00,2-250.50,3-165.50,4-238.25,5-131.50,6- NAN,7-207.25,8-91.50#
14-06,23:21:04, 5675 ,1-252.25,2-250.50,3-166.00,4-238.00,5-131.50,6- NAN,7-208.00,8-92.25#
14-06,23:21:14, 5675 ,1-251.75,2-250.75,3-165.75,4-238.00,5-132.00,6- NAN,7-207.75,8-92.00#
14-06,23:21:24, 5675 ,1-251.50,2-251.00,3-166.00,4-238.75,5-132.25,6- NAN,7-208.00,8-93.50#
14-06,23:21:34, 5675 ,1-251.25,2-251.25,3-166.00,4-238.50,5-132.00,6- NAN,7-207.50,8-91.75#

- Advertisement -

Everybody should monitor these data

So far these data were monitored by the boiler maintenance department as they are the sole agency to take care of any abnormalities of these parameters. But one day one important aberration was missed due to the fact that the day was poll day here! So the verdict came that these data should be posted on LAN / WAN so that they can be monitored round-the-clock by the (24*7) local operation department and regional operation center.

How to do that?

While the IT department started exploring the several protocols like – telnet, wget, ftp, web database etc. I thought to upload data to a cloud where from it can be accessible by all. But doing it on Arduino MEGA is a challenge! ( although not impossible! )

ESP32 LoRa router

Its rather very easy to achieve this feat on ESP32! The same UART LoRa radio is first to be connected to the Rx/Tx of the ESP32. While software serial works on Arduino, only hardware serial works on ESP32. Therefore I’ve to connect the LoRa radio on the hardware serial port first. For setting hardware serial on ESP32 the following command is used.

Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1); //
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); //
// For Rx = 16,15,13,34
// For Tx = 17,12,4,35

You can set your own pins for the Tx and Rx. I find the above pin works splendidly. For connecting two LoRa radio you can set two UART sets as well. As per databook, ESP32 can have three UARTs at a time also any GPIO pins can be set for serial communications. But I’m yet to set the UART3 to work for me.

Principles of operation

Once the LoRa radios start communicating with the ESP32 on the UARTs then comes the another crucial part of networking – setting up the WiFi network for connecting with the Internet.

#include
#include
#include
#include
const char *ssid = “bera1”;
const char *password = “**********”;
const char *ssid1 = “bera2”;
const char *password1 = “**********”;

I have two networks to use and depending upon the connectivity the ESP32 is programmed in such a way that if it does not get the connection, it will look up it’s EEPROM memory and restart to connect into the alternate network! You can provide any number of ssid and password and in case it fails to connect, the ESP32 will try all of them one after another !!! Please incorporate small changes for additional network selection criteria in the setup area.

The Router

So at this stage, the ESP32 is getting data at the SS radio network and it is also connected to the Internet using WiFi or BLE [Bluetooth Low Energy]. Now if we can transfer the data from one network to the other network [Internet] the ESP32 will achieve the status of a Router!

Therefore, we have to achieve those feats now.

We, at this point, can select our own server/cloud or we can find a third party server/cloud. While our company cloud is in the making, we have decided to upload 8 very critical data to a public cloud for distribution and visibility for everyone. These 8 data are available at this site now.

Schematic

The ESP32 is getting data on it’s Tx2,Rx2 [17,16] vide SS Radio interface and then after connecting on WiFi sends data on Internet servers.It’s not necessary that you upload data on public cloud only. You can send data to your personal / corporate server as well.
Distributed Cloud Computing With ESPs [ESP8266 & ESP32]

Consult the site above where you can upload data to a LAMP server using ESP32 / ESP8266.

For uploading data to thingspeak server, one needs to have an API upload key, which may be obtained after registering with the thingspeak.com site. After having the API key, the sensor data is lined up in a string which is then parsed through the

http.begin(poststr);
int httpCode=http.GET();
if (httpCode > 0) { //Check for the returning code
String payload = http.getString();
Serial.println(“Updated”);
}

Aftermath

Gone are the days of big computing power and elaborate data uploading etc. Now small micro computers have enough power to upload data getting from one node using several technologies like SS Radio, WiFi or BLE and then upload it directly to remote cloud or database server. It gives flexibility improves deploy-ability to a great extent.

Prototype


SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Electronics News

Truly Innovative Electronics

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics