Cov txheej txheem:

Siv Analog Sensors Nrog ESP8266: 5 Cov Kauj Ruam
Siv Analog Sensors Nrog ESP8266: 5 Cov Kauj Ruam

Video: Siv Analog Sensors Nrog ESP8266: 5 Cov Kauj Ruam

Video: Siv Analog Sensors Nrog ESP8266: 5 Cov Kauj Ruam
Video: Лучшие камуфляжные часы G-Shock-Топ 7 лучших камуфляжных ч... 2024, Kaum ib hlis
Anonim
Siv Analog Sensors Nrog ESP8266
Siv Analog Sensors Nrog ESP8266

Ib qho piv txwv-rau-digital hloov pauv (ADC, A/D, A – D, lossis A-to-D) yog lub kaw lus uas hloov pauv cov teeb liab analog mus rau hauv cov teeb liab. A/D hloov pauv txhais cov cim hluav taws xob analog rau cov ntaub ntawv ua haujlwm. Nrog cov khoom sib piv kev ua tau zoo, lub zog, tus nqi, thiab sizeneed. Cov ntaub ntawv hloov pauv no pab txhawb kev hloov pauv tau meej thiab muaj zog hauv ntau yam kev siv xws li kev sib txuas lus, lub zog, kev noj qab haus huv, kev ntsuas thiab ntsuas, lub cev muaj zog thiab kev tswj hwm lub zog, kev siv tshuab ua haujlwm, thiab kev siv dav hlau/tiv thaiv. Ntau yam khoom siv hloov pauv A/D tau muab los pab tus kws tshaj lij hauv txhua qhov haujlwm theem, los ntawm kev xaiv cov khoom mus rau kev tsim qauv.

Hnub no, peb yuav siv qhov hloov pauv sib piv rau digital nrog ESP8266. Wb pib.. !!

Kauj Ruam 1: Cov Khoom Uas Peb Xav Tau

Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau

1. MCP3425 ADC Converter

MCP3425 yog 1-Channel Analog to Digital Converter nrog 16-ntsis kev daws teeb meem, hom phiaj haum rau kev ntsuas qis-siab siab ntsuas kev ntsuas. MCP3425 muaj peev xwm nyeem qhov sib piv ntawm 15 qhov piv txwv thib ob nrog 16-ntsis kev daws teeb meem lossis 240 qhov piv txwv thib ob ntawm 12-ntsis kev daws teeb meem.

2. Adafruit Huzzah ESP8266

ESP8266 yog lub platform zoo kawg rau IoT daim ntawv thov txhim kho. ESP8266 tus txheej txheem los ntawm Espressif yog 80 MHz microcontroller nrog WiFi puv ntoob-kawg thiab TCP/IP pawg nrog DNS txhawb nqa ib yam. ESP8266 muab kev paub tab rau kev tshuaj xyuas thiab tswj kev siv daim ntawv Arduino Wire Language thiab Arduino IDE.

3. ESP8266 USB Programmer

Qhov ESP8266 tus tswv tsev tau tsim tshwj xeeb los ntawm Contol Txhua Yam rau Adafruit Huzzah version ntawm ESP8266, tso cai rau I²C kev sib txuas lus sib txuas.

4. I²C Txuas Cable

Contol Txhua yam kuj tau tsim I²C kev txuas cable uas muaj nyob ntawm qhov txuas saum toj no.

5. Mini USB Cable

Lub mini USB cable Lub hwj chim muab yog qhov kev xaiv zoo tshaj rau kev txhawb nqa Adafruit Huzzah ESP8266.

Kauj Ruam 2: Kev Sib Txuas Kho Vajtse

Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas

Feem ntau, kev sib txuas yog ib feem yooj yim ntawm txoj haujlwm no. Ua raws cov lus qhia thiab cov duab, thiab koj yuav tsum tsis muaj teeb meem.

Ua ntej tshaj plaws, coj Adafruit Huzzah ESP8266 thiab muab tso rau ntawm USB Programmer (nrog Sab Hauv Lub ntsej muag I²C Port). Nias ESP8266 maj mam muab tso rau hauv USB Programmer thiab peb tau ua tiav nrog cov kauj ruam no (Saib daim duab #1).

Coj tus I²C Cable thiab txuas nws mus rau qhov chaw nres nkoj nkag ntawm Sensor. Kom ua haujlwm tau zoo ntawm cov kab no, thov nco ntsoov I²C Cov Tawm Ib Leeg txuas rau I²C Cov Tswv Yim. Tam sim no, txuas lwm qhov kawg ntawm tib I²C Cable rau USB Programmer nrog Adafruit Huzzah ESP8266 tau teeb tsa nws (Saib daim duab #2).

Nco tseg: Cov xaim xim av yuav tsum ib txwm ua raws hauv av (GND) kev sib txuas ntawm cov khoom siv ntawm ib lub cuab yeej thiab cov tswv yim ntawm lwm lub cuab yeej.

Txuas lub Mini USB cable rau hauv lub zog txuas ntawm Adafruit Huzzah ESP8266. Qhov kev sib txuas zaum kawg yuav zoo li hauv daim duab #3.

Kauj ruam 3: Code

ESP Code rau Adafruit Huzzah ESP8266 thiab MCP3425 ADC Converter muaj nyob ntawm peb GitHub chaw cia khoom.

Ua ntej mus rau txoj cai, nco ntsoov koj tau nyeem cov lus qhia muab rau hauv Readme cov ntaub ntawv thiab teeb tsa koj li Adafruit Huzzah ESP8266 kom haum. Nws yuav siv sijhawm tsuas yog 5 feeb los teeb tsa ESP.

Txhawm rau kom yooj yim rau koj, koj tuaj yeem luam qhov ESP code ua haujlwm rau lub ntsuas no los ntawm no kuj:

// Tshaj tawm nrog daim ntawv tso cai pub dawb.// Siv nws txhua txoj hauv kev koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm. // MCP3425 // Cov cai no tau tsim los ua haujlwm nrog MCP3425_I2CADC I2C Mini Module muaj los ntawm ControlEverything.com. //

#suav nrog

#include #include #include

// MCP3425 I2C chaw nyob yog 0x68 (104)

#define Ntxiv 0x68

const char* ssid = "koj lub network ssid";

const char* password = "koj tus password"; ntab siab, cTemp, fTemp;

ESP8266WebServer server (80);

tsis muaj dab tsi handleroot ()

{unsigned int cov ntaub ntawv [2];

// Pib I2C Kev Kis

Wire.beginTransmission (Addr); // Xa cov lus txib teeb tsa // Kev hloov pauv mus tas li, 12-ntsis daws teeb meem Wire.write (0x10); // Nres I2C Kev Xa Xov Hlau.endTransmission (); ncua (300);

// Pib I2C Kev Kis

Wire.beginTransmission (Addr); // Xaiv cov ntaub ntawv sau npe Wire.write (0x00); // Nres I2C Kis Kab Hlau.endTransmission ();

// Thov 2 bytes ntawm cov ntaub ntawv

Wire.requestFrom (Addr, 2);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// raw_adc msb, raw_adc lsb yog (Wire.available () == 2) {data [0] = Wire.read (); cov ntaub ntawv [1] = Wire.read (); }

// Hloov cov ntaub ntawv mus rau 12-ntsis

int raw_adc = (cov ntaub ntawv [0] & 0x0F) * 256 + cov ntaub ntawv [1]; yog (raw_adc> 2047) {raw_adc -= 4096; }

// Cov ntaub ntawv tso tawm rau tus saib xyuas

Serial.print ("Tus nqi Digital ntawm Analog Input:"); Serial.println (raw_adc); ncua (500);

// Tso cov ntaub ntawv rau lub web server

server.sendContent ("<meta http-equiv = 'refresh' cov ntsiab lus = '3'""

Tswj txhua yam

www.controleverything.com

MCP3425 Sensor I2C Mini Module

"); server.sendContent ("

Tus nqi digital ntawm cov tswv yim Analog: " + Txoj hlua (raw_adc));}

void teeb tsa ()

{// Initialise I2C kev sib txuas lus li MASTER Wire.begin (2, 14); // Initialise serial communication, set baud rate = 115200 Serial.begin (115200);

// Txuas rau WiFi network

WiFi.begin (ssid, password);

// Tos rau kev txuas

thaum (WiFi.status ()! = WL_CONNECTED) {ncua (500); Serial.print ("."); } Serial.println (""); Serial.print ("Txuas nrog"); Serial.println (ssid);

// Tau txais IP chaw nyob ntawm ESP8266

Serial.print ("IP chaw nyob:"); Serial.println (WiFi.localIP ());

// Pib server

server.on ("/", tus tuav tes); server.begin (); Serial.println ("HTTP server tau pib"); }

void lub voj ()

{server.handleClient (); }

Kauj ruam 4: Ua haujlwm

Ua hauj lwm
Ua hauj lwm

Rub tawm (gitpull) lossis luam cov cai thiab qhib nws hauv Arduino IDE.

Ua ke thiab Tshaj tawm cov cai thiab pom cov txiaj ntsig ntawm koj li Serial Monitor.

Nco tseg: Ua ntej rub tawm, xyuas kom tseeb tias koj nkag mus rau koj li SSID network thiab tus password hauv tus lej.

Luam tus IP chaw nyob ntawm ESP8266 los ntawm Serial Monitor thiab muab tso rau hauv koj lub vev xaib. Koj yuav pom lub vev xaib nrog cov digital tso tawm ntawm analog nyeem ntawv nyeem. Cov txiaj ntsig ntawm lub ntsuas ntawm Serial Monitor thiab Web Server tau qhia hauv daim duab saum toj no.

Kauj Ruam 5: Cov ntawv thov thiab Nta

Cov cuab yeej MCP3425 tuaj yeem siv rau ntau yam kev ntsuas siab sib piv-rau-digital cov ntaub ntawv hloov pauv qhov twg tsim qhov yooj yim, lub zog qis, thiab hneev taw me me yog qhov kev txiav txim siab loj. Cov ntawv thov tseem ceeb suav nrog Kev Ntsuas Hluav Taws Xob, ntsuas qhov ntsuas thiab ntsuas ntsuas roj, ntsuas kub nrog RTD, Thermistor, thiab Thermocouple, Choj Pom Zoo rau Siab, Nyuaj, thiab Quab Yuam.

ADC cov hloov pauv ua kom muaj kev hloov pauv tau raug thiab ntseeg tau hauv ntau qhov kev thov xws li kev sib txuas lus, lub zog, kev noj qab haus huv, kev ntsuas thiab ntsuas, lub cev muaj zog thiab kev tswj hwm lub zog, kev siv tshuab ua haujlwm, thiab kev siv dav hlau/tiv thaiv.

Nrog kev pab los ntawm ESP8266, peb tuaj yeem nce nws lub peev xwm kom ntev dua. Peb tuaj yeem tswj hwm peb cov cuab yeej siv thiab saib xyuas lawv cov kev ua tau zoo los ntawm peb lub desktop thiab cov khoom siv mobile. Peb tuaj yeem khaws thiab tswj cov ntaub ntawv online thiab kawm lawv txhua lub sijhawm rau kev hloov kho. Ntau daim ntawv thov suav nrog Tsev Automation, Mesh Network, Muaj Wireless Tswj, Tus Saib Xyuas Me Nyuam, Sensor Networks, Wearable Electronics, Wi-Fi Qhov Chaw-paub Devices, Wi-Fi Position System Beacons.

Tsis tas li, koj tuaj yeem tshawb xyuas peb qhov blog ntawm Tsev Automation nrog Lub Teeb Sensor thiab ESP8266.

Pom zoo: