Cov txheej txheem:

Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32: 8 Cov Kauj Ruam
Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32: 8 Cov Kauj Ruam

Video: Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32: 8 Cov Kauj Ruam

Video: Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32: 8 Cov Kauj Ruam
Video: saib. - São Paulo Sunset 2024, Kaum ib hlis
Anonim
Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32
Saib Xyuas-Temp-thiab-Vaum-siv-AWS-ESP32

Hauv qhov kev qhia no, peb yuav ntsuas qhov sib txawv ntawm qhov kub thiab txias cov ntaub ntawv siv Temp thiab humidity sensor. Koj tseem yuav kawm paub xa cov ntaub ntawv no mus rau AWS

Kauj ruam 1: HARDWARE THIAB SOFTWARE YUAV TSUM TAU

Kho vajtse:

  • ESP-32: ESP32 ua kom yooj yim siv Arduino IDE thiab Arduino Wire Language rau IoT daim ntawv thov. Qhov ESp32 IoT Module no sib txuas Wi-nkaus, Bluetooth, thiab Bluetooth BLE rau ntau yam kev siv sib txawv. Cov qauv no tau los ua tiav nrog 2 CPU cores uas tuaj yeem tswj tau thiab siv zog ib tus zuj zus, thiab nrog lub moos hloov pauv tau ntawm 80 MHz txog 240 MHz. Qhov ESP32 IoT WiFi BLE Module nrog Kev Sib Txuas USB tau tsim los kom haum rau txhua qhov khoom ncd.io IoT. Saib xyuas cov ntsuas thiab tswj kev xa tawm, FETs, PWM cov tswj, solenoids, li qub, lub cev muaj zog thiab ntau ntxiv los ntawm txhua qhov chaw hauv ntiaj teb no siv nplooj ntawv web lossis nplooj siab rau server. Peb tsim peb tus kheej version ntawm ESP32 kom haum rau NCD IoT cov cuab yeej, muab cov kev xaiv nthuav dav ntau dua li lwm yam cuab yeej hauv ntiaj teb! Kev koom ua ke USB chaw tso cai yooj yim ntawm ESP32. ESP32 IoT WiFi BLE Module yog lub platform zoo kawg rau IoT daim ntawv thov txhim kho. Qhov ESP32 IoT WiFi BLE Module no tuaj yeem tsim kho siv Arduino IDE.
  • IoT Long Range Wireless Kub Thiab Vaum Sensor: Muaj Ntau Yam Wireless Wireless Kub Kub Sensor. Qib nrog Sensor Daws Teeb Meem ntawm ± 1.7%RH ± 0.5 ° C. Ua li 500, 000 Kev xa tawm los ntawm 2 AA Roj Teeb. Measure -40 ° C txog 125 ° C nrog Cov Roj Teeb uas Ciaj sia Cov Kev Ntsuas no. Zoo Tshaj 2 -mais LOS Ntau & 28 mais nrog High-Gain Antennas. Interface rau Raspberry Pi, Microsoft Azure, Arduino thiab Ntau
  • Long-Range Wireless Mesh Modem nrog USB InterfaceLong-Range Wireless Mesh Modem nrog USB Interface

Siv Software:

  • Arduino IDE Cov
  • AWS

Tsev qiv ntawv siv:

  • PubSubClient Library
  • Hlau.h
  • AWS_IOT.h

Kauj Ruam 2: Tshaj Tawm Txoj Cai rau ESP32 Siv Arduino IDE:

Raws li esp32 yog ib feem tseem ceeb tshaj tawm koj cov ntaub ntawv kub thiab av noo rau AWS.

  • Rub tawm thiab suav nrog PubSubClient Library, Wire.h Library, AWS_IOT.h, Wifi.h.
  • Rub tawm Zip cov ntaub ntawv ntawm AWS_IoT, los ntawm qhov muab txuas thiab tom qab muab rho tawm, muab cov tsev qiv ntawv tso rau hauv koj lub tsev qiv ntawv Arduino.

#suav nrog

#include <AWS_IOT.h #include #include #include

  • Koj yuav tsum muab koj lub AWS tshwj xeeb MQTT_TOPIC, AWS_HOST, SSID (WiFi Npe) thiab Lo lus zais ntawm lub network muaj.
  • MQTT lub ncauj lus thiab AWS HOST tuaj yeem sab hauv Yam-Sib Tham ntawm AWS-IoT console.

#define WIFI_SSID "xxxxx" // koj wifi ssid

#define WIFI_PASSWD "xxxxx" // your wifi password #define CLIENT_ID "xxxxx" // yam tshwj xeeb ID, tuaj yeem yog ib tus cim tshwj xeeb #define MQTT_TOPIC "xxxxxx" // ncauj lus rau MQTT cov ntaub ntawv #define AWS_HOST "xxxxxx" // koj host for uploading data to AWS

Txheeb xyuas lub npe sib txawv uas cov ntaub ntawv yuav xa mus rau AWS

koj temp;

int Vaum;

Code to publish data to AWS:

yog (temp == NAN || Vaum == NAN) {// NAN txhais tau tias tsis muaj cov ntaub ntawv

Serial.println ("Nyeem tsis tau."); } lwm tus {// tsim txoj hlua them nyiaj rau tshaj tawm Txoj hlua temp_humidity = "Kub:"; temp_humidity += Txoj hlua (temp); temp_humidity += "° C Vaum:"; temp_humidity += Txoj hlua (Vaum); temp_humidity += " %";

temp_humidity.toCharArray (payload, 40);

Serial.println ("Luam tawm:-"); Serial.println (them nyiaj); if (aws.publish (MQTT_TOPIC, payload) == 0) {// luam tawm payload thiab xa rov qab 0 thaum ua tiav Serial.println ("Success / n"); } lwm {Serial.println ("Failed! / n"); }}

  • Sau thiab xa cov cai theESP32_AWS.ino.
  • Txhawm rau txheeb xyuas qhov kev sib txuas ntawm lub cuab yeej thiab cov ntaub ntawv xa mus, qhib lub ntsuas saib. Yog tias tsis pom cov lus teb, sim tshem koj lub ESP32 thiab tom qab ntawd txuas nws dua. Nco ntsoov tias tus nqi baud ntawm Serial monitor tau teeb tsa rau tib qho uas tau teev tseg hauv koj tus lej 115200.

Kauj Ruam 3: Serial Monitor Output

Serial Monitor Output
Serial Monitor Output

Kauj Ruam 4: Ua kom AWS Ua Haujlwm

AWS Work
AWS Work
AWS Work
AWS Work
AWS Work
AWS Work

TSHUAB NTAWV THIAB CERTIFICATE

THING: Nws yog qhov sawv cev virtual ntawm koj lub cuab yeej.

CERTIFICATE: Pov thawj qhov tseeb ntawm tus THING.

  • Open AWS-IoT.
  • Nyem rau ntawm tswj -THING -Register THING.
  • Nyem rau tsim ib yam nkaus.
  • Muab lub npe thiab hom.
  • Nyem rau tom ntej no.
  • Tam sim no koj daim ntawv pov thawj nplooj ntawv yuav qhib, Nyem rau Tsim Daim Ntawv Pov Thawj.
  • Rub tawm cov Ntawv Pov Thawj no, feem ntau yog tus yuam sij ntiag tug, daim ntawv pov thawj rau qhov no thiab root_ca thiab khaws cia rau hauv cov ntawv cais. daim ntawv pov thawj ntawv tais ceev tseg.

Kauj Ruam 5: Tsim Txoj Cai

Tsim Txoj Cai
Tsim Txoj Cai
Tsim Txoj Cai
Tsim Txoj Cai
Tsim Txoj Cai
Tsim Txoj Cai

Nws txiav txim siab qhov haujlwm twg lub cuab yeej lossis tus neeg siv tuaj yeem nkag tau.

  • Mus rau AWS-IoT interface, Nyem rau Secure-Policies.
  • Nyem rau Tsim.
  • Sau tag nrho cov ntsiab lus tsim nyog xws li lub npe txoj cai, Nyem Tsim.
  • Tam sim no rov qab mus rau AWS-IoT interface, Nyem rau Secure-Certificates thiab txuas txoj cai tsim tam sim no rau nws.

Kauj Ruam 6: Ntxiv Tus Kheej Ntiag Tug, Daim Ntawv Pov Thawj thiab Root_CA rau Code

Ntxiv Ntiag Tug, Ntawv Pov Thawj thiab Root_CA rau Code
Ntxiv Ntiag Tug, Ntawv Pov Thawj thiab Root_CA rau Code
Ntxiv Ntiag Tug, Ntawv Pov Thawj thiab Root_CA rau Code
Ntxiv Ntiag Tug, Ntawv Pov Thawj thiab Root_CA rau Code
  • Qhib koj daim ntawv pov thawj rub tawm hauv koj cov ntawv sau (Notepad ++), feem ntau yog tus yuam sij ntiag tug, root_CA thiab daim ntawv pov thawj ntawm yam thiab kho lawv raws li muab hauv qab no.
  • Tam sim no qhib koj daim ntawv AWS_IoT hauv koj lub tsev qiv ntawv Arduino -My Document. Mus rau C: / Users / xyz / Documents / Arduino / libraries / AWS_IOT / src, nyem rau ntawm aws_iot_certficates.c, qhib nws ntawm tus editor thiab muab tag nrho cov ntawv pov thawj kho lawv nyob ntawm qhov chaw xav tau, txuag nws.

Kauj Ruam 7: Tau Txais Kev Tso Tawm-

Tau Txais Cov Zis
Tau Txais Cov Zis
Tau Txais Cov Zis
Tau Txais Cov Zis
  • Mus sim hauv AWS_IoT console.
  • Sau koj li MQTT cov ncauj lus rau Cov npe sau npe hauv koj daim ntawv pov thawj xeem.
  • Tam sim no koj tuaj yeem saib koj cov ntaub ntawv huab cua thiab av noo.

Pom zoo: