Cov txheej txheem:
- Kauj Ruam 1: BoM - Cov Nqi Khoom
- Kauj ruam 2: Hw
- Kauj Ruam 3: Micropython, REPL, Jupyter
- Kauj ruam 4: Sensors
- Kauj Ruam 5: Kev ntes thiab nthuav tawm hauv ib cheeb tsam Txhua Cov Ntaub Ntawv Sensor
- Kauj Ruam 6: Khiav Txoj Cai Chaw Nyob Hauv Zos ntawm ESP Pib-pib
- Kauj Ruam 7: Txuas ESP mus rau WiFi Hauv Zos
- Kauj ruam 8: ThingSpeak
- Kauj Ruam 9: MQTT raws tu qauv thiab ThingSpeak Kev Sib Txuas
- Kauj ruam 10: Sensor Cov Ntaub Ntawv Logger
- Kauj ruam 11: The ThingView App
- Kauj Ruam 12: Xaus
Video: IoT Ua Yooj Yim: ESP-MicroPython-MQTT-ThingSpeak: 12 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Hauv kuv qhov kev qhia yav dhau los, MicroPython ntawm ESP siv Jupyter, peb tau kawm paub yuav teeb tsa thiab khiav MicroPython ntawm ESP li cas. Siv Jupyter Phau Ntawv los ua peb ib puag ncig kev txhim kho, peb tseem kawm paub yuav nyeem li cas los ntawm lub ntsuas cua (Kub, Vaum, thiab Luminosity), Peb siv ntau txoj kev sib txuas lus thiab cov txheej txheem, Analog, Digital, 1-Wire thiab I2C, qhov kawg no los tso saib peb cov ntes cov ntaub ntawv ntawm OLED zaub.
Tam sim no, ntawm qhov kev qhia no siv MQTT raws tu qauv, peb yuav tau txais txhua cov ntaub ntawv khaws tseg, xa lawv mus rau IoT cov kev pabcuam, ThingSpeak.com thiab mus rau lub App txawb (Thingsview), qhov uas peb tuaj yeem nkag mus thiab ua si nrog cov ntaub ntawv.
Ntawm no, daim duab thaiv ntawm peb tes num:
Kauj Ruam 1: BoM - Cov Nqi Khoom
- NodeMCU - US $ 8.39
- DHT22 Kub thiab Txheeb Ze Cov Vaum Sensor - USD 9.95
- DS18B20 Waterproof Kub Sensor - USD 5.95
- OLED Zaub SSD1366- USD 8.99 (yeem)
- LDR (1 x)
- LEDs (1x) (Tsis teb los tau)
- Laub Khawm (1x)
- Kuj Resistor 4K7 ohm (2x)
- Resistor 10K ohm (1x)
- Resistor 220 ohm (1x) Cov
Kauj ruam 2: Hw
Hw uas peb yuav siv ntawm no ib txwm yog tib yam siv hauv kev qhia: Micropython ntawm ESP Siv Jupyter. Xa mus rau nws rau txhua qhov kev sib txuas HW.
Qhov tshwj xeeb yog Servo, uas peb yuav tsis raug siv hauv txoj haujlwm no.
Saum toj no koj tuaj yeem pom HW tag nrho. Txuas cov cuab yeej raws li qhia muaj.
Kauj Ruam 3: Micropython, REPL, Jupyter
Koj yuav tsum muaj tus neeg txhais lus Micropython ntsaws rau hauv koj lub cuab yeej ESP. Thaum thauj khoom, koj yuav tsum tau teeb tsa koj li ESP siv ib txoj hauv kev twg muaj/IDEs muaj, xws li:
- REPL
- Jupyter Phau Ntawv
- Mu
- ESPCut (Windows nkaus xwb)
- … lwm
Ntawm kuv qhov kev qhia, Micropython ntawm ESP Siv Jupyter, Kuv tau piav qhia yuav ua li cas rub tawm thiab teeb tsa MicroPython tus neeg txhais lus, ESPTool los tswj ESP cov cuab yeej thiab yuav siv Jupyter Notebook li Kev Txhim Kho Ib puag ncig li cas. Xav tias dawb siv qhov uas yooj yim dua rau koj.
Kuv ib txwm ua txhua qhov kev txhim kho ntawm Jupyter Notebook, thiab thaum kuv tau txais tus lej kawg, kuv theej lawv mus rau Geany thiab thauj nws ntawm kuv ESP siv Ampy.
Kauj ruam 4: Sensors
Cia peb nruab cov tsev qiv ntawv, txheeb xyuas GPIO, tsim khoom, ua haujlwm rau txhua lub ntsuas tus kheej:
A. DHT (Kub thiab Vaum)
Wb Nruab DHT lub tsev qiv ntawv thiab tsim cov khoom:
los ntawm dht ntshuam DHT22
los ntawm tshuab ntshuam Pin dht22 = DHT22 (Pin (12))
Tam sim no, tsim muaj nuj nqi los nyeem DHT sensor:
def nyeemDht ():
dht22.measure () rov qab dht22.temperature (), dht22.humidity () Kuaj DHT muaj nuj nqi
print (nyeemDht ())
Qhov tshwm sim yuav tsum yog piv txwv:
(17.7, 43.4)
B. DS18B20 (Sab Nraud Kub)
Cia Nruab Nruab cov tsev qiv ntawv thiab tsim cov khoom:
ntshuam onewire, ds18x20
lub sijhawm ntshuam # Txheeb xyuas tus lej twg tus pin 1-ntaus ntawv yuav txuas nrog ==> tus pin 2 (D4) dat = Tus Pin (2) # tsim cov khoom siv ib leeg ds = ds18x20. DS18X20 (onewire. OneWire (dat)) Luam theej duab rau cov cuab yeej ntawm no
sensors = ds.scan ()
print ('pom cov cuab yeej:', cov cim)
Qhov tshwm sim luam tawm tsis yog qhov tseem ceeb tiag tiag, yam peb yuav xav tau yog thawj qhov ntsuas pom: cov cim [0]. Thiab tam sim no, peb tuaj yeem tsim txoj haujlwm los nyeem cov ntaub ntawv sensor:
def nyeem ntawv ():
ds.convert_temp () time.sleep_ms (750) rov qab ds.read_temp (sensors [0])
Nws yog ib qho tseem ceeb los ntsuas lub ntsuas ntsuas siv qhov tsim muaj nuj nqi
print (nyeemDs ()) Yog tias koj tau txais qhov ntsuas kub, koj cov cai raug
17.5
C. LDR (Luminosity)
LDR yuav siv tus pin analog ntawm peb ESP (nws tsuas yog ib qho ntawm ESP8266 thiab ntau rau ESP32).
Xa mus rau kuv qhov ESP32 qhia kom paub meej.
Zoo ib yam li ua ntej:
# ntshuam tsev qiv ntawv
los ntawm tshuab ntshuam ADC # Txhais cov khoom adc = ADC (0) Ib txoj haujlwm yooj yim: adc.read () tuaj yeem siv los nyeem ADC tus nqi. Tab sis nco ntsoov tias sab hauv ADC yuav hloov hluav taws xob nruab nrab ntawm 0 thiab 3.3V hauv cov xov tooj digital qhov sib txawv, sib txawv ntawm 0 txog 1023. Thaum peb txaus siab rau "Luminosity", peb yuav txiav txim siab Max teeb raws li qhov siab tshaj plaws tau txais los ntawm lub ntsuas (hauv kuv rooj plaub 900) thiab lub teeb pom kev tsawg kawg nkaus uas nyob hauv kuv rooj plaub yog 40. Muaj cov txiaj ntsig no peb tuaj yeem "daim ntawv qhia" tus nqi ntawm 40 txog 900 hauv 0 txog 100% ntawm qhov ci ntsa iab. Rau qhov ntawd, peb yuav tsim txoj haujlwm tshiab
def nyeemLdr ():
lumPerct = (adc.read ()-40)*(10/86) # hloov pauv hauv feem pua ("daim ntawv qhia") rov qab puag ncig (lumPerct)
Koj yuav tsum ntsuas qhov ua haujlwm siv luam ntawv (readLDR ()). Qhov tshwm sim yuav tsum yog tus lej nruab nrab ntawm o thiab 100.
D. Push-Button (Digital Input)
Ntawm no peb tab tom siv Push-Button ua lub ntsuas hluav taws xob, tab sis nws tuaj yeem yog "ncha" ntawm tus ua haujlwm (Lub twj tso kua mis uas tau qhib ON/OFF, piv txwv).
# txhais tus pin 13 raws li kev tawm tswv yim thiab qhib lub zog Rub sab hauv sab hauv:
khawm = Pin (13, Pin. IN, Pin. PULL_UP) # Muaj nuj nqi los nyeem lub xeev khawm: def readBut (): rov qab khawm.value ()
Koj tuaj yeem sim lub khawm nyeem ntawv ua haujlwm luam ntawv (readBut ()). W/o nias qhov tshwm sim yuav tsum yog "1". Nias lub pob, qhov tshwm sim yuav tsum yog "0"
Kauj Ruam 5: Kev ntes thiab nthuav tawm hauv ib cheeb tsam Txhua Cov Ntaub Ntawv Sensor
Tam sim no peb tau tsim ib txoj haujlwm rau txhua lub ntsuas, cia tsim qhov kawg uas yuav nyeem tag nrho lawv tib lub sijhawm:
def colectData (): cov
temp, hum, = readDht () extTemp = readDs () lum = readLdr () butSts = readBut () rov temp, hum, extTemp, lum, butSts Tam sim no yog tias koj siv
print (colectData ()) cov
Yuav ua rau tuple uas suav nrog txhua cov ntaub ntawv raug ntes los ntawm cov cim:
(17.4, 45.2, 17.3125, 103, 1)
Peb tseem tuaj yeem xaiv tau, qhia cov ntaub ntawv ntawm cov zaub hauv zos:
# ntshuam tsev qiv ntawv thiab tsim cov khoom i2c
los ntawm tshuab ntshuam I2C i2c = I2C (scl = Pin (5), sda = Pin (4)) # ntshuam tsev qiv ntawv thiab tsim cov khoom oled ntshuam ssd1306 i2c = I2C (scl = Pin (5), sda = Pin (4)) oled = ssd1306. SSD1306_I2C (128, 64, i2c, 0x3c) # tsim kom muaj nuj nqi: def displayData (temp, hum, extTemp, lum, butSts): oled.fill (0) oled.text ("Temp:" + str (temp) + "oC", 0, 4) oled.text ("Hum:" + str (hum) + "%", 0, 16) oled.text ("ExtTemp:" + str (extTemp) + "oC", 0, 29) oled.text ("Lumin:" + str (lum) + "%", 0, 43) oled.text ("Khawm:" + str (butSts), 0, 57) oled.show () # tso saib cov ntaub ntawv siv lub luag haujlwm displayData (temp, hum, extTemp, lum, butSts)
Raws li qhov kev xaiv, Kuv tseem yuav suav nrog LED kom ON thaum peb pib nyeem ntawv cov cim, mus OFF tom qab cov ntaub ntawv raug tshwm. Ua qhov no yuav pab kom paub meej tias qhov haujlwm tau ua haujlwm thaum peb muaj ESP txiav tawm ntawm lub PC thiab ua haujlwm tau zoo.
Yog li, lub luag haujlwm tseem ceeb yuav yog:
# Lub luag haujlwm tseem ceeb los nyeem txhua lub ntsuas
def lub ntsiab (): # qhia cov ntaub ntawv nrog kev ua haujlwm led.on () temp, hum, extTemp, lum, butSts = colectData () displayData (temp, hum, extTemp, lum, butSts) led.off ()
Yog li, ua qhov tseem ceeb (), peb yuav tau txais cov ntaub ntawv ntsuas pom ntawm OLED raws li qhia hauv daim duab.
Kauj Ruam 6: Khiav Txoj Cai Chaw Nyob Hauv Zos ntawm ESP Pib-pib
Peb tuaj yeem muaj txhua yam uas tau tsim los txog tam sim no ntawm ib daim ntawv kom ua tiav los ntawm peb ESP.
Cia peb qhib ib phau ntawv nyeem thiab dhau los ntawm nws txhua tus lej:
# ntshuam cov tsev qiv ntawv dav dav
los ntawm lub tshuab ntshuam Pin lub sijhawm ntshuam # txhais tus pin 0 raws li tso tawm coj = Pin (0, Pin. OUT) # DHT los ntawm dht ntshuam DHT22 dht22 = DHT22 (Pin (12)) # Muaj nuj nqi los nyeem DHT def readDht (): dht22.measure () rov qab dht22.temperature (), dht22.humidity () # DS18B20 ntshuam onewire, ds18x20 # Txheeb xyuas tus pin twg 1-xaim ntaus ntawv yuav txuas nrog ==> pin 2 (D4) dat = Pin (2) # Tsim lub onewire object ds = ds18x20. DS18X20 (onewire. OneWire (dat)) # scan rau cov cuab yeej ntawm lub tsheb npav sensors = ds.scan () # muaj nuj nqi los nyeem DS18B20 def readDs (): ds.convert_temp () time.sleep_ms (750) rov qab puag ncig (ds.read_temp (sensors [0]), 1) # LDR los ntawm lub tshuab ntshuam ADC # Txheeb xyuas cov khoom adc = ADC (0) #function nyeem cov teeb pom kev zoo def readLdr (): lumPerct = (adc.read ()-40) *(10/86) # hloov pauv nyob rau hauv feem pua ("daim ntawv qhia chaw") rov qab puag ncig (lumPerct) # txhais tus pin 13 raws li kev tawm tswv yim thiab qhib lub zog rub sab hauv sab hauv: khawm = Pin (13, Pin. IN, Pin. PULL_UP) # Muaj nuj nqi los nyeem lub xeev khawm: def readBut (): rov qab khawm.value () # Muaj nuj nqi los nyeem txhua cov ntaub ntawv: def cole ctData (): temp, hum, = readDht () extTemp = readDs () lum = readLdr () butSts = readBut () rov temp, hum, extTemp, lum, butSts # ntshuam tsev qiv ntawv thiab tsim cov khoom i2c los ntawm tshuab ntshuam I2C i2c = I2C (scl = Pin (5), sda = Pin (4)) # ntshuam tsev qiv ntawv thiab tsim cov khoom oled ntshuam ssd1306 i2c = I2C (scl = Pin (5), sda = Pin (4)) oled = ssd1306. SSD1306_I2C (128, 64, i2c, 0x3c) # tsim kom muaj nuj nqi: def displayData (temp, hum, extTemp, lum, butSts): oled.fill (0) oled.text ("Temp:" + str (temp) + "oC", 0, 4) oled.text ("Hum:" + str (hum) + "%", 0, 16) oled.text ("ExtTemp:" + str (extTemp) + "oC", 0, 29) oled. text ("Lumin:" + str (lum) + "%", 0, 43) oled.text ("Khawm:" + str (butSts), 0, 57) oled.show () # Lub luag haujlwm tseem ceeb nyeem tag nrho cov ntsuas def lub ntsiab (): # qhia cov ntaub ntawv nrog kev ua haujlwm led.on () temp, hum, extTemp, lum, butSts = colectData () displayData (temp, hum, extTemp, lum, butSts) led.off () '' ''- ----- khiav lub luag haujlwm tseem ceeb -------- '' 'main ()
Txuag nws, piv txwv li localData.py.
Txhawm rau khiav cov cai no ncaj qha rau ntawm koj lub davhlau ya nyob twg koj yuav xav tau Ampy.
Ua ntej, ntawm Terminal qhia rau Ampy peb Serial chaw nres nkoj:
export AMPY_PORT =/dev/tty. SLAB_USBtoUART
Tam sim no, peb tuaj yeem pom cov ntaub ntawv uas nyob hauv peb ESP cov npe hauv paus:
ams lis
Raws li cov lus teb, peb yuav tau txais boot.py, uas yog thawj cov ntawv uas yuav khiav hauv kab ke.
Tam sim no, cia siv Ampy txhawm rau thauj peb li nab nab Script LocalData.py ua /main.py, yog li ntawv yuav khiav tom qab khau raj:
ampy tso localData.py /main /py
Yog tias peb siv qhov hais kom ua amp tam sim no, koj yuav pom 2 cov ntawv hauv ESP: boot.py thiab main.py
Rov pib dua koj li ESP, yuav ua rau qhov program localData.py khiav tau zoo, tso tawm cov ntaub ntawv ntsuas ntawm lub vijtsam.
Lub davhlau ya nyob twg Terminal saum toj no qhia txog yam peb tau ua.
Nrog cov cai saum toj no, cov zaub yuav pom ib zaug nkaus xwb, tab sis peb tuaj yeem txhais lub voj ntawm lub luag haujlwm tseem ceeb (), uas yuav qhia cov ntaub ntawv ntawm txhua lub sijhawm teev tseg (PUB_TIME_SEC), thiab piv txwv li, txog thaum peb nias lub pob:
# voj tau txais cov ntaub ntawv kom txog thaum khawm tau nyem
thaum khawm.value (): coj.on () temp, hum, extTemp, lum, butSts = colectData () displayData (temp, hum, extTemp, lum, butSts) led.off () time.sleep (PUB_TIME_SEC)
PUB_TIME_SEC qhov txawv txav yuav tsum tau tshaj tawm los ntawm lub sijhawm uas koj xav tau koj cov qauv.
Txhawm rau txhim kho peb cov cai ntau ntxiv, yuav yog qhov zoo los qhia tias peb yuav tawm ntawm lub voj, rau qhov peb yuav piav qhia 2 qhov kev ua haujlwm tshiab, ib qho yog kom pom cov zaub thiab lwm qhov ntsais lub LED ntawm qee lub sijhawm.
# Cov zaub ntshiab:
def displayClear (): oled.fill (0) oled.show () # tsim kom muaj nuj nqis ntsais muag def blinkLed (num): rau kuv hauv ntau (0, num): led.on () pw tsaug zog (0.5) led.off () pw tsaug zog (0.5)
Yog li, tam sim no peb tuaj yeem rov sau peb lub ntsiab () ua haujlwm:
thaum khawm.value ():
led.on () temp, hum, extTemp, lum, butSts = colectData () displayData (temp, hum, extTemp, lum, butSts) led.off () time.sleep (PUB_TIME_SEC) blinkLed (3) displayClear ()
Txoj cai kawg tuaj yeem rub tawm los ntawm kuv GitHub: localData.py thiab tseem Jupyter Phau Ntawv siv los txhim kho cov lej tag nrho: Jupyter Local Data Development.
Kauj Ruam 7: Txuas ESP mus rau WiFi Hauv Zos
Lub network qauv siv los teeb tsa kev sib txuas WiFi. Muaj ob lub WiFi cuam tshuam, ib qho rau lub chaw nres tsheb (thaum ESP8266 txuas mus rau lub router) thiab ib qho rau qhov chaw nkag (rau lwm yam khoom siv txuas rau ESP8266). Ntawm no, peb ESP yuav txuas nrog lub network hauv zos. Cia peb hu lub tsev qiv ntawv thiab txheeb xyuas peb cov ntaub ntawv pov thawj network:
ntshuam network
WiFi_SSID = "Koj li SSID" WiFi_PASS = "Koj tus password"
Cov haujlwm hauv qab no tuaj yeem siv los txuas ESP rau koj lub network hauv zej zog:
def ua_connect ():
wlan = network. WLAN (network. STA_IF) wlan.active (True) yog tias tsis wlan.isconnected (): luam tawm ('txuas rau network …') wlan.connect (WiFi_SSID, WiFi_SSID) thaum tsis wlan.isconnected (): kis print ('network teeb tsa:', wlan.ifconfig ())
Khiav lub luag haujlwm, koj tuaj yeem tau txais qhov txiaj ntsig IP chaw nyob:
ua_connect ()
Qhov tshwm sim yuav yog:
network teeb tsa: ('10.0.1.2 ',' 255.255.255.0 ', '10.0.1.1', '10.0.1.1 ')
Puas yog, hauv kuv qhov xwm txheej, 10.0.1.2, yog ESP IP chaw nyob.
Kauj ruam 8: ThingSpeak
Txog tam sim no, peb tau kawm paub yuav khaws cov ntaub ntawv los ntawm txhua lub ntsuas cua, nthuav tawm lawv ntawm peb OLED. Tam sim no, nws yog lub sijhawm los saib yuav xa cov ntaub ntawv no mus rau IoT platform, ThingSpeak.
Cia peb pib!
Ua ntej, koj yuav tsum muaj tus as khauj ntawm ThinkSpeak.com. Tom ntej no, ua raws cov lus qhia los tsim Channel thiab sau koj li Channel ID thiab Sau API Key.
Saum toj no koj tuaj yeem pom 5 thaj chaw uas yuav siv rau ntawm peb Channel.
Kauj Ruam 9: MQTT raws tu qauv thiab ThingSpeak Kev Sib Txuas
MQTT yog tshaj tawm/sau npe ua vaj tsev uas tau tsim los txuas rau txuas bandwidth thiab lub zog-txwv cov cuab yeej hla wireless tes hauj lwm. Nws yog cov txheej txheem yooj yim thiab hnyav uas ua haujlwm dhau TCP/IP qhov nyob lossis WebSockets. MQTT hla WebSockets tuaj yeem ruaj ntseg nrog SSL. Kev tshaj tawm/sau npe ua haujlwm ua kom cov lus raug thawb mus rau cov neeg siv khoom yam tsis muaj lub cuab yeej xav tau los mus pov ntawv tawm suab tsis tu ncua.
MQTT tus tswv lag luam yog lub hauv paus ntsiab lus ntawm kev sib txuas lus, thiab nws yog lub luag haujlwm xa tag nrho cov lus ntawm tus xa thiab tus txais raug cai. Tus neeg siv khoom yog ib qho khoom siv uas txuas rau tus broker thiab tuaj yeem tshaj tawm lossis sau npe rau cov ncauj lus kom nkag tau cov ntaub ntawv. Ib lub ncauj lus muaj cov ntaub ntawv qhia txog tus broker. Txhua tus neeg siv khoom uas xav xa lus tshaj tawm lawv mus rau qee lub ncauj lus, thiab txhua tus neeg siv khoom uas xav tau txais cov lus sau npe rau qee lub ncauj lus. Tus broker xa tag nrho cov lus nrog cov ncauj lus sib txuas rau cov neeg siv khoom tsim nyog.
ThingSpeak ™ muaj tus broker MQTT ntawm qhov URL mqtt.thingspeak.com thiab chaw nres nkoj 1883. Tus ThingSpeak tus broker txhawb nqa ob qho MQTT tshaj tawm thiab MQTT sau npe.
Hauv peb qhov xwm txheej, peb yuav siv: MQTT Tshaj Tawm
Daim duab piav qhia lub ntsiab lus qauv. Sau API Key yuav tsum tau tshaj tawm. Tus broker lees paub qhov tseeb CONNECT thov nrog CONNACK.
MQTT raws tu qauv tau txhawb nqa hauv lub tsev qiv ntawv built-in hauv Micropython binaries-cov txheej txheem no tuaj yeem siv xa cov ntaub ntawv los ntawm koj li ESP8266, dhau WIFI, mus rau huab huab dawb.
Cia peb siv lub tsev qiv ntawv umqtt.simple:
los ntawm umqtt.simple import MQTTClient
Thiab paub peb tus SERVER ID, nws muaj peev xwm tsim peb MQTT cov khoom siv:
SERVER = "mqtt.thingspeak.com"
tus neeg siv = MQTTClient ("umqtt_client", SERVER)
Tam sim no, muaj koj daim ntawv pov thawj ThingSpeak ntawm tes:
CHANNEL_ID = "Koj li CHANNEL ID"
WRITE_API_KEY = "Koj KEY NTAWM NO"
Cia peb tsim peb MQTT "Xai":
ntsiab lus = "raws/" + CHANNEL_ID + "/tshaj tawm/" + WRITE_API_KEY
Cia peb tau txais peb cov ntaub ntawv xa mus rau ThingSpeak IoT Service, siv cov haujlwm tsim thiab koom nrog nws cov lus teb rau cov ntaub ntawv hloov pauv tshwj xeeb:
temp, hum, extTemp, lum, butSts = colectData ()
Nrog cov kev hloov pauv tshiab no, peb tuaj yeem tsim peb "MQTT Them Nyiaj":
payload = "field1 ="+str (temp)+"& field2 ="+str (hum)+"& field3 ="+str (extTemp)+"& field4 ="+str (lum)+"& field5 ="+str (butSts)
Thiab qhov ntawd yog nws! Peb npaj tau xa cov ntaub ntawv mus rau ThinsSpeak, yooj yim siv 3 kab ntawm cov lej hauv qab no:
client.connect ()
client.publish (ncauj lus, them nyiaj) client.disconnect ()
Tam sim no, yog tias koj mus rau koj nplooj ntawv nplooj ntawv (zoo li kuv li saum toj no) koj yuav pom tias txhua ntawm 5 thaj chaw yuav muaj cov ntaub ntawv cuam tshuam nrog koj lub ntsuas cua.
Kauj ruam 10: Sensor Cov Ntaub Ntawv Logger
Tam sim no, uas peb paub tias nrog tsuas yog ob peb kab ntawm txoj cai nws tuaj yeem rub cov ntaub ntawv mus rau IoT cov kev pabcuam, cia peb tsim lub voj ua haujlwm kom ua nws lub sijhawm ib ntus (zoo ib yam li peb tau ua nrog "Cov ntaub ntawv hauv zos. ").
Siv tib qhov sib txawv (PUB_TIME_SEC), tshaj tawm ua ntej, lub luag haujlwm tseem ceeb yooj yim kom khaws cov ntaub ntawv tsis tu ncua, txiav lawv ntawm peb cov channel yuav yog:
thaum Muaj Tseeb:
temp, hum, extTemp, lum, butSts = colectData () payload = "field1 ="+str (temp)+"& field2 ="+str (hum)+"& field3 ="+str (extTemp)+"& field4 ="+ str (lum)+"& field5 ="+str (butSts) client.connect () client.publish (ntsiab lus, them nyiaj) client.disconnect () time.sleep (PUB_TIME_SEC)
Nco ntsoov tias tsuas yog "them nyiaj" yuav tsum tau hloov kho tshiab, ib zaug "ntsiab lus" cuam tshuam nrog peb cov peev txheej channel thiab yuav tsis hloov pauv.
Nrhiav koj nplooj ntawv ThingSpeak channel, koj yuav pom tias cov ntaub ntawv yuav raug thauj mus los tsis tu ncua rau txhua qhov haujlwm. Koj tuaj yeem npog LDR, muab koj txhais tes tso rau qhov ntsuas kub/hum, nias lub pob, thiab lwm yam thiab saib yuav ua li cas cov channel yuav cia li "nkag mus" cov ntaub ntawv no rau kev tshuaj xyuas yav tom ntej.
Feem ntau, rau Kev Txheeb Xyuas Cov Ntaub Ntawv, peb yuav tsum sim siv lub zog kom tsawg li sai tau, yog li, peb yuav tsis siv LED lossis tso saib hauv zos. Tsis tas li, nws ib txwm muaj nrog ESP cov cuab yeej, muab tso rau "pw tsaug zog", qhov twg microprocessor yuav nyob ntawm nws lub xeev ntawm lub zog tsawg kawg kom txog rau thaum nws yog lub sijhawm los khaws cov ntaub ntawv thiab xa lawv mus rau IoT platform.
Tab sis, ib zaug ntawm no lub tswv yim tab tom kawm, cia peb suav nrog cov zaub thiab LED ib yam li peb tau ua dhau los. Ua qhov ntawd, peb qhov "logger" muaj nuj nqi yuav yog:
thaum khawm.value ():
led.on () temp, hum, extTemp, lum, butSts = colectData () displayData (temp, hum, extTemp, lum, butSts) led.off () temp, hum, extTemp, lum, butSts = colectData () payload = "field1 ="+str (temp)+"& field2 ="+str (hum)+"& field3 ="+str (extTemp)+"& field4 ="+str (lum)+"& field5 ="+str (butSts) tus neeg siv khoom.connect () client.publish (ncauj lus, them nyiaj) client.disconnect () time.sleep (PUB_TIME_SEC) blinkLed (3) displayClear ()
Ua tiav microPython tsab ntawv tuaj yeem pom ntawm no: dataLoggerTS_EXT.py thiab Jupyter phau ntawv uas tau siv rau kev txhim kho kuj tseem tuaj yeem pom ntawm no: IoT ThingSpeak Data Logger EXT.ipynb.
Txhawm rau upload tsab ntawv ntawm ESP, ntawm koj lub davhlau ya nyob twg siv cov lus txib:
ampy muab dataLoggerTS.py /main.py
Thiab nias lub ESP - pib dua khawm. Koj yuav muaj ESP ntes cov ntaub ntawv thiab nkag mus rau ntawm ThingSpeak.com kom txog thaum lub hauv qab raug nias (tos kom LED ntsais 3 zaug thiab OLED tua).
Kauj ruam 11: The ThingView App
Cov ntaub ntawv nkag tuaj yeem pom ncaj qha ntawm ThingSpeak.com lub xaib lossis ntawm APP, piv txwv li, ThingsView!
ThingView yog APP tsim los ntawm CINETICA, uas ua rau koj pom koj li ThingSpeak raws hauv txoj hauv kev yooj yim, tsuas yog nkag mus rau tus lej ID thiab koj npaj mus.
Txog rau pej xeem cov channel, daim ntawv thov yuav hwm koj lub qhov rais teeb tsa: xim, sijhawm, hom kab ntawv thiab tus lej ua tiav. Qhov tam sim no txhawb nqa kab thiab kab kab kos, kab ntawv sib cais tau tshwm ua kab kab.
Rau cov channel ntiag tug, cov ntaub ntawv yuav raug nthuav tawm siv qhov kev teeb tsa ua ntej, vim tsis muaj txoj hauv kev los nyeem cov qhov rai ntiag tug teeb tsa nrog tus yuam sij API nkaus xwb.
ThingView APP tuaj yeem rub tawm rau ANDROID thiab IPHONE.
Kauj Ruam 12: Xaus
Raws li ib txwm muaj, Kuv vam tias txoj haujlwm no tuaj yeem pab lwm tus pom lawv txoj hauv kev mus rau hauv lub ntiaj teb zoo ntawm hluav taws xob!
Yog xav paub ntxiv thiab tus lej kawg, thov mus saib kuv qhov kev tso nyiaj GitHub: IoT_TS_MQTT
Yog xav paub ntau ntxiv, thov mus saib kuv qhov blog: MJRoBot.org
Saludos los ntawm sab qab teb ntawm lub ntiaj teb!
Pom koj hauv kuv cov lus qhia tom ntej!
Ua tsaug, Marcelo
Pom zoo:
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: 4 Cov Kauj Ruam (nrog Duab)
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: Hnub no kuv xav qhia yuav ua li cas kom pom lub teeb pom kev zoo los ntawm lub zog xa hluav taws xob tsis siv hluav taws xob los ntawm tus txhuam txhuam hniav thiab lub tshuab solenoid valve coils uas tau khaws los ntawm scrapyard.Ua ntej pib, thov saib cov vis dis aus hauv qab no:
Txoj Kev Yooj Yim thiab Yooj Yim Los Hloov Koj Lub Xauv Screen hauv 6 Cov Kauj Ruam Yooj Yim (Windows 8-10): 7 Kauj Ruam
Txoj Kev Yooj Yim thiab Yooj Yim Los Hloov Koj Lub Xauv Screen hauv 6 Cov Kauj Ruam Yooj Yim (Windows 8-10): Xav hloov pauv yam ntawm koj lub laptop lossis PC? Xav tau kev hloov pauv hauv koj qhov chaw? Ua raws cov kauj ruam no yooj yim thiab yooj yim kom ua tiav koj tus kheej lub computer ntsuas phoo
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS YOOJ YIM: 4 Cov Kauj Ruam
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS: Nyob zoo txhua tus hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas kom yooj yim " SOIL DRYNESS SENSOR ". Qhuav ntawm cov av tau txheeb xyuas siv qhov taw qhia coj. Lub teeb ci wi
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: 4 Cov Kauj Ruam
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: Nyeem … lub npe
YOOJ YIM YOOJ YIM TSHAJ PLAWS COMPACT LIGHT !! 3 KAUJ RUAM YOOJ YIM !!: 3 Kauj Ruam
YOOJ YIM YOOJ YIM TSHAJ PLAWS COMPACT LIGHT !! 3 KAUJ RUAM YOOJ YIM !!: Koj Yuav Tsum Tau Li Cas - Tin ntawv ci 1 AA roj teeb (qee lub roj teeb AAA yuav ua haujlwm) 1 Mini Lub Teeb Pom Kev (lub teeb siv rau feem ntau lub teeb nyem; xa mus rau daim duab) Tus Tswj (yog xav tau)