Cov txheej txheem:

Lora Gateway Raws Li MicroPython ESP32: 10 Cov Kauj Ruam (nrog Duab)
Lora Gateway Raws Li MicroPython ESP32: 10 Cov Kauj Ruam (nrog Duab)

Video: Lora Gateway Raws Li MicroPython ESP32: 10 Cov Kauj Ruam (nrog Duab)

Video: Lora Gateway Raws Li MicroPython ESP32: 10 Cov Kauj Ruam (nrog Duab)
Video: LoRa - Long-Range Radio for IoT | Arduino, ESP32, RPI Pico 2024, Hlis ntuj nqeg
Anonim
Lora Rooj vag Raws Li MicroPython ESP32
Lora Rooj vag Raws Li MicroPython ESP32
Lora Rooj vag Raws Li MicroPython ESP32
Lora Rooj vag Raws Li MicroPython ESP32

Lora tau nrov heev nyob rau xyoo tas los no. Qhov kev sib txuas lus wireless siv cov thev naus laus zis no feem ntau pheej yig (siv dawb spectrum), qhov loj me me, kev siv hluav taws xob zoo thiab muaj kev sib txuas lus ntev, thiab feem ntau yog siv rau kev sib tham sib tham ntawm IoT cov dav hlau lossis cov ntaub ntawv sib pauv nrog tus tswv tsev. Muaj ntau ntau LoRa cov qauv ntawm kev ua lag luam, xws li RFM96W, uas tau nruab nrog SX1278 (sib xws) nti, uas yog me me heev. Kuv siv nws nrog MakePython ESP32 ua lub qhov rooj.

Tom ntej no, Kuv yuav siv ob LoRa nodes xa cov ntaub ntawv ntsuas kub thiab av noo mus rau lub qhov rooj, thiab tom qab ntawd xa nws mus rau Is Taws Nem los ntawm lub qhov rooj. Ntawm no koj yuav kawm paub yuav ua li cas upload cov ntaub ntawv nyob deb ntawm ntau LoRa nodes rau huab los ntawm lub qhov rooj.

Kauj Ruam 1: Cov khoom siv

Khoom siv
Khoom siv

1*MakePython ESP32

MakePython ESP32 yog ESP32 pawg thawj coj nrog kev sib xyaw SSD1306 OLED zaub.

2*Maduino LoRa Xov tooj cua

Maduino Lora Radio yog IoT (Internet ntawm yam) Kev daws teeb meem raws li Atmel's Atmega328P MCU thiab Lora module. Nws tuaj yeem yog txoj haujlwm tiag tiag rau IoT cov haujlwm (tshwj xeeb tshaj yog ntev-ntau, daim ntawv thov qis zog)

2*DHT11

1*MakePython Lora

Kauj ruam 2: LoRa Node

LoRa Node
LoRa Node
LoRa Node
LoRa Node

Nov yog qhov txheej txheem ntawm Maduino Lora Radio.

Arduino Lora Radio module ua LoRa node, peb siv nws xa cov ntaub ntawv ntsuas kub thiab av noo mus rau lub qhov rooj.

(Qhov WiKi no qhia yuav siv Maduino Lora Radio li cas thiab xa thiab txais cov ntaub ntawv)

Kauj Ruam 3: Node thiab Sensor Kev Sib Txuas

Node thiab Sensor Kev Sib Txuas
Node thiab Sensor Kev Sib Txuas
Node thiab Sensor Kev Sib Txuas
Node thiab Sensor Kev Sib Txuas

VCC thiab GND ntawm DHT11 txuas nrog 3V3 thiab GND ntawm Maduino, thiab DATA tus pin txuas nrog D4 ntawm Maduino.

Node 0 nyob hauv lub tiaj ua si, node 1 yog nyob hauv chaw ua haujlwm nyob ze lub tuam txhab, lawv nyob deb li 2 kilometers sib nrug, thiab tom qab ntawd kuv tau txais lawv cov ntaub ntawv ntsuas kub thiab av noo hauv tsev

Kauj Ruam 4: Xa Cov Ntaub Ntawv mus rau Lub Rooj Vag

Rub tawm TransmitterDHT11.ino, qhib nws ntawm Arduino IDE.

Thaum ntxiv ib qho, hloov kho tus lej raws li. Piv txwv li, tam sim no siv 2 cov node, thawj qhov hloov kho nodenum = 0 los khiav qhov haujlwm, qhov thib ob ntawm kev hloov kho nodenum = 1 los khiav qhov haujlwm, thiab ntxiv rau, koj tuaj yeem ntxiv ntau ntxiv.

int16_t pob ntawv = 0; // pob ntawv txee, peb nce ib xmission

int16_t nodenum = 0; // Hloov tus lej naj npawb

Sau cov ntaub ntawv thiab luam tawm

Cov lus xov = "#"+(Txoj hlua) nodenum+"Vaum:"+(Txoj hlua) av noo+"% Kub:"+(Txoj hlua) kub+"C"+"num:"+(String) packetnum; Serial.println (xov); packetnum ++;

Xa lus mus rau rf95_server

uint8_t radioPacket [message.length ()+1];

message.toCharArray (radioPacket, message.length ()+1); radioPacket [message.length ()+1] = '\ 0'; rf95.send ((uint8_t *) radioPacket, message.length ()+1);

Qhib lub ntsuas saib, koj tuaj yeem pom cov ntaub ntawv ntsuas kub thiab av noo, thiab xa tawm.

#0 Vaum: 6.00% Kub: 27.00C tus lej: 0

Kev xa tawm: Xa mus rau rf95_server Xa … Tos rau pob ntawv kom tiav … Tos kom teb … Tsis teb, puas muaj tus mloog nyob ib puag ncig?

Muab nws tso tseg, tam sim no peb yuav tsum ua Lora Gateway.

Kauj Ruam 5: MakePython Lora

MakePython Lora
MakePython Lora
MakePython Lora
MakePython Lora
MakePython Lora
MakePython Lora

Nov yog tus lej sib thooj ntawm RFM96W module thiab MakePython ESP32. Txhawm rau pab txhawb kev sib txuas nrog MakePython ESP32, Kuv tau ua lub rooj tsav xwm hauv Circuit Court nrog RFM96W module. Yog lawm, muaj ob lub RFM96W ntawm nws, uas tuaj yeem xa thiab txais cov ntaub ntawv tib lub sijhawm, tab sis tam sim no kuv tsuas xav tau ib qho.

Kauj Ruam 6: LoRaWAN Rooj vag

LoRaWAN Rooj vag
LoRaWAN Rooj vag

LoRaWAN yog lub zog hluav taws xob qis hauv cheeb tsam sib txuas raws li LoRa, uas tuaj yeem muab ib qho: kev siv hluav taws xob tsawg, kev nthuav dav, kev ua haujlwm zoo, thiab muaj kev nyab xeeb nyob deb wireless network.

Sib sau MakePython Lora thiab ESP32 los ua lub qhov rooj uas tuaj yeem txais cov ntaub ntawv nyob deb thiab xa mus rau Is Taws Nem.

Kauj ruam 7: Download tau Code

Rub tawm tag nrho 'xxx.py' cov ntaub ntawv los ntawm WiKi thiab xa lawv mus rau ESP32.

Qhib LoRaDuplexCallback.py cov ntaub ntawv, Koj yuav tsum tau kho qee yam kom koj li ESP32 tuaj yeem txuas rau lub network thiab xa cov ntaub ntawv mus rau server.

Hloov kho API_KEY koj tau txais hauv ThingSpeak (Kuv yuav qhia yuav ua li cas thiaj li tau txais nws tom qab)

#https://thingspeak.com/channels/1047479

API_KEY = 'UBHIRHVV9THUJVUI'

Hloov kho SSID thiab PSW txhawm rau txuas WiFi

ssid = "Makerfabs"

pswd = "20160704"

Kauj Ruam 8: Tau Txais Cov Ntaub Ntawv

Nrhiav qhov on_receive (lora, them nyiaj) ua haujlwm hauv LoRaDuplexCallback.py cov ntaub ntawv, qhov twg koj tuaj yeem qhia ESP32 yuav ua dab tsi tom qab tau txais cov ntaub ntawv. Cov cai hauv qab no cais tawm thiab nthuav tawm cov ntaub ntawv tau txais qhov kub thiab txias.

def on_receive (lora, them nyiaj):

lora.blink_led () rssi = lora.packetRssi () sim: ntev = len (payload) -1 myStr = str ((payload [4: ntev]), 'utf-8') length1 = myStr.find (':') myNum1 = myStr [(length1+1):(length1+6)] myNum2 = myStr [(length1+20):(length1+25)] print ("*** Tau txais cov lus *** / n {}". format (payload)) yog config_lora. IS_LORA_OLED: lora.show_packet (("{}". hom ntawv (payload [4: ntev])), rssi) yog wlan.isconnected (): thoob ntiaj teb msgCount luam tawm ('Xa mus rau network …') node = int (str (payload [5: 6], 'utf-8')) if node == 0: URL = "https://api.thingspeak.com/update?api_key="+API_KEY+"& field1 = "+myNum1+" & field2 = "+myNum2 res = urequests.get (URL) luam tawm (res.text) elif node == 1: URL =" https://api.thingspeak.com/update?api_key= "+API_KEY+" & field3 = "+myNum1+" & field4 = "+myNum2 res = urequests.get (URL) luam tawm (res.text) tshwj tsis yog kev zam li e: print (e) print (" with RSSI {} n ".format (rssi))

Txiav txim tus lej kom paub qhov txawv ntawm cov nodes, thiab xa cov ntaub ntawv mus rau Is Taws Nem los ntawm URL, peb tuaj yeem saib xyuas cov ntaub ntawv nyob deb ntawm cov ntshav sib txawv ntawm txhua lub sijhawm. Koj tuaj yeem ntxiv ntau qhov ntxiv thiab hloov pauv zoo ib yam rau cov cai.

yog node == 0:

URL = "https://api.thingspeak.com/update?api_key="+API_KEY+"& field1 ="+myNum1+"& field2 ="+myNum2 res = urequests.get (URL) luam tawm (res.text)

Kauj Ruam 9: Siv ThingSpeak IoT

Siv ThingSpeak IoT
Siv ThingSpeak IoT
Siv ThingSpeak IoT
Siv ThingSpeak IoT
Siv ThingSpeak IoT
Siv ThingSpeak IoT

Cov kauj ruam:

  1. Sau npe tus account hauv https://thingspeak.com/. Yog tias koj twb muaj lawm, kos npe ncaj qha.
  2. Nyem rau Channel Tshiab los tsim qhov tshiab ThingSpeak channel.
  3. Lub npe nkag, Nqe lus piav qhia, Xaiv teb 1. Tom qab ntawd txuag cov channel hauv qab.
  4. Nyem rau API Keys xaiv, luam API Key, peb yuav siv nws hauv txoj haujlwm.

Kauj ruam 10: Qhov tshwm sim

Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim
Qhov tshwm sim

Koj tuaj yeem pom cov ntaub ntawv ntawm node 0 thiab node 1 ntawm lub vijtsam, txawm hais tias lawv nyob nrug deb 2 kilometers.

Nkag mus rau hauv koj tus account ThingSpeak thiab nyem rau ntawm cov channel koj tsim, koj tuaj yeem pom cov ntaub ntawv tso tawm qhov kub thiab txias.

Daim teb 1 daim duab thiab daim duab 2 daim duab yog cov av noo thiab cov ntaub ntawv ntsuas kub ntawm Lora node 0, thiab daim teb 3 daim duab thiab daim duab 4 daim duab yog cov av noo thiab ntsuas kub ntawm Lora node 1.

Pom zoo: