Cov txheej txheem:

Yuav Ua Li Cas Txheeb Tus Kheej?: 3 Kauj Ruam (nrog Duab)
Yuav Ua Li Cas Txheeb Tus Kheej?: 3 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Txheeb Tus Kheej?: 3 Kauj Ruam (nrog Duab)

Video: Yuav Ua Li Cas Txheeb Tus Kheej?: 3 Kauj Ruam (nrog Duab)
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Image
Image
Tsim Blynk Project
Tsim Blynk Project

Kuv siv los ua tau zoo ntawm ntau yam kis las: taug kev, khiav, caij tsheb kauj vab, ntaus tis qaib thiab lwm yam.

Kuv nyiam caij tsheb mus ncig ua ntej ntev. Zoo, saib ntawm kuv lub plab portly ……

Zoo, txawm li cas los xij, Kuv txiav txim siab rov pib ua haujlwm. Kuv yuav tsum npaj cov cuab yeej twg? Dhau ntawm qhov chaw ua kis las, yog! Kuv xav tau ib qho cuab yeej! Kuv ntseeg nrog nws, Kuv tuaj yeem khaws qhov tsim nyog ntawm kev tawm dag zog. Nov yog qhov cuab yeej los ua. Peb pib nrog video ~

Qhov ntsuas tsis yog tuaj yeem sau cov kauj ruam (thiab calories) ntawm lub sijhawm, tab sis qhia lub sijhawm. Dab tsi tshwj xeeb yog tias hom ntawv ntawm kev qhia yog pointer ~ zoo heev! Kuv yeej, tiag tiag nyiam nws!

Koj tuaj yeem xa koj cov ntaub ntawv mus rau Is Taws Nem

tsuas yog nias ib zaug. Txhua cov ntaub ntawv tuaj yeem nthuav tawm los ntawm Blynk (lub xov tooj ntse siv software qhia ua ntej). Zoo ib yam li lub ntsej muag ntse saib, ntsuas tau sijhawm nyob ntawm kab (Yog li koj tsis tas yuav ntshai lub zog thiab hloov kho lub sijhawm).

Kho vajtse hauv meed:

FireBeetle Board-ESP32

FireBeetle Npog-Proto Board

OLED12864 dispaly npo

Kev ua kom nrawm dua

3.7V roj teeb (yuav online, ntim ib ncig 600mAH)

3 lub raj mis (yuav online)

Nws yooj yim heev los tsim txoj haujlwm no los ntawm Blybk.

Kauj Ruam 1: Tsim Blynk Project

Ntxiv ob qhov kev tswj hwm:

Tus Nqi Zaub * 1

Lub sijhawm tiag tiag * 1

Lub npe ntawm Cov Zaub Qhia yuav tsum tau teeb tsa ua cov kauj ruam, tab sis tsis muaj teeb tsa rau cov khoom ntawm Lub Sijhawm Sijhawm. Xaiv V1 ua tus pin nkag rau kev ncaj ncees ntawm kev tswj hwm, qhia raws li hauv qab no.

Kauj Ruam 2: Rub Cov Haujlwm rau FireBeetle Board-ESP32

Nyem rau qhov no rub tawm qhov chaws rau esp32. Qhov chaws muaj cov ntaub ntawv hauv tsev qiv ntawv thiab luam ntawv 3D. Koj yuav tsum khaws cov ntaub ntawv hauv tsev qiv ntawv mus rau lib ntawm arduino. Thiab cov ntaub ntawv 3D tuaj yeem luam tawm cov tawv nqaij ncaj qha.

Hauv qab no yog txoj haujlwm tseem ceeb

#include #include // Tsuas yog xav tau rau Arduino 1.6.5 thiab ua ntej #include "SSD1306.h" // alias rau `#include" SSD1306Wire.h "" #include "OLEDDisplayUi.h" #include "images.h" # suav nrog #include #include #include #include #define POWER_KEY 1 #define MENU_KEY 2 #define UPLOAD_KEY 3 boolean upload = cuav; SSD1306 zaub (0x3c, 18, 0); OLEDDisplayUi ui (& zaub); SimpleTimer timer; WidgetRTC rtc; int screenW = 128; int screenH = 64; int moosCenterX = screenW/2; int moosCenterY = ((screenH-16)/2) +16; // sab daj sab yog 16 px qhov siab int clockRadius = 23; #define DEVICE (0x53) // ADXL345 chaw nyob ntaus ntawv #define TO_READ (6) // tus lej bytes peb yuav nyeem txhua lub sijhawm (ob bytes rau txhua lub axis) byte buff [TO_READ]; // 6 bytes tsis rau txuag cov ntaub ntawv nyeem los ntawm lub cuab yeej char str [100]; // hlua tsis hloov pauv cov ntaub ntawv ua ntej xa nws mus rau qhov chaw nres nkoj txuas int regAddress = 0x32; // thawj axis-nrawm-cov ntaub ntawv sau npe ntawm ADXL345 int xx, yy, zz; // peb axis nrawm cov ntaub ntawv zoo li qub int currentValue = 0; zoo li qub unsigned ntev stepsSum = 0; char auth = "YourAuthToken"; // Koj li ntawv pov thawj WiFi. // Teeb tus password rau "" rau qhib tes hauj lwm. char ssid = "YourNetworkName"; char pass = "YourPassword"; const char running_Logo_bits PROGMEM = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x03, 0x00, 0x00, 0x60, 0xF1, 0x07, 0x00, 0x00, 0x00, 0x20, 0xF8, 0x17, 0x00, 0x00, 0xC0, 0xF8, 0x0F, 0x00, 0x00, 0xE0, 0xFB, 0x17, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0x13, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x80, 0xFE, 0x03, 0x00, 0x00, 0x00, 0xF9, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFA, 0x03, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF4, 0x07, 0x00, 0x00, 0x00, 0xF4, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF9, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x00, 0x80, 0x80, 0x1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0x00, 0xA0, 0xFF, 0x5F, 0x00, 0x00, 0x00, 0xC0, 0xx3F, 0x3F, 0x00, 0x0 0, 0xE8, 0x1F, 0x3F, 0x00, 0x00, 0xE8, 0xA7, 0x3E, 0x00, 0x00, 0xF0, 0xF0, 0x03, 0x7C, 0x00, 0x00, 0xE0, 0x7C, 0x00, 0x00, 0xE0, 0x05, 0xF8, 0x01, 0x00, 0xC0, 0x01, 0xF0, 0x03, 0x00, 0xC0, 0x03, 0xE8, 0x07, 0x00, 0xC0, 0xC0, 0x03, 0x88, 0x6F, 0x00, 0x80, 0x03, 0x40, 0x1E, 0x00, 0xA0, 0x03, 0x40, 0xFC, 0x00, 0x80, 0x03, 0x00, 0xF8, 0x01, 0x00, 0x07, 0x00, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0xE8, 0x00, 0x80, 0x0F, 0x00, 0xE8, 0x00, 0x90, 0x0F, 0x00, 0xE0, 0x00, 0xE8, 0x0F, 0x00, 0xE8, 0x00, 0xF0, 0x09, 0x00, 0x60, 0x01, 0xF0, 0x04, 0x00, 0x00, 0x00,}; // muaj nuj nqi ua haujlwm rau lub moos saib digital: luam tawm ua 0 Txoj hlua twoDigits (tus lej) {yog (tus lej <10) {Txoj hlua i = '0'+Txoj hlua (tus lej); rov i; } lwm {xa cov hlua (tus lej); }} void clockOverlay (OLEDDisplay * zaub, OLEDDisplayUiState * xeev) {yog ((teev () == 0) && (feeb () == 0) && (thib ob () == 0)) stepsSum = 0; } void analogClockFrame (OLEDDisplay * zaub, OLEDDisplayUiState * xeev, int16_t x, int16_t y) {display-> drawCircle (clockCenterX + x, clockCenterY + y, 2); // teev zuam rau (int z = 0; z drawLine (x2 + x, y2 + y, x3 + x, y3 + y);} // tso saib thib ob ntab lub kaum sab xis = thib ob () * 6; kaum = (kaum / 57.29577951); // Hloov cov degrees rau radians int x3 = (clockCenterX + (sin (kaum)) * (clockRadius - (clockRadius / 5)))); int y3 = (clockCenterY - (cos (kaum)) * (clockRadius - (clockRadius / 5)))); display-> drawLine (clockCenterX + x, clockCenterY + y, x3 + x, y3 + y); // tso saib feeb txhais tes kaum = feeb () * 6; kaum = (kaum sab xis / 57.29577951); // Hloov cov degrees rau radians x3 = (clockCenterX + (sin (kaum sab xis) * (clockRadius - (clockRadius / 4))))); y3 = (clockCenterY - (cos (angle) * (clockRadius - (clockRadius / 4))))); display-> drawLine (clockCenterX + x, clockCenterY + y, x3 + x, y3 + y); // tso saib teev teev lub kaum sab xis = teev () * 30 + int ((feeb () / 12) * 6); kaum = (kaum / 57.29577951); // Hloov cov degrees rau radians x3 = (clockCenterX + (sin (kaum)) * (clockRadius - (clockRadius / 2)))); y3 = (clockCenterY - (cos (kaum)) * (moosRadius - (clockRa dius / 2)))); display-> drawLine (clockCenterX + x, clockCenterY + y, x3 + x, y3 + y); } tsis muaj nuj nqis digitalClockFrame (OLEDDisplay * zaub, OLEDDisplayUiState * xeev, int16_t x, int16_t y) {String date = String (year ())+"/"+twoDigits (month ())+"/"+twoDigits (day ()); Txoj hlua timenow = Txoj hlua (teev ())+":"+twoDigits (feeb ())+":"+twoDigits (thib ob ()); display-> setTextAlignment (TEXT_ALIGN_CENTER); display-> setFont (ArialMT_Plain_24); display-> drawString (clockCenterX + x, 20, timenow); display-> setFont (ArialMT_Plain_16); display-> drawString (60, 45, hnub tim); } void writeTo (int ntaus ntawv, chaw nyob byte, byte val) {Wire.beginTransmission (ntaus ntawv); // pib kis mus rau ntaus ntawv Wire.write (chaw nyob); // xa npe chaw nyob Wire.write (val); // xa tus nqi sau Wire.endTransmission (); // kawg kis} // nyeem tus lej bytes pib los ntawm chaw nyob sau npe ntawm lub cuab yeej nyob rau hauv buff array tsis muaj dab tsi readFrom (int ntaus ntawv, byte chaw nyob, int tus lej, byte buff ) {Wire.beginTransmission (ntaus ntawv); // pib kis mus rau ntaus ntawv Wire.write (chaw nyob); // xa qhov chaw nyob nyeem los ntawm Wire.endTransmission (); // kawg kis Wire.beginTransmission (ntaus ntawv); // pib kis mus rau ntaus ntawv Wire.requestFrom (ntaus ntawv, lej); // thov 6 bytes los ntawm ntaus ntawv int i = 0; thaum (Wire.available ()) // ntaus ntawv tuaj yeem xa tsawg dua qhov thov (txawv txav) {buff = Wire.read (); // tau txais ib byte i ++; } Wire.endTransmission (); // kawg kis} tsis muaj dab tsi khiavFrame (OLEDDisplay*zaub, OLEDDisplayUiState*xeev, int16_t x, int16_t y) {ntab calValue = stepsSum*0.4487; display-> setTextAlignment (TEXT_ALIGN_CENTER); display-> setFont (ArialMT_Plain_24); display-> drawString (clockCenterX, clockCenterY, str); sprintf (str, "%.2fcal", calValue); display-> setTextAlignment (TEXT_ALIGN_CENTER); display-> setFont (ArialMT_Plain_10); display-> drawString (100, 20, str); display-> drawXbm (10, 14, 34, 50, running_Logo_bits); } void uploadFrame (OLEDDisplay * zaub, OLEDDisplayUiState * xeev, int16_t x, int16_t y) {display-> setFont (ArialMT_Plain_16); display-> drawString (60, 45, "upload cov ntaub ntawv …"); } // Cov kab ke no ua haujlwm taw qhia rau txhua tus ntas // thav ntawv yog ib qho pom uas swb hauv FrameCallback ntas = {analogClockFrame, digitalClockFrame, runningFrame, uploadFrame}; // Muaj pes tsawg tus ntas muaj? num frameCount = 4; // Kev sib tshooj yog zoo li kos rau saum tus ncej piv txwv. moos OverlayCallback overlays = {clockOverlay}; int overlaysCount = 1; void uploadToBlynk (tsis muaj dab tsi) {yog (upload == muaj tseeb) {Blynk.virtualWrite (V0, stepsSum); Blynk.virtualWrite (V1, stepsSum); }} void uiInit (tsis muaj dabtsis) {ui.setTargetFPS (30); //ui.setActiveSymbol(activeSymbol); //ui.setInactiveSymbol(inactiveSymbol); ui.setIndicatorPosition (TOP); ui.setIndicatorDirection (LEFT_RIGHT); ui.setFrameAnimation (SLIDE_LEFT); ui.setFrames (thav ntawv, frameCount); ui.setOverlays (overlays, overlaysCount); ui.disableAutoTransition (); ui.switchToFrame (2); ui.init (); display.flipScreenVertically (); } void adxl345Init (tsis muaj dab tsi) {writeTo (DEVICE, 0x2D, 0); writeTo (DEVICE, 0x2D, 16); writeTo (DEVICE, 0x2D, 8); } void updateAdxl345 (void) {readFrom (DEVICE, regAddress, TO_READ, buff); // nyeem cov ntaub ntawv nrawm los ntawm ADXL345 xx = (((int) buff [1]) << 8) | foob [0]; yy = (((int) buff [3]) << 8) | foob [2]; zz = (((int) buff [5]) << 8) | foob [4]; yog (xx 80) {yog (xx <currentValue) {stepsSum ++; } tam sim noValue = xx; } sprintf (str, "%d", stepsSum); } int getKeys (tsis muaj dab tsi) {yog (digitalRead (D2) == LOW) {ncua sijhawm (5); yog (digitalRead (D2) == LOW) {thaum (digitalRead (D2) == LOW); rov POWER_KEY; }} yog (digitalRead (D3) == LOW) {ncua (5); yog (digitalRead (D3) == LOW) {thaum (digitalRead (D3) == LOW); rov MENU_KEY; }} yog (digitalRead (D4) == LOW) {ncua (5); yog (digitalRead (D4) == LOW) {thaum (digitalRead (D4) == LOW); rov UPLOAD_KEY; }} rov qab 0; } tsis muaj dab tsi doKeysFunction (tsis muaj dab tsi) {zoo li qub uiFrameIndex = 2; int cov yuam sij = getKeys (); yog (yuam sij == POWER_KEY) {zoo li qub char i = 0; yog (i) {ui.init (); display.flipScreenVertically (); display.displayOn (); } lwm {display.displayOff (); } kuv = ~ kuv; } yog (tuav == MENU_KEY) {yog (upload == tsis tseeb) {uiFrameIndex ++; yog (uiFrameIndex == 3) uiFrameIndex = 0; ui.switchToFrame (uiFrameIndex); } lwm {ui.switchToFrame (3); }} yog (cov yuam sij == UPLOAD_KEY) {yog (upload == muaj tseeb) {upload = tsis tseeb; ui.switchToFrame (uiFrameIndex); } lwm {upload = tseeb; ui.switchToFrame (3); }}} tsis muaj teeb meem teeb tsa () {pinMode (D2, INPUT); pinMode (D3, INPUT); pinMode (D4, INPUT); Blynk.begin (auth, ssid, dhau); rtc.begin (); uiInit (); adxl345Init (); timer.setInterval (30, updateAdxl345); timer.setInterval (100, uploadToBlynk); } void loop () {int seemTimeBudget = ui.update (); zoo li qub int testSum = 0; yog ((testSum 0) {ncua sijhawm (seemTimeBudget);} doKeysFunction (); timer.run ();}

Ceev faj: Koj yuav tsum hloov kho Wi-Fi teeb tsa, daim ntawv hla tebchaws thiab AUTHTOKENS rau koj tus kheej.

char auth = "YourAuthToken"; // Koj li ntawv pov thawj WiFi. // Teeb tus password rau "" rau qhib tes hauj lwm. char ssid = "YourNetworkName"; char pass = "YourPassword";

Kauj Ruam 3: Kev Kho Vajtse Txuas

Kho vajtse txuas
Kho vajtse txuas
Kho vajtse txuas
Kho vajtse txuas
Kho vajtse txuas
Kho vajtse txuas

Txuas OLED12864 thiab nrawm rau I2C, hauv qab mus rau D2, D3, D4. Ntxiv mus, ntxiv 51k rub tawm cov neeg tawm tsam rau hauv qab kom mus txog 3.3V, qhia raws li hauv qab no.

Ceev faj: Nws tsis raug txuas txuas rub tawm cov neeg tawm tsam rau AREF, qhov raug yog 3.3V

Cov duab kho qhov muag, qhia raws li hauv qab no:

Tom qab cov laug, sib dhos kho vajtse module rau crust, qhia raws li hauv qab no:

Cov duab nthuav dav ~

Pom zoo: