Internship Report- NAv

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 31

LoRa Enabled Precision Farming

STUDENT INTERNSHIP PROJECT REPORT

SUBMITTED BY
NAVEEN B

Supervisor
Dr. R. Hemalatha
Associate Professor

DEPARTMENT OF ECE
SRI SIVASUBRAMANIYA NADAR COLLEGE OF ENGINEERING
KALAVAKKAM-603110

JUNE 2023

Date: 12-06-23
CERTIFICATE OF COMPLETION

This is to certify that the internship project titled “LoRa Enabled Precision Farming”
undertaken by NAVEEN B of Sri Sairam Engineering College has been completed as per the
proposed aim and objectives.

Faculty Incharge Head of the Department


Dr.R.Hemalatha Dr.S.Radha
Associate Professor Prof and Head

TABLE OF CONTENTS

2
1. PROJECT OVERVIEW 4

2. INTRODUCTION 5

3. OBJECTIVE 6

4. PROPOSED SOLUTION 9

5. RESULTS 18

6. REFERENCES 21

3
PROJECT OVERVIEW

I. PROJECT TITLE
LoRa Enabled Precision Farming.

II. MAJOR RESEARCH AREA


LoRa Module - Monitoring of physical parameters in farm through wireless network
systems, and transmitting sensor data to analyse and take action immediately.

III. PROJECT DURATION


The project was carried out between the 29th of May and the 04th of August 2023.

4
INTRODUCTION

Precision Farming:
Precision farming, also known as precision agriculture or site-specific farming, is an
approach to agricultural management that utilizes technology and data to optimize agricultural
practices on a more precise and localized level. It involves the use of various technologies such
as remote sensing, geographic information systems (GIS), global positioning systems (GPS), and
advanced analytics to collect and analyze data about soil conditions, crop growth, and other
environmental factors.
The goal of precision farming is to make agricultural practices more efficient, sustainable,
and cost-effective by tailoring them to specific areas within a farm or field. By gathering detailed
information about soil variability, crop health, moisture levels, and other relevant parameters,
farmers can make data-driven decisions to optimize the use of resources such as water,
fertilizers, pesticides, and energy.

LoRa:
LoRa (Long Range) is a wireless communication technology specifically designed for low-
power, wide-area networks (LPWAN). It enables long-range communication with low data rates,
making it suitable for applications that require long-range connectivity while conserving battery
power. LoRa technology is often used in various IoT (Internet of Things) applications, including
smart agriculture, smart cities, industrial monitoring, and asset tracking. LoRa technology has
gained popularity due to its ability to provide long-range, low-power connectivity for IoT
applications. It offers a cost-effective solution for deploying large-scale IoT networks with a
focus on conserving battery power and extending the range of communication.
Some of the main features long range wireless communication is, we can able to transmit
data to long ranges upto kilometers (approx. 10Km), it consumes less power for the operation,
the transmission of data will be secure, LoRa networks typically consist of end devices,
gateways, and a network server. End devices, such as sensors or actuators, transmit data to
gateways, which act as intermediaries between the devices and the network server. The network
server manages the overall network and data routing.
The aim of a LoRa-enabled precision farming project would be to leverage the capabilities
of LoRa technology to enhance precision farming practices. The project would focus on using
LoRa for efficient data collection, monitoring, and control in agricultural operations, leading to
improved resource management, increased crop yields, and sustainable farming practices.

5
OBJECTIVE

The objective of a LoRa-enabled precision farming project is to leverage LoRa technology


for real-time monitoring of environmental parameters, data-driven decision making, and resource
optimization. By collecting and analysing sensor data, farmers can make informed decisions
about irrigation, fertilization, and pest control. LoRa connectivity enables remote control and
automation of farm operations, leading to increased efficiency, reduced resource wastage, and
improved crop yields.
The entire process involves the proper choice of
 An appropriate network model,
 Data transmission from sensor nodes.
 Receiving the sensor data.
 Analysing data for taking further action.

In this project, I have done three things to transmit and receive data:
1. LoRa to LoRa data transmission.
2. LoRa to web server.
3. LoRa to web application through Firebase.

In all the three methods of data transmission, the components used were:

1)Heltec WiFi LoRa ESP32 module(433-510MHz):


This module consists of WiFi module, and a ESP32 microcontroller. It is a 36 pinned
module. It consists of 0.96 OLED display. Its operating voltage is between 3.3v to 7v. Its
operating temperature range is between -40 degree Celsius to +90 degree Celsius and it has a
frequency range of 433MHz to 510MHz in which the module operates.
Detailed description about the components present in the Heltec WiFi LoRa ESP32
module were as follows:

1. ESP32 Microcontroller: The module is built around the ESP32, a powerful and widely
used microcontroller with integrated Wi-Fi and Bluetooth capabilities.

2. LoRa Communication: The module incorporates a LoRa transceiver that allows long-
range communication at low data rates. LoRa is well-suited for applications that require
long-distance communication with low power consumption.

6
3. WiFi Connectivity: In addition to LoRa, the module also supports standard WiFi (802.11
b/g/n) connectivity, enabling easy integration with internet-based services and
communication.

4. OLED Display: Many Heltec LoRa WiFi ESP32 modules come with an integrated OLED
display, providing a convenient way to display data or status information without the
need for external displays.

5. Built-in Antenna: The module typically includes an onboard antenna for both LoRa and
WiFi, making it a compact and ready-to-use solution for wireless communication.

6. GPIO Pins: The module exposes GPIO (General Purpose Input/Output) pins, allowing
you to interface with various sensors, actuators, and peripherals to build custom
applications.

7. Arduino IDE Support: The Heltec LoRa WiFi ESP32 module can be programmed using
the Arduino IDE, making it accessible to a broad community of developers who are
familiar with the Arduino ecosystem.

8. Development Board: The module usually comes as a development board with USB-to-
UART communication, easing the programming and debugging process.

9. Battery Management: Some versions of the module may include battery management
features, making it suitable for low-power, battery-operated applications.
10. Support for LoRaWAN: Depending on the specific variant, the module might suppor
LoRaWAN, a widely-used protocol for long-range communication with low-power
devices in IoT applications.

Heltec LoRa WiFi ESP32 module with 0.96inch OLED display

7
2)DHT11 Sensor:
DHT11 sensor is used to monitor the temperature and humidity of the environment. It
consists of 3 pins- Ground, VCC, data pins.
The main use of DHT11 sensor is for:
1.Temperature Measurement: The DHT11 sensor can measure ambient
temperature with reasonable accuracy. The temperature range is typically from
0°C to 50°C (32°F to 122°F).
2. Humidity Measurement: The sensor can measure relative humidity in the air.
The humidity range is usually from 20% to 90%.

DHT11 SENSOR

8
PROPOSED SOLUTION

BLOCK DIAGRAM

INPUT

LoRa Module

DHT 11 Sensor

Transmitting data
OUTPUT

OUTPUT Received Data

Web Page

In this project, I have done three things to transmit and receive data:
1. LoRa to LoRa data transmission.
2. LoRa to web server.
3. LoRa to web application through Firebase.

9
1)LoRa to LoRa data Transmission:

FLOW DIAGRAM:

Connecting Transmitting
Receiving data
DHT11 sensor sensor data
by LoRa
to Heltec LoRa by LoRa
receiver
module transmitter

DESCRIPTION:

To perform LoRa to LoRa transmission, the following requirements should be made:

 LoRa Transceiver Modules: Both the transmitting and receiving devices should be
equipped with LoRa transceiver modules, such as the popular SX1276 or SX1278 chips.
These modules handle the LoRa modulation and demodulation processes, making it
easier to work with LoRa technology.

 LoRaWAN vs. Point-to-Point: There are two primary modes of LoRa communication:
LoRaWAN and point-to-point. LoRaWAN is a protocol designed for IoT applications
and involves communication with LoRaWAN gateways, while point-to-point
communication is a direct communication between two LoRa devices. For point-to-point
communication, you don't need a LoRaWAN network infrastructure.

 Frequency and Spreading Factor: Before transmitting data, you need to configure both
devices to operate on the same frequency (e.g., 433 MHz) and set the same spreading
factor. The spreading factor determines the data rate and range of the transmission.

10
Higher spreading factors provide longer range but lower data rates, while lower spreading
factors offer higher data rates but shorter range.

 Data Encoding: Prepare the data you want to send in a format that can be transmitted over
LoRa. The data can be sensor readings, commands, or any other relevant information.

 Transmitting Device Configuration: On the transmitting device, configure the LoRa


module with the necessary settings, including frequency, spreading factor, power level,
and data rate. Then, package the data to be transmitted in a LoRa packet.

 Transmitting Data: Once the transmitting device is configured, send the LoRa packet
containing your data. The LoRa transceiver will use the specified frequency, spreading
factor, and power level to transmit the packet.

 Receiving Device Configuration: On the receiving device, configure the LoRa module
with the same settings as the transmitting device, such as frequency, spreading factor, and
data rate.

 Receiving Data: The LoRa module on the receiving device will listen for incoming
packets on the specified frequency and decoding them using the same spreading factor. If
the packet is successfully received and decoded, the data will be extracted.

 Error Handling: LoRa communication is subject to interference and fading in the radio
environment. For reliable communication, you may need to implement error-checking
and retry mechanisms in your software.

In this method, I’ve taken a LoRa module connected with a DHT11 sensor which I used
as a transmitter to transmit sensor data. Then I created a code to transmit data for the LoRa
transmitter and uploaded that code to the LoRa transmitter through Arduino IDE. After that I
uploaded a code to the LoRa receiver to receive the sensor data through Arduino IDE. Then the
final result can be displayed in both the serial monitor and the OLED display of both the LoRa
transmitter and receiver.

11
The temperature value will be transmitted to the received LoRa module. And the
temperature value can be seen in the Serial monitor of Arduino IDE, the transmitter LoRa OLED
display and the receiver LoRa OLED display.

Generally I’ve tested the data transmission range between these two LoRa(LoRa
transmitter and Receiver module) modules, I’ve got the data transmission range without any
delay of around 200 to 220 metres. After 220 metres, the data receiving in the receiver module
got delayed by seconds. I’ve have taken this reading in a straight path. The range varies
depending upon the surroundings and obstructions in the environment.

2)LoRa to Web Server:

FLOW DIAGRAM:

Connecting
Receiving
DHT11 sensor to Connecting this
Sensor data
Heltec WiFi LoRa module to
through IP
LoRa ESP32 WiFi network
address
module

DESCRIPTION:
Connecting LoRa devices to a web server involves the integration of LoRa
communication with an internet-connected server or cloud platform. This allows you to transmit
data from LoRa devices to the web server for further processing, storage, or visualization. Here
are the general steps to achieve this:

12
 LoRa Device Setup: Set up your LoRa devices with LoRa transceiver modules, such as
the ones equipped with SX1276 or SX1278 chips. Configure both the transmitting and
receiving devices to operate on the same frequency, spreading factor, and other necessary
parameters for communication.

 LoRaWAN vs. Point-to-Point: Decide whether you want to use LoRaWAN or point-to-
point communication. LoRaWAN requires a LoRaWAN network infrastructure with
gateways and a LoRaWAN server, while point-to-point communication involves direct
communication between two LoRa devices.

 Internet Connectivity: To connect to a web server, you'll need internet connectivity on the
server-side. Ensure that the web server or cloud platform you are using is accessible via
the internet.

 Web Server Setup: Set up your web server or cloud platform to receive and process data
from the LoRa devices. Depending on your chosen platform, you may need to create an
account, set up an API or webhook, or configure a database to store incoming data.

 Data Encoding: Prepare the data you want to send from the LoRa devices in a format that
can be transmitted over LoRa and understood by your web server. This could be JSON,
XML, or any other appropriate data format.

 LoRa Packet Payload: In LoRaWAN or point-to-point communication, you'll need to


create LoRa packets with the data you want to transmit as the payload.

 Transmitting Data: On the LoRa device side, send the LoRa packets containing your data.
The packets will be transmitted using the LoRa parameters you configured earlier.

 Receiving Data on Web Server: On the web server or cloud platform, set up the necessary
endpoints or APIs to receive incoming data from the LoRa devices. This could be done
through HTTP requests, MQTT, or other suitable protocols.

13
 Data Processing and Storage: Upon receiving the data, process and store it on the web
server or cloud platform. This might involve parsing the data from the LoRa packets,
storing it in a database, and performing any required computations or analytics.

 Data Visualization (Optional): If desired, you can create a web-based dashboard or user
interface to visualize the received data for monitoring and analysis purposes.

 Security Considerations: Implement appropriate security measures to protect data


transmission and storage. For LoRaWAN, data is usually encrypted during transmission.

 Error Handling and Reliability: Account for potential errors and packet loss during LoRa
communication. Implement error-checking and retry mechanisms to ensure reliable data
transmission.

In this method, I’ve used only one Heltec LoRa WiFi ESP32 module and a DHT11
sensor. First, I have connected the DHT11 sensor with the LoRa module. Then designed a code
for the DHT11 sensor to transmit data by the LoRa transmitter module. After that, I’ve made
code to connect Heltec LoRa WiFi ESP32 module to the available WiFi network.

I have connected the module to my mobile phone WiFi network by giving WiFi network
SSID and password and uploaded that code to the LoRa transmitter module. I ensured that LoRa
module has connected to my WiFi network by checking the connections in the mobile phone
which will display the name of the devices connected. If it shows the name of the LoRa module,
then it means it is connected to the mobile WiFi network.

After that finally we can receive and see the sensor data i.e, temperature and humidity of
the surrounding by the serial monitor of Arduino and it also shows an IP address. By searching
the IP address in the browser we can get the temperature and humidity readings. We have to
make sure that we have a better WiFi connection to transmit and receive data.

This total set up depends mainly on the WiFi network connection. If we have a better
WiFi connection connected to the LoRa module, then we can receive the data instantly and can
access the data from anywhere. This is a simple and general method of transmitting and
receiving data through IP address and it is quite easy when we correct code to do it.

14
3)LoRa to Web Application through Google Firebase:

FLOW DIAGRAM:

Connecting
Creating a Transmitting Receiving
DHT11 Open a Transmitting
own Web Firebase real Data in the
sensor to the Google Real time
Application time data to created
Heltec WiFi Firebase Sensor data
through web HTML web
LoRa ESP32 Account to Firebase
HTML Application Application
module

DESCRIPTION:

 Setup Firebase Account: If you don't have a Firebase account, create one at
https://firebase.google.com/. Once you have an account, create a new Firebase project.

 Add Web App to Firebase Project: In your Firebase project, add a new web app by
clicking on the "Add app" button and select "Web" from the options. Follow the
instructions to register your web app and obtain the Firebase configuration settings
(apiKey, authDomain, databaseURL, etc.).

15
 Setup Firebase Realtime Database: In your Firebase project console, navigate to the
"Database" section and set up a new Firebase Realtime Database. Configure the security
rules to allow read and write access as required for your application.

 Configure LoRa Device: Setup your LoRa device to send data to a gateway or a
LoRaWAN network server. Ensure that the data you want to send is encoded in a format
that you can parse on the web page.

 Web Page Setup: Create a web page that will display the data received from the LoRa
device. Include the Firebase JavaScript SDK in your web page using the Firebase
configuration settings obtained earlier.

 Firebase Authentication (Optional): If you need to authenticate users before accessing


data or making changes to the Firebase Realtime Database, set up Firebase
Authentication and implement user login functionality on your web page.

 Data Sending from LoRa to Firebase: When the LoRa device sends data to the gateway
or LoRaWAN network server, process this data and use the Firebase JavaScript SDK to
send the data to the Firebase Realtime Database. Use functions like push() or set() to
store the data under a specific node in the database.

 Data Retrieval in Web Page: Implement JavaScript code in your web page to listen for
changes in the Firebase Realtime Database. Use the Firebase SDK to retrieve data from
the database and update the web page with the latest data.

 Data Visualization and Presentation: Format and present the data received from Firebase
on the web page in a way that makes sense for your application. You can use charts,
tables, or any other suitable UI elements.

 Realtime Updates: Firebase Realtime Database provides realtime synchronization, so any


changes made to the database will automatically trigger updates on the web page without
the need for manual refreshing.

16
 Security Considerations: Ensure that your Firebase security rules are appropriately
configured to prevent unauthorized access to sensitive data.

 Testing and Debugging: Test the entire flow from LoRa device data transmission to data
presentation on the web page. Use debugging tools and logging to identify and fix any
issues that may arise.

In this, I have used one Heltec WiFi LoRa ESP32 module and DHT11 sensor. First, I
have connected the DHT11sensor with the LoRa transmitter module. Just created an account in
the Google Firebase with my own Email Id. After creating an account, I generated and store the
web API key, database secret Id and real time database URL in the notepad.

Then a code to transmit data to the Google firebase is created and uploaded to the LoRa
module. After receiving data in the Google firebase, A Web application is created using the
HTML to see the Temperature and Humidity Readings instantly. The code uploaded to the LoRa
module contains the WiFi SSID and password to which the LoRa module is connected and the
HTML code contains the Website designing and firebase important details.

The output can be seen in serial monitor of Arduino IDE, Google Firebase real time
database and also in the web application. The main important thing we need in this method is a
Google Firebase account and a proper HTML web design and a proper WiFi connectivity done
in the previous method.

17
RESULT

In this Project work, the transmission of sensor data from one LoRa module to another LoRa
module,web application, google firebase was done successfully and it’s output data is received.

18
Above was a simple web page was designed by the output can be seen, observed and analysed.
The web page was designed using HTML code and linked the firebase authorization id and
secret Application programming interface key.

Data’s were stored and transmitted with the delay of 5 seconds, this will helps in analysing the
conditions further on a daily basis.

19
A same and single output seen by different ways, i.e, by a simply designed web page, through
realtime database of google firebase, and serial monitor of Arduino IDE.

20
REFERENCES

 B. Citoni, F. Fioranelli, M. A. Imran and Q. H. Abbasi, "Internet of Things and


LoRaWAN-Enabled Future Smart Farming," in IEEE Internet of Things Magazine, vol.
2, no. 4, pp. 14-19, December 2019, DOI: 10.1109/IOTM.0001.1900043.

 R. K. Kodali, S. Yerroju and S. Sahu, "Smart Farm Monitoring Using LoRa Enabled
IoT," 2018 Second International Conference on Green Computing and Internet of Things
(ICGCIoT), 2018, pp. 391-394, DOI: 10.1109/ICGCIoT.2018.8753086.

 Nicholas Zinas, Sotirios Kontogiannis, George Kokkonis, Stavros Valsamidis, and


Ioannis Kazanidis. 2017. Proposed open source architecture for Long Range monitoring.
The case study of cattle tracking at Pogoniani. In Proceedings of the 21st Pan-Hellenic
Conference on Informatics (PCI 2017). Association for Computing Machinery, New
York, NY, USA

 M. R. Seye, B. Ngom, B. Gueye and M. Diallo, "A Study of LoRa Coverage: Range
Evaluation and Channel Attenuation Model," 2018 1st International Conference on Smart
Cities and Communities (SCCIC), 2018, pp. 1-4, DOI: 10.1109/SCCIC.2018.8584548.

 K. Tsai, Y. Huang, F. Leu, I. You, Y. Huang and C. Tsai, "AES-128 Based Secure Low
Power Communication for LoRaWAN IoT Environments," in IEEE Access, vol. 6, pp.
45325-45334, 2018, DOI: 10.1109/ACCESS.2018.2852563.

 D. Davcev, K. Mitreski, S. Trajkovic, V. Nikolovski and N. Koteli, "IoT agriculture


system based on LoRaWAN," 2018 14th IEEE International Workshop on Factory
Communication Systems (WFCS), 2018, pp. 1-4, DOI: 10.1109/WFCS.2018.8402368.

 Ray M.K., Oraon A., Kumari R., Shreya S., Prasad D., Nath V. (2021) FPGA-Based
Smart Irrigation System. In: Nath V., Mandal J.K. (eds) Proceedings of the Fourth
International Conference on Microelectronics, Computing and Communication Systems.
Lecture Notes in Electrical Engineering, vol 673. Springer, Singapore.
https://doi.org/10.1007/978-981-15-5546- 6_87.

 Lau X.Y., Soo C.H., Yusof Y., Isaak S. (2021) Integrated Soil Monitoring System for
Internet of Thing (IOT) Applications. In: Md Zain Z. et al. (eds) Proceedings of the 11th
National Technical Seminar on Unmanned System Technology 2019. Lecture Notes in
Electrical Engineering, vol 666. Springer, Singapore.

 M. K. Saini and R. K. Saini, "Agriculture monitoring and prediction using Internet of


Things (IoT)," 2020 Sixth International Conference on Parallel, Distributed and Grid
Computing (PDGC), 2020, pp. 53- 56, DOI: 10.1109/PDGC50313.2020.9315836.

21
 A. Dahane, R. Benameur, B. Kechar and A. Benyamina, "An IoT Based Smart Farming
System Using Machine Learning," 2020 International Symposium on Networks,
Computers and Communications (ISNCC), 2020, pp. 1-6, DOI:
10.1109/ISNCC49221.2020.9297341.

22
ANNEXURE

PROGRAM

1)LoRa to LoRa data transmission

TRANSMITTER CODE:

#include <stdlib.h>
#include <OneWire.h>
#include <DHT.h>
#include <Adafruit_Sensor.h>
#include "heltec.h"
#include "images.h"
#define BAND 510E6 //you can set band here directly,e.g. 868E6,915E6
#define DHTPIN 13
#define DHTTYPE DHT11
#define pinDatos 4
// Example pin number for OneWire communication

unsigned int counter = 0;


String rssi = "RSSI --";
String packSize = "--";
String packet ;

OneWire oneWireObjeto(pinDatos);
DHT sensorDHT(DHTPIN, DHTTYPE);
void logo()
{
Heltec.display->clear();
Heltec.display->drawXbm(0,5,logo_width,logo_height,logo_bits);
Heltec.display->display();
}

void setup()
{
sensorDHT.begin();
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.Heltec.Heltec.LoRa
Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);

Heltec.display->init();
Heltec.display->flipScreenVertically();

23
Heltec.display->setFont(ArialMT_Plain_10);
logo();
delay(1500);
Heltec.display->clear();

Heltec.display->drawString(0, 0, "Heltec.LoRa Initial success!");


Heltec.display->display();
delay(1000);
}

void loop()
{
delay(2000);
float temp = sensorDHT.readTemperature();
char tempstring[20];
dtostrf(temp,3,1,tempstring);
String temperatura(tempstring);
Heltec.display->clear();
Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
Heltec.display->setFont(ArialMT_Plain_10);
Heltec.display->drawString(0, 0, "Sending packet: ");
Heltec.display->setFont(ArialMT_Plain_24);
Heltec.display->drawString(0, 26, temperatura+" C");
Heltec.display->display();
// send packet
LoRa.beginPacket();
/*
* LoRa.setTxPower(txPower,RFOUT_pin);
* txPower -- 0 ~ 20
* RFOUT_pin could be RF_PACONFIG_PASELECT_PABOOST or
RF_PACONFIG_PASELECT_RFO
* - RF_PACONFIG_PASELECT_PABOOST -- LoRa single output via PABOOST,
maximum output 20dBm
* - RF_PACONFIG_PASELECT_RFO -- LoRa single output via RFO_HF /
RFO_LF, maximum output 14dBm
*/
LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
LoRa.print("Temp: ");
LoRa.print(temperatura);
LoRa.endPacket();
counter++;
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

24
RECEIVER CODE:

#include "heltec.h"
#include "images.h"

#define BAND 510E6 //you can set band here directly,e.g. 868E6,915E6
String rssi = "RSSI --";
String packSize = "--";
String packet ;

void logo(){
Heltec.display->clear();
Heltec.display->drawXbm(0,5,logo_width,logo_height,logo_bits);
Heltec.display->display();
}

void LoRaData(){
Heltec.display->clear();
Heltec.display->setTextAlignment(TEXT_ALIGN_LEFT);
Heltec.display->setFont(ArialMT_Plain_16);
Heltec.display->drawString(0 , 15 , "Received "+ packSize + " bytes");
Heltec.display->drawString(0, 0, rssi);
Heltec.display->drawStringMaxWidth(0 , 38 , 128, packet+" c");
Heltec.display->display();
}

void cbk(int packetSize) {


packet ="";
packSize = String(packetSize,DEC);
for (int i = 0; i < packetSize; i++) { packet += (char) LoRa.read(); }
rssi = "RSSI " + String(LoRa.packetRssi(), DEC) ;
LoRaData();
}

void setup() {
//WIFI Kit series V1 not support Vext control
Heltec.begin(true /*DisplayEnable Enable*/, true

25
/*Heltec.Heltec.Heltec.LoRa Disable*/, true /*Serial Enable*/, true
/*PABOOST Enable*/, BAND /*long BAND*/);

Heltec.display->init();
Heltec.display->flipScreenVertically();
Heltec.display->setFont(ArialMT_Plain_10);
logo();
delay(1500);
Heltec.display->clear();

Heltec.display->drawString(0, 0, "Heltec.LoRa Initial success!");


Heltec.display->drawString(0, 10, "Wait for incoming data...");
Heltec.display->display();
delay(1000);
//LoRa.onReceive(cbk);
LoRa.receive();
}

void loop() {
int packetSize = LoRa.parsePacket();
if (packetSize) { cbk(packetSize); }
delay(10);
}

2) LoRa TO WEB SERVER

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <DHT.h>

const char *ssid = "SSN";


const char *password = "Ssn1!Som2@Sase3#";

WebServer server(80);
DHT dht(13, DHT11);

26
void handleRoot() {
char msg[1500];

snprintf(msg, 1500,
"<html>\
<head>\
<meta http-equiv='refresh' content='4'/>\
<meta name='viewport' content='width=device-width, initial-scale=1'>\
<link rel='stylesheet'
href='https://use.fontawesome.com/releases/v5.7.2/css/all.css'
integrity='sha384-
fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHp
vLbHG9Sr' crossorigin='anonymous'>\
<title>ESP32 DHT Server</title>\
<style>\
html { font-family: Arial; display: inline-block; margin: 0px auto; text-
align: center;}\
h2 { font-size: 3.0rem; }\
p { font-size: 3.0rem; }\
.units { font-size: 1.2rem; }\
.dht-labels{ font-size: 1.5rem; vertical-align:middle; padding-bottom:
15px;}\
</style>\
</head>\
<body>\
<h2>ESP32 DHT Server!</h2>\
<p>\
<i class='fas fa-thermometer-half' style='color:#ca3517;'></i>\
<span class='dht-labels'>Temperature</span>\
<span>%.2f</span>\
<sup class='units'>&deg;C</sup>\
</p>\
<p>\
<i class='fas fa-tint' style='color:#00add6;'></i>\
<span class='dht-labels'>Humidity</span>\
<span>%.2f</span>\
<sup class='units'>&percnt;</sup>\
</p>\
</body>\

27
</html>",
readDHTTemperature(), readDHTHumidity()
);
server.send(200, "text/html", msg);
}

void setup(void) {

Serial.begin(115200);
dht.begin();

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection


while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

if (MDNS.begin("esp32")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);

server.begin();
Serial.println("HTTP server started");
}

void loop(void) {
server.handleClient();
delay(2);//allow the cpu to switch to other tasks

28
}

float readDHTTemperature() {
// Sensor readings may also be up to 2 seconds
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
if (isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return -1;
}
else {
Serial.println(t);
return t;
}
}

float readDHTHumidity() {
// Sensor readings may also be up to 2 seconds
float h = dht.readHumidity();
if (isnan(h)) {
Serial.println("Failed to read from DHT sensor!");
return -1;
}
else {
Serial.println(h);
return h;
}
}

3) LoRa to Web Application through Google Firebase:

#include <IOXhop_FirebaseESP32.h>
#include <WiFi.h>
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

29
#define WIFI_SSID "OPPO F17"
#define WIFI_PASSWORD "Naveen@7777"
#define FIREBASE_AUTH "https://heltec-first-default-rtdb.asia-
southeast1.firebasedatabase.app/"
#define FIREBASE_HOST
"vHWZHQ4NNRxHmK7rp4EmvbBrDFHe1TnaAsbcsEVr"
void setup(){
Serial.begin(115200);
Serial.print("DHT TEST");
dht.begin();

WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.println("Connecting");
while(WiFi.status() != WL_CONNECTED){
Serial.println(".");
delay(500);
}
Serial.println();
Serial.println("Connected:");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_AUTH, FIREBASE_HOST);
}
int n=0;
void loop(){
float h=dht.readHumidity();
float t=dht.readTemperature();
if(isnan(h) || isnan(t)){
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity:");
Serial.print(h);
Serial.print("%\t");

Serial.print("Temperature");
Serial.print(t);
Serial.print("*c");

Firebase.setFloat("Humidity:", h);

30
if(Firebase.failed()){
Serial.println("Setting/number failed:");
Serial.println(Firebase.error());
return;
}
Firebase.setFloat("Temperature:", t);
if(Firebase.failed()){
Serial.print("Setting/number failed:");
Serial.println(Firebase.error());
return;
}
Serial.println(" Temperature and Humidity Data Sent Successfully");
}

31

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy