Cov txheej txheem:

ESP32 Lora Thingspeak Gateway Nrog Sensor Node: 9 Kauj Ruam
ESP32 Lora Thingspeak Gateway Nrog Sensor Node: 9 Kauj Ruam

Video: ESP32 Lora Thingspeak Gateway Nrog Sensor Node: 9 Kauj Ruam

Video: ESP32 Lora Thingspeak Gateway Nrog Sensor Node: 9 Kauj Ruam
Video: ESP32 LoRaWAN Gateway tutorial with Sensor Node 2024, Kaum ib hlis
Anonim
ESP32 Lora Thingspeak Rooj vag Nrog Sensor Node
ESP32 Lora Thingspeak Rooj vag Nrog Sensor Node

hauv qhov IoT Project no, Kuv tsim ESP32 LoRa Gateway & kuj tseem ESP32 LoRa Sensor Node los saib xyuas lub sensor nyeem ntawv wirelessly los ntawm ob peb kis nrug. Tus neeg xa ntawv yuav nyeem cov ntaub ntawv huab cua thiab qhov kub uas siv DHT11 Sensor. Tom qab ntawd nws xa cov ntaub ntawv ntawm xov tooj cua LoRa. Cov ntaub ntawv tau txais los ntawm tus txais tus qauv. Tus txais yuav xa cov ntaub ntawv mus rau Thingspeak Server tom qab lub sijhawm tshwj xeeb.

Kauj Ruam 1: Cov Cheeb Tsam Yuav Tsum Tau

1. Pawg ESP32 - 2

2. Lora Module SX1278/SX1276

3. DHT11 Humidity Kub Sensor

4. Cov qhob cij

5. Txuas Jumper Xov

Kauj Ruam 2: Txhim Kho Cov Tsev Qiv Ntawv Yuav Tsum Tau

Peb yuav tsum teeb tsa cov tsev qiv ntawv sib txawv ua ntej:

1. DHT11 Lub Tsev Qiv Ntawv

2. LoRa Library

Kauj Ruam 3: ESP32 LoRa Thingspeak Gateway

ESP32 LoRa Thingspeak Rooj vag
ESP32 LoRa Thingspeak Rooj vag
ESP32 LoRa Thingspeak Rooj vag
ESP32 LoRa Thingspeak Rooj vag

Tam sim no cia peb pom tus xa thiab tus txais xov tooj cua rau tsim ESP32 LoRa Gateway & Sensor Node. Kuv tau sib sau ua ke ob lub Circuit Court ntawm daim ntawv qhia zaub mov. Koj tuaj yeem ua nws ntawm PCB yog tias koj xav tau.

Nov yog ESP32 LoRa Module SX1278 Gateway Circuit. Qhov no ua haujlwm raws li Tus Txais. Cov ntaub ntawv huab cua thiab qhov kub tau txais siv LoRa Xov Tooj Cua & tshaj tawm rau Thingspeak Server.

Kauj Ruam 4: ESP32 LoRa Sensor Node

ESP32 LoRa Sensor Node
ESP32 LoRa Sensor Node
ESP32 LoRa Sensor Node
ESP32 LoRa Sensor Node

Nov yog ESP32 LoRa Sensor Node Circuit nrog DHT11 Sensor. Qhov no ua haujlwm raws li tus xa tawm. Cov ntaub ntawv huab cua thiab qhov kub tau nyeem los ntawm DHT11 Humidity Temperature Sensor thiab xa tawm siv LoRa Xov Tooj Cua.

Kauj ruam 5: Teem Up Thingspeak

Teem Up Thingspeak
Teem Up Thingspeak

Txhawm rau Saib Xyuas Cov Ntaub Ntawv Sensor ntawm Thingspeak Server, koj thawj zaug yuav tsum teeb tsa Thingspeak. Txhawm rau teeb tsa Thingspeak Server, mus saib https://thingspeak.com/. Tsim ib tus as khauj lossis nkag mus yooj yim yog tias koj tau tsim tus lej ua ntej. Tom qab ntawd tsim cov channel tshiab nrog cov ntsiab lus hauv qab no.

Kauj ruam 6: Rooj vag Code

#suav nrog

// Cov tsev qiv ntawv rau LoRa #include #include // txhais cov pins siv los ntawm LoRa transceiver module #define ss 5 #define rst 14 #define dio0 2 #define BAND 433E6 // 433E6 rau Asia, 866E6 rau Europe, 915E6 rau North America // Hloov nrog koj cov ntaub ntawv pov thawj network cov hlua apiKey = "14K8UL2QEK8BTHN6"; // Sau koj li API Sau los ntawm ThingSpeak const char *ssid = "Wifi SSID"; // hloov nrog koj li wifi ssid thiab wpa2 qhov tseem ceeb const char *password = "Password"; const char* neeg rau zaub mov = "api.thingspeak.com"; WiFiClient tus thov kev pab; // Pib hloov pauv kom tau txais thiab khaws LoRa cov ntaub ntawv int rssi; Txoj hlua loRaMessage; Txoj hlua kub; Txoj hlua av noo; Txoj hlua nyeem ntawv ID; // Hloov chaw tso nrog DHT qhov tseem ceeb String processor (const String & var) {//Serial.println(var); yog (var == "TEMPERATURE") {rov kub; } lwm tus yog (var == "HUMIDITY") {xa cov av noo; } lwm yog (var == "RRSI") {rov qab hlua (rssi); } rov qab txoj hlua (); } tsis muaj teeb tsa teeb tsa () {Serial.begin (115200); koj counter; // teeb LoRa transceiver module LoRa.setPins (ss, rst, dio0); // teeb tsa LoRa transceiver module thaum (! LoRa.begin (BAND) && counter <10) {Serial.print ("."); txee ++; ncua (2000); } yog (counter == 10) {// nce kev nyeem ntawv ID ntawm txhua qhov kev nyeem tshiab Serial.println ("Pib LoRa ua tsis tiav!"); } Serial.println ("LoRa Initialization OK!"); ncua (2000); // Txuas rau Wi-nkaus network nrog SSID thiab password Serial.print ("Txuas rau"); Serial.println (ssid); WiFi.begin (ssid, password); thaum (WiFi.status ()! = WL_CONNECTED) {ncua (2000); Serial.print ("."); } // Luam tawm IP chaw nyob thiab pib lub vev xaib Serial.println (""); Serial.println ("Txuas nrog WiFi."); Serial.println ("IP chaw nyob:"); Serial.println (WiFi.localIP ()); } // Nyeem LoRa pob ntawv thiab tau txais lub sensor nyeem tsis tau lub voj () {int packetSize = LoRa.parsePacket (); yog (packetSize) {Serial.print ("Lora pob ntawv tau txais:"); thaum (LoRa.available ()) // Nyeem pob ntawv {Txoj hlua LoRaData = LoRa.readString (); Serial.print (LoRaData); int pos1 = LoRaData.indexOf ('/'); int pos2 = LoRaData.indexOf ('&'); nyeem ID = LoRaData.substring (0, pos1); // Tau txais qhov ntsuas kub ID = LoRaData.substring (pos1 +1, pos2); // Tau txais qhov ntsuas kub = LoRaData.substring (pos2+1, LoRaData.length ()); // Tau txais cov av noo} rssi = LoRa.packetRssi (); // Tau txais RSSI Serial.print ("nrog RSSI"); Serial.println (rssi); } yog (client.connect (server, 80)) // "184.106.153.149" lossis api.thingspeak.com {String postStr = apiKey; postStr += "& field1 ="; postStr += Txoj hlua (nyeem ID); postStr += "& field2 ="; postStr += Txoj hlua (qhov kub thiab txias); postStr += "& teb 3 ="; postStr += Txoj hlua (av noo); postStr += "& field4 ="; postStr += Txoj hlua (rssi); postStr += "\ r / n / r / n / r / n / r / n"; client.print ("POST /hloov tshiab HTTP /1.1 / n"); client.print ("Tus tswv tsev: api.thingspeak.com / n"); client.print ("Kev sib txuas: kaw / n"); client.print ("X-THINGSPEAKAPIKEY:" + apiKey + "\ n"); client.print ("Cov ntsiab lus-Hom: thov/x-www-form-urlencoded / n"); client.print ("Cov ntsiab lus-Ntev:"); client.print (postStr.length ()); client.print ("\ n / n"); client.print (postStr); } // ncua (30000); }

Kauj Ruam 7: Sensor Node Code

#suav nrog

#include // Libraries for LoRa #include "DHT.h" #define DHTPIN 4 // pin qhov twg dht11 txuas nrog DHT dht (DHTPIN, DHT11); // txhais cov pins siv los ntawm LoRa transceiver module #define ss 5 #define rst 14 #define dio0 2 #define BAND 433E6 // 433E6 rau Asia, 866E6 rau Europe, 915E6 rau North America // pob ntawv txee int readingID = 0; int counter = 0; Txoj hlua LoRaMessage = ""; ntab kub = 0; float av noo = 0; // Initialize LoRa module void startLoRA () {LoRa.setPins (ss, rst, dio0); // teeb tsa LoRa transceiver module thaum (! LoRa.begin (BAND) && counter <10) {Serial.print ("."); txee ++; ncua (500); } yog (txee == 10) {// nce kev nyeem ntawv ID ntawm txhua qhov kev nyeem tshiab nyeem ID ++; Serial.println ("Pib LoRa ua tsis tiav!"); } Serial.println ("LoRa Initialization OK!"); ncua (2000); } void startDHT () {if (isnan (humidity) || isnan (temperature)) {Serial.println ("Ua tsis tau tejyam nyeem los ntawm DHT sensor!"); rov qab; }} tsis muaj dab tsi getReadings () {av noo = dht.readHumidity (); kub = dht.readTemperature (); Serial.print (F ("Vaum:")); Serial.print (av noo); Serial.print (F ("% Kub:")); Serial.print (kub); Serial.println (F ("° C")); } void sendReadings () {LoRaMessage = Txoj hlua (nyeem ID) + "/" + Txoj hlua (kub) + "&" + Txoj hlua (av noo); // Xa LoRa pob ntawv rau tus txais LoRa.beginPacket (); LoRa.print (LoRaMessage); LoRa.endPacket (); Serial.print ("Xa pob ntawv:"); Serial.println (nyeem ID); nyeem ID ++; Serial.println (LoRaMessage); } void setup () {// initialize Serial Monitor Serial.begin (115200); dht.begin (); startDHT (); startLoRA (); } tsis muaj dab tsi voj () {getReadings (); xaReadings (); ncua (500); }

Kauj Ruam 8: Saib Xyuas Cov Ntaub Ntawv ntawm Thingspeak Server

Saib xyuas cov ntaub ntawv ntawm Thingspeak Server
Saib xyuas cov ntaub ntawv ntawm Thingspeak Server
Saib xyuas cov ntaub ntawv ntawm Thingspeak Server
Saib xyuas cov ntaub ntawv ntawm Thingspeak Server

Thaum cov cai tau rub tawm, koj tuaj yeem qhib Serial Monitor ntawm ob lub Gateway & Sensor Node Circuit. Koj yuav xa cov ntaub ntawv thiab tau txais yog tias txoj cai raug. Tam sim no koj tuaj yeem mus ntsib Thingspeak Private View. Muaj koj tuaj yeem pom cov ntaub ntawv rau Pob Naj Npawb, Kub, Vaum & Rooj vag tau muab tso tom qab lub sijhawm 15 vib nas this.

Kauj Ruam 9: Cov neeg ua tim khawv

1.

2.

Pom zoo: