Cov txheej txheem:

Multi-channel Wifi Voltage & Meter Tam Sim No: 11 Kauj Ruam (nrog Duab)
Multi-channel Wifi Voltage & Meter Tam Sim No: 11 Kauj Ruam (nrog Duab)

Video: Multi-channel Wifi Voltage & Meter Tam Sim No: 11 Kauj Ruam (nrog Duab)

Video: Multi-channel Wifi Voltage & Meter Tam Sim No: 11 Kauj Ruam (nrog Duab)
Video: Tswv Yexus lub neej thaum pib txug thaum xaus 2024, Kaum ib hlis
Anonim
Multi-channel Wifi Voltage & Meter Tam Sim No
Multi-channel Wifi Voltage & Meter Tam Sim No

Thaum ua zaub mov noj, ib qho feem ntau yuav tsum tau saib xyuas qhov sib txawv ntawm qhov Circuit Court ib zaug.

Txhawm rau zam qhov mob uas yuav tsum tau ntsuas qhov ntsuas qhov ntsuas ntawm ib qho mus rau lwm qhov, Kuv xav tsim ntau qhov channel voltage thiab ntsuas tam sim no.

Pawg Ina260 los ntawm Adafruit muab txoj hauv kev zoo thiab muaj txiaj ntsig zoo rau kev ua li ntawd. Nws muaj qhov ntsuas hluav taws xob raug thiab ntsuas tam sim no nrog tus choj I2C sib xyaw (txuag ntau tus pin thaum sib txuas 3 ntawm lawv!).

Tib yam uas ploj lawm yog cov zaub. Li no qhov kev txiav txim siab los nqua cov laug cam mus rau ESP32 pawg thawj coj txhim kho, uas tuaj yeem nqa tau lub vev xaib yooj yim los nthuav qhia cov khoom ntsuas ntawm lub PC/mobile screen.

Khoom siv

3 x Ina260 adafruit board

3 x header pins nrog tus pin ntev

Min 6 jumper xov hlau

1 x ESP32 Wrover-B (lossis Wifi lwm lub rooj tsavxwm nrog I2C txhawb nqa)

2 x 19 tus lej pin header (yog tias tsim nyog)

1 x PCB lossis Perfboard

1 x 3.3 V fais fab mov

Kauj Ruam 1: Rhuav Peb Lub Rooj INA

Solder Peb INA Boards
Solder Peb INA Boards

Thawj kauj ruam yog sib sau ua ke peb pawg INA260.

Cov lus qhia zoo heev tuaj yeem nrhiav tau ntawm Adafruit lub vev xaib. Ua raws li Adafruit cov lus qhia sib dhos.

Yuav kom tuaj yeem teeb lawv nyob rau ib sab ntawm ib sab siv tus pin ntev lub taub hau ntau dua li xa cov kab xev!

Kauj Ruam 2: Kho Peb Qhov Chaw Sib Txawv I2C

Kho peb Qhov Chaw Sib Txawv I2C
Kho peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C
Txhim Kho Peb Qhov Chaw Sib Txawv I2C

I2C yog cov txheej txheem sib txuas rau ob-xaim sib txuas los txuas cov cuab yeej siv qis dua qhov nyob deb. Ib tus tuaj yeem txuas mus txog 127 tus qhev. Ntawm ib lub tsheb npav txhua lub cuab yeej xav tau los ntawm tus cim I2C chaw nyob. I2C qhov chaw nyob ntawm lub cuab yeej feem ntau nyuaj siv rau hauv lub nti ntawm lub cuab yeej. Txhawm rau txuas tib lub cuab yeej ntawm ib lub npav, cov chaw tsim khoom feem ntau tawm qhov muaj peev xwm hloov pauv I2C chaw nyob los ntawm kev teeb tsa tus qauv ntawm tus pin ua ke.

Qhov no kuj yog rooj plaub rau peb pawg INA260. Cov cuab yeej muaj ob tus lej chaw nyob, A0 thiab A1 uas tuaj yeem txuas nrog GND, VS, SCL lossis SDA los teeb tsa qhov chaw nyob uas xav tau. Hauv cov ntaub ntawv ntawm INA260 nti los ntawm cov cuab yeej texas, ib tus tuaj yeem pom cov npe ntawm tus pin txuas rau txhua ntawm 16 qhov chaw nyob tau.

Pawg adafruit txwv qhov no rau 4 pawg los ntawm kev nthuav tawm ob daim ntaub uas tuaj yeem siv los rub A0 thiab/lossis A1 rau VS. Qhov chaw nyob tsis raug ntawm INA260 pawg thawj coj yog 0x40.

Koj ua tiav cov theem no los ntawm kev muab chaw nyob sib txawv rau ob lub rooj sib tham:

Los ntawm kev siv A0 ncoo ntawm pawg thawj coj thib ob koj teeb nws qhov chaw nyob rau: 0x41 (lossis 1000001 BIN)

Los ntawm kev siv A1 ncoo ntawm pawg thawj coj thib peb koj muab qhov chaw nyob rau: 0x44 (lossis 1000100 BIN)

Kauj Ruam 3: Txuas Ina Boards rau ESP32

Txuas Ina Boards rau ESP32
Txuas Ina Boards rau ESP32

Tam sim no peb tau muab cov chaw sib txawv I2C rau txhua ntawm INA cov laug cam, nws yog lub sijhawm los txuas lawv rau ESP32 pawg thawj coj saib!

Ib daim duab saum toj no, txuas

1) tus pin VCC rau tus pin 3.3V

2) tus pin GND rau tus pin GND

3) SDA tus pin rau GPIO tus pin 21

4) SCL tus pin rau GPIO tus pin 22

Kuv tau siv PCB tsim los ua kev sib txuas vim nws yog ib feem ntawm txoj haujlwm loj dua (WiFi hloov pauv qhov hluav taws xob nrog kev hloov kho tam sim no txwv - vam tias yuav ua tus qhia rau qhov no ib yam nkaus).

Koj tuaj yeem siv lwm txoj hauv kev rau kev sib txuas, qhov no yuav yog daim txiag ntoo uas koj tau siv lawm lossis siv lub khob cij. Ob leeg yuav ua haujlwm zoo ib yam.

Kauj Ruam 4: Nruab ESP32 Board hauv Arduino IDE

Nruab ESP32 Board hauv Arduino IDE
Nruab ESP32 Board hauv Arduino IDE

Tam sim no peb tau txuas cov laug cam rau ib leeg, nws yog lub sijhawm los tshuaj xyuas qhov txuas.

Peb yuav ua qhov ntawd los ntawm kev sau cov I2C chaw nyob ntawm Ina cov laug cam.

Pawg ESP32 ua haujlwm zoo nrog Arduino IDE.

Yog li cia peb teeb tsa ESP32 pawg thawj coj hauv Arduino siv Tus Thawj Saib Xyuas Haujlwm.

Kauj Ruam 5: Txheeb xyuas Ina rau ESP32 Kev Sib Txuas Siv I2C Scanner

Txheeb xyuas Ina rau ESP32 Kev Sib Txuas Siv I2C Scanner
Txheeb xyuas Ina rau ESP32 Kev Sib Txuas Siv I2C Scanner

Peb yuav siv qhov yooj yim I2C chaw nyob scanner kom ntseeg tau kev sib txuas ntawm ESP32 thiab Ina260 cov laug cam.

I2C chaw nyob tus lej ntsuas tus lej tuaj yeem theej muab tso rau hauv qhov haujlwm Arduino khoob.

Cov cai tau raug coj los ntawm Arduino cc lub vev xaib:

// -------------------------------------- // i2c_scanner // // Version 1/ / Qhov haujlwm no (lossis tus lej uas zoo li nws) // tuaj yeem pom nyob hauv ntau qhov chaw. // Piv txwv li ntawm Arduino.cc lub rooj sab laj. // Tus thawj sau tsis paub. // Version 2, Juni 2012, Siv Arduino 1.0.1 // Hloov kho kom yooj yim li sai tau los ntawm Arduino.cc tus neeg siv Krodal // Version 3, Feb 26 2013 // V3 los ntawm louarnold // Version 4, Peb Hlis 3, 2013, Siv Arduino 1.0.3 // los ntawm Arduino.cc tus neeg siv Krodal. // Hloov pauv los ntawm louarnold tshem tawm. // Txheeb chaw nyob hloov pauv los ntawm 0… 127 rau 1… 119, // raws li i2c scanner los ntawm Nick Gammon // https://www.gammon.com.au/forum/?id=10896 // Version 5, Lub Peb Hlis 28, 2013 // Raws li version 4, tab sis chaw nyob scans tam sim no rau 127. // Lub sensor zoo li siv qhov chaw nyob 120. // Version 6, Kaum Ib Hlis 27, 2015. // Ntxiv rau tos rau Leonardo cov lus sib txuas. // // // Cov duab kos no ntsuas tus qauv 7-ntsis chaw nyob // Cov cuab yeej nrog qhov chaw nyob me ntsis siab dua yuav tsis pom zoo. // #suav nrog qhov tsis muaj teeb tsa teeb tsa () {Wire.begin (); Serial.begin (9600); thaum (! Serial); // Leonardo: tos saib daim ntawv Serial.println ("\ nI2C Scanner"); } void loop () {byte yuam kev, chaw nyob; koj nDevices; Serial.println ("Luam theej duab …"); nDevices = 0; rau (chaw nyob = 1; chaw nyob <127; chaw nyob ++) {// Tus i2c_scanner siv tus nqi rov qab los ntawm // Tus Sau.endTransmisstion kom pom tias // lub cuab yeej puas lees paub rau qhov chaw nyob. Wire.beginTransmission (chaw nyob); yuam kev = Wire.endTransmission (); yog (yuam kev == 0) {Serial.print ("I2C ntaus ntawv pom ntawm qhov chaw nyob 0x"); yog (chaw nyob <16) Serial.print ("0"); Serial.print (chaw nyob, HEX); Serial.println ("!"); nDevices ++; } lwm yog (yuam kev == 4) {Serial.print ("Tsis paub qhov yuam kev ntawm qhov chaw 0x"); yog (chaw nyob <16) Serial.print ("0"); Serial.println (chaw nyob, HEX); }} yog (nDevices == 0) Serial.println ("Tsis pom I2C li pom / n"); lwm tus Serial.println ("ua tiav / n"); ncua (5000); // tos 5 vib nas this rau tom ntej scan}

Kauj Ruam 6: Tsim HTML Lub Vev Xaib Lub Vev Xaib

Tsim cov HTML Webserver Folder
Tsim cov HTML Webserver Folder

ESP32 muab qhov ua tau rau khiav lub vev xaib. Nws kuj tseem muab lub cim xeeb RAM loj heev los tuav qee lub vev xaib. (Nws automaticlly compresses cov nplooj ntawv webpage).

Arduino IDE muab kev ua haujlwm rau upload cov vev xaib tsim mus rau ESP32's RAM ncaj qha.

Txhawm rau ua qhov no, koj yuav tsum tsim daim nplaub tshev 'cov ntaub ntawv' hauv qab Arduino qhov project daim nplaub tshev. Hauv kuv qhov no yog / Arduino / esp32_Power_supply_v1_implemented / data.

Nws yog ib qho tseem ceeb rau npe cov ntaub ntawv raws nraim 'cov ntaub ntawv' raws li nws yog lub npe nplaub tshev Arduino yuav saib thaum rub cov vev xaib nplooj ntawv mus rau ESP.

Kauj Ruam 7: Tsim Lub Hwj Chim Saib Xyuas Lub Vev Xaib

HMTL yog hom lus uas tso cai nthuav tawm cov ntawv rau hauv webbrowser. Cov ntaub ntawv HTML raug khaws tseg hauv qab txuas ntxiv htm (l). Kev tsim cov vev xaib feem ntau muab tso rau hauv cov ntawv cais (piv txwv li. Css file). Qhov haujlwm ua haujlwm uas lub vev xaib xav tau muab yog ib txwm muab tso rau hauv lwm cov ntawv (piv txwv li. Js file, rau javascript).

Hauv kuv cov ntawv HTML Kuv suav nrog cov ntawv, kev tsim thiab Javascript rau hauv ib daim ntawv. Yog li ntawd nws tsis yog ib qho piv txwv zoo ntawm yuav ua li cas rau lub vev xaib tab sis nws ua haujlwm lub hom phiaj. Kuv lub npe HTML daim ntawv 'Index.htm'.

Ib daim ntawv thib ob suav nrog hauv kuv cov ntaub ntawv khaws cia, piv txwv li. PicoGraph.js Lub tsev qiv ntawv PicoGraph tau muab los ntawm Vishnu Shankar B los ntawm RainingComputers thiab tso cai rau kev yooj yim heev, tseem muaj txiaj ntsig thiab hloov tau txoj hauv kev los nthuav qhia cov duab rau hauv lub vev xaib. Kuv hloov kho me ntsis cov cai kom pab tau kuv lub hom phiaj zoo dua.

Koj yuav pom tias HTML lub vev xaib tseem suav nrog cov cai tswj hwm cov khoom siv hluav taws xob ntawm kuv lub rooj tsav xwm PCB. Txoj cai muab hluav taws xob tswj hwm qhov ntsuas hluav taws xob ntawm 5 I/O pins. Koj tuaj yeem hloov txoj cai kom tshem tawm qhov no lossis koj tuaj yeem tso nws tawm yog tias tsis muaj kev cuam tshuam.

Cov cai html tau txuas rau cov kauj ruam no raws li txt cov ntaub ntawv (raws li cov lus qhia tsis tso cai rub tawm cov cai htm).

Txhawm rau siv tus lej HTML koj theej thiab muab nws tso rau hauv cov ntawv hloov kho (Kuv siv Notepad ++) thiab khaws nws li 'Index.htm' hauv qab 'Cov ntaub ntawv' nplaub tshev. Koj ua tib yam rau daim ntawv picograph.txt tab sis hloov nws mus rau picograph.js

Hais txog cov ntaub ntawv HTML:

Lub luag haujlwm SndUpdate yog siv los xa xov rov qab thiab xa mus los ntawm ESP mus rau lub vev xaib.

Cov lus xa los ntawm ESP tau ua haujlwm pabcuam lub zog thiab tsis muaj peev xwm ua tau rau cov lus qhia no. cov lus rau ESP tau ua haujlwm rau Ina260 pawg tswj hwm ntsuas.

var Msg = JSON.parse (xh.responseText); PG1_yrand0 = Msg. PG1_yrand0; PG2_yrand0 = Msg. PG2_yrand0; PG3_yrand0 = Msg. PG3_yrand0; PG4_yrand0 = Msg. PG4_yrand0; PG5_yrand0 = Msg. PG5_yrand0; PG6_yrand0 = Msg. PG6_yrand0;

Cov cai saum toj no nyeem 6 tus lej los ntawm ESP32 pawg thawj coj, piv txwv li. ntsuas qhov ntsuas hluav taws xob, ntsuas tam sim no los ntawm thawj pawg thawj coj, ua raws ob qhov ntsuas los ntawm qhov thib ob thiab lwm yam.

Cov kab ntawv tau kos rau hauv lub npe hu ua flex-ntim, uas tso cai rau hloov pauv qhov loj me ntawm lub vev xaib.

.flex-container {display: flex; xim tom qab: cadetblue; flex-qhwv: qhwv; }.flex-container> div {keeb kwm yav dhau xim: #f1f1f1; paj: 10px; duav: 20px; font-loj: 20px; font-family: "Xya Ntu"; font-ceeb thawj: siab tawv; }

Cov ntsiab lus ntawm txhua lub thawv hloov pauv tau ua raws li hauv qab no, suav nrog cov duab kos.

(nco ntsoov tias qhov twg raug tshem tawm)

div daim ntawv lo rau = "PG1_scale" Nplai:/daim ntawv lo lub npe = "PG1_scale" tus nqi = "10" brbr!-Canvas rau thr graph-canvas style = "height: 100px; ciam teb: 2px solid #000000; background-color: #fafafa; "Peb /ntaub

!-div rau cov dab neeg/ntawv cim-

div /div div /div /div

Ntu kawg ntawm qhov tseem ceeb hauv cov ntawv HTML ua haujlwm nrog PicoGraph lub tsev qiv ntawv los nthuav qhia cov lej:

var PG1_demograph = createGraph ("PG1_graphDemo", ["Ch1"], "V", "PG1_graphLabels", 20, 11, cuav, cuav, 11, "#e52b50"); var PG2_demograph = createGraph ("PG2_graphDemo", ["Ch1"], "mA", "PG2_graphLabels", 20, 11, cuav, cuav, 11, "#e52b50"); var PG3_demograph = createGraph ("PG3_graphDemo", ["Ch2"], "V", "PG3_graphLabels", 20, 11, cuav, cuav, 11, "#008000"); var PG4_demograph = createGraph ("PG4_graphDemo", ["Ch2"], "mA", "PG4_graphLabels", 20, 11, cuav, cuav, 11, "#008000"); // var PG5_demograph = createGraph ("PG5_graphDemo", ["Ch3"], "V", "PG5_graphLabels", 20, 11, cuav, cuav, 11, "#0000ff"); var PG6_demograph = createGraph ("PG6_graphDemo", ["Ch3"], "mA", "PG6_graphLabels", 20, 11, cuav, cuav, 11, "#0000ff"); / * Hloov kho qhov tseem ceeb txhua ob */ setInterval (hloov tshiab txhua lub hlis, 1000); muaj nuj nqi updateEverySecond () { / * Tau txais qhov txiaj ntsig tshiab * / SndUpdate ();

/ * Hloov kho kab */PG1_demograph.update ([PG1_yrand0], parseInt (byID ("PG1_scale"). Tus nqi)+ parseInt (byID ("PG1_scale") tus nqi)/10, "#e52b50"); PG2_demograph.update ([PG2_yrand0], parseInt (byID ("PG2_scale"). Tus nqi)+ parseInt (byID ("PG2_scale". Tus nqi)/10, "#e52b50"); PG3_demograph.update ([PG3_yrand0], parseInt (byID ("PG3_scale"). Value)+ parseInt (byID ("PG3_scale". Value)/10, "#008000"); PG4_demograph.update ([PG4_yrand0], parseInt (byID ("PG4_scale"). Tus nqi)+ parseInt (byID ("PG4_scale". Tus nqi)/10, "#008000"); // PG5_demograph.update ([PG5_yrand0], parseInt (byID ("PG5_scale"). Value)+ // parseInt (byID ("PG5_scale". Value)/10, "#0000ff"); PG6_demograph.update ([PG6_yrand0], parseInt (byID ("PG6_scale"). Tus nqi)+ parseInt (byID ("PG6_scale". Tus nqi)/10, "#0000ff"); var Watts = Math.round (PG1_yrand0 * PG2_yrand0 * 100)/100; byID ("PG1_wattLabel"). innerHTML = `WATT: $ {Watts} mW`; var Watts = Math.round (PG3_yrand0 * PG4_yrand0 * 100)/100; byID ("PG3_wattLabel"). innerHTML = `WATT: $ {Watts} mW`; // var Watts = Math.round (PG5_yrand0 * PG6_yrand0 * 100)/100; // byID ("PG5_wattLabel"). innerHTML = `WATT: $ {Watts} mW`; byID ("PG1_scale"). tus nqi = Math.floor (parseInt (byID ("PG1_scale"). tus nqi)/2+PG1_yrand0); byID ("PG2_scale"). tus nqi = Math.floor (parseInt (byID ("PG2_scale"). tus nqi)/2+PG2_yrand0); byID ("PG3_scale"). tus nqi = Math.floor (parseInt (byID ("PG3_scale"). tus nqi)/2+PG3_yrand0); byID ("PG4_scale"). tus nqi = Math.floor (parseInt (byID ("PG4_scale"). tus nqi)/2+PG4_yrand0); // byID ("PG5_scale"). tus nqi = Math.floor (parseInt (byID ("PG5_scale"). tus nqi)/2+PG5_yrand0); byID ("PG6_scale"). tus nqi = Math.floor (parseInt (byID ("PG6_scale"). tus nqi)/2+PG6_yrand0);

Kawm cov cai koj yuav pom kuv tsuas yog siv 5 kab ntawm 6 rau kuv lub hom phiaj. Kev tsis tawm tswv yim txog kab uas raug yuav ua rau daim duab thib 6.

Rau cov tsis tau ntsib nrog html, cov kauj ruam no tuaj yeem dhau los ua nyuaj. Txawm li cas los xij nws tuaj yeem pab ua qhov kev qhia zoo rau hauv ntiaj teb ntawm HTML. Kuv paub vim tias qhov no yog thawj nplooj ntawv kuv puas tau tsim. Yog li tsis txhob ntshai. Rau cov neeg paub dhau los hauv peb, zam txim.

Qhov tshwm sim ntawm koj txoj haujlwm ntawm nplooj ntawv web tuaj yeem tshuaj xyuas los ntawm kev qhib koj li html, nws yuav ntsaws rau hauv koj tus browser thiab qhia nws qhov tsos. Koj tuaj yeem tshawb xyuas qhov ua tau yuam kev los ntawm nias F12 tus yuam sij hauv koj tus browser, lub qhov rais debugging yuav tshwm. Kev piav qhia tag nrho yuav ua li cas debug tawm ntawm qhov uas tau qhia no, tab sis lub vev xaib tuaj yeem pab tau ua thawj kauj ruam rau webpage / javascript debugging.

Cov kauj ruam tom ntej yog txhawm rau tsim cov nplooj ntawv webpages rau hauv ESP32.

Kauj Ruam 8: Thauj Lub Vev Xaib rau hauv ESP32

Thauj Lub Vev Xaib rau hauv ESP32
Thauj Lub Vev Xaib rau hauv ESP32

Tom qab tau txais qhov txiaj ntsig zoo, nws yog lub sijhawm los rub lub vev xaib rau hauv ESP32.

Koj ua qhov no los ntawm kev txuag 'Index.htm' (koj lub vev xaib) thiab 'PicoGraph.js' rau hauv 'cov ntaub ntawv' nplaub tshev hauv koj qhov Arduino project.

Cov kauj ruam tom ntej yog txuas ESP32 pawg thawj coj saib mus rau lub khoos phis tawj. Tom qab tau xaiv lub rooj tsav xwm raug thiab qhov chaw nres nkoj COM, xaiv ESP32 Sketch Data Upload hauv qab Cov cuab yeej ntawv qhia zaub mov hauv Arduino IDE.

Koj yuav pom tias IDE yuav pib nws cov txheej txheem uploading, uas yuav tsum coj mus rau qhov ua tiav.

Ib sab ntawm cov kauj ruam no yog teeb tsa ESP32 microcontroller ua lub vev xaib.

Kauj Ruam 9: teeb tsa ESP32 Raws li Lub Vev Xaib

Txuas nrog koj pom Arduino Ino kos duab uas yuav teeb tsa ESP32 ua lub vev xaib.

Koj yuav tsum tau hloov SSID thiab cuam tshuam nrog Tus password nrog koj tus router tus password.

Raws li tau hais dhau los daim duab no tseem muaj cov cai txhawm rau teeb tsa lub vev xaib ua tus tswj hwm rau lub zog hluav taws xob sab ntawm PCB (qhov tseeb, teeb tsa 5 IO pins li PWM pins thiab tswj lawv los ntawm cov lus xa los ntawm lub vev xaib).

Cov duab kos yog ua raws tus qauv Webserver tus qauv tsim los ntawm Hristo Gochkov.

Qee qhov kev piav qhia ntawm txoj cai.

Cov haujlwm hauv qab no yog txhua yam cuam tshuam nrog kev teeb tsa lub vev xaib.

String formatBytes (size_t bytes) String getContentType (String filename) bool muaj nyob (Txoj hlua txoj hauv kev) bool handleFileRead (Txoj hlua txoj hauv kev) void handleFileUpload () void handleFileDelete () void handleFileCreate () void handleFileList ()

Kuj thawj tus lej hauv kev teeb tsa () kev ua haujlwm cuam tshuam nrog PWM thiab teeb tsa lub vev xaib.

Cov cai hauv qab no teeb tsa Kev cuam tshuam cuam tshuam uas ua rau cov lus xa mus rau thiab los ntawm lub vev xaib:

(koj yuav tsum paub tus cim los ntawm kev tsim lub vev xaib)

server.on ("/SndUpdate", HTTP_GET, () {

Txoj hlua Msg = "{"; Msg+ = "\" PG1_yrand0 / ":"+ (Txoj hlua) Vina [1]; Msg+ = ", \" PG2_yrand0 / ":"+ (Txoj hlua) Iina [1]; Msg+ = ", \" PG3_yrand0 / ":"+ (Txoj hlua) Vina [0]; Msg+ = ", \" PG4_yrand0 / ":"+ (Txoj hlua) Iina [0]; Msg+ = ", \" PG5_yrand0 / ":"+ (Txoj hlua) Vina [2]; Msg+ = ", \" PG6_yrand0 / ":"+ (Txoj hlua) Iina [2]; Msg+= "}";

server.send (200, "ntawv nyeem/json", Msg);

Qhov no pib server:

server.begin ();

Cov thaiv kab lus tom ntej, pib ua INA260 cov laug cam:

// INA260 initialization yog (! Ina260_0x40.begin (0x40)) {Serial.println (F ("Tsis pom INA260 0x40 nti")); // thaum (1); } Serial.println (F ("Pom INA260 nti 0x40")); yog (! ina260_0x41.begin (0x41)) {Serial.println (F ("Tsis tuaj yeem pom 0x41 INA260 nti")); // thaum (1); } Serial.println (F ("Pom INA260 0x41 nti")); yog (! ina260_0x44.begin (0x44)) {Serial.println (F ("Tsis tuaj yeem pom INA260 0x44 nti")); // thaum (1); } Serial.println (F ("Pom INA260 nti 0x44"));

ina260_0x40.setAverageingCount (INA260_COUNT_256);

ina260_0x40.setVoltageConversionTime (INA260_TIME_1_1_ms); ina260_0x40.setCurrentConversionTime (INA260_TIME_1_1_ms); ina260_0x40.setMode (INA260_MODE_CONTINUOUS); ina260_0x41.setAverageingCount (INA260_COUNT_256); ina260_0x41.setVoltageConversionTime (INA260_TIME_1_1_ms); ina260_0x41.setCurrentConversionTime (INA260_TIME_1_1_ms); ina260_0x41.setMode (INA260_MODE_CONTINUOUS); ina260_0x44.setAverageingCount (INA260_COUNT_256); ina260_0x44.setVoltageConversionTime (INA260_TIME_1_1_ms); ina260_0x44.setCurrentConversionTime (INA260_TIME_1_1_ms); ina260_0x44.setMode (INA260_MODE_CONTINUOUS);

Hauv Loop code, cov lus hauv qab no lees paub kev tuav cov cai cuam tshuam:

server.handleClient ();

Cov cai hauv qab no hauv kab lus hais txog cuam tshuam nrog Lub Hwj Huam ua haujlwm.

Cov cai hauv qab no hauv lub voj () yog qhov nthuav dua:

Vina [0] = ina260_0x40.readBusVoltage ()/1000.0f; Iina [0] = ina260_0x40.readCurrent (); Vina [1] = ina260_0x41.readBusVoltage ()/1000.0f; Iina [1] = ina260_0x41.readCurrent (); Vina [2] = ina260_0x44.readBusVoltage ()/1000.0f; Iina [2] = ina260_0x44.readCurrent ();

Cov nqe lus no sau thiab teeb tsa kev ntsuas rau hloov mus rau lub vev xaib ntawm Server.on cuam tshuam kev hu (tshwm sim txhua 1000ms, teeb tsa hauv lub vev xaib html java tsab ntawv).

Kauj ruam 10: Koj Ua tiav

Koj Ua Tiav lawm!
Koj Ua Tiav lawm!

Kev xa cov duab kos mus rau ESP32 pawg thawj coj, yuav tsum ua tiav qhov teeb tsa thiab koj Lub Hwj Chim Saib Xyuas yuav tsum yog zaum kawg!

Tej zaum koj yuav tau pom tias lub zog ESP32 tam sim no ua tiav ntawm USB chaw nres nkoj, qhov no ua rau ntau qhov zoo ntawm WiFi raws li kev txuas nrog koj qhov hluav taws xob / ntsuas tam sim no. Li no, Kuv tau ua qhov yooj yim LM317 raws qhov ntsuas hluav taws xob tswj hluav taws xob rau ESP32. Kuv khaws nws tawm ntawm cov lus qhia no tab sis yog tias muaj kev txaus siab tuaj yeem dhau los ua tus qhia tom ntej.

Hauv cov kauj ruam tom ntej kuv twb tau muab cov hluav taws xob hluav taws xob rau lub zog hluav taws xob uas tuaj yeem pab ua kev tshoov siab.

Kauj ruam 11: Hwj chim ESP32

Txhawb nqa ESP32
Txhawb nqa ESP32

Nov yog qhov kev tshoov siab los tsim lub zog ib leeg rau koj li ESP32, yog tias koj tsis muaj ib qho dag ib ncig.

Lub zog hluav taws xob ua haujlwm ntawm 19V lub laptop fais fab mov. Qhov no thov kom muaj ob theem hluav taws xob nqis qis kom ua kom lub zog tawg ntawm LM317 nyob hauv kev tswj hwm. (Txawm tias muaj cov cua sov poob!). Tsis tas li tsis txhob hnov qab suav nrog 100uF capacitor nyob rau hauv pem hauv ntej ntawm VCC_ESP kab raws li cov microcontrollers muaj cov viav vias tam sim no yeej thaum pib txuas WiFi.

Nco tseg kom tsis txhob muaj zog ESP32 nrog ntau dua ib lub zog siv ib zaug!

Ntxiv qhov kev lees paub kev lav paub ib txwm muaj, tab sis feem ntau ntawm txhua qhov

Muaj kev lom zem!

Txhua cov ntaub ntawv tuaj yeem pom ntawm kuv GitHub:

Pom zoo: