Cov txheej txheem:

[IoT] Telegram Bot Nrog Arduino MKR WiFi 1010: 5 Cov Kauj Ruam
[IoT] Telegram Bot Nrog Arduino MKR WiFi 1010: 5 Cov Kauj Ruam

Video: [IoT] Telegram Bot Nrog Arduino MKR WiFi 1010: 5 Cov Kauj Ruam

Video: [IoT] Telegram Bot Nrog Arduino MKR WiFi 1010: 5 Cov Kauj Ruam
Video: Night 2024, Hlis ntuj nqeg
Anonim
Image
Image
Yam Koj Xav Tau
Yam Koj Xav Tau

Txoj haujlwm no qhia pom yuav ua li cas cuam tshuam Arduino nrog Telegram Bot APIs. Qhov haujlwm no tau tsim nyob ib puag ncig ntawm MKR WiFi 1010 pawg thawj coj tshiab nruab nrog ESP32 module los ntawm U-BLOX.

Hauv theem no, txoj haujlwm tsis muaj ntau tshaj li qhov pov thawj ntawm lub tswv yim, tsuas yog qhia koj tias koj tuaj yeem ua dab tsi nrog, yog li qhov no koj xav tau tsuas yog Arduino board.

Tab sis dab tsi yog Telegram Bot? Zoo, Bots tsuas yog Telegram tus lej siv los ntawm software - tsis yog tib neeg - thiab lawv feem ntau yuav muaj AI nta. Lawv tuaj yeem ua dab tsi - qhia, ua si, tshawb nrhiav, tshaj tawm, ceeb toom, txuas, sib koom nrog lwm cov kev pabcuam, lossis tseem dhau cov lus txib mus rau Internet ntawm Yam. (khab nias los ntawm Telegram:

Hauv peb qhov xwm txheej peb yuav dhau cov lus txib rau Arduino tsim lub cuab yeej IoT yooj yim. Nws yuav teb rau cov lus txib yooj yim thiab tseem qhib/tua lub built-in Led. Kuv yuav cia koj lub tswv yim ua ntau dua nrog nws… (xav txog kev txuas ib lossis ntau qhov txuas mus rau I/O pins thiab qhib/tua lub rhaub lossis cua txias nrog koj lub smartphone, piv txwv).

Kauj Ruam 1: Yam Koj Xav Tau

Yam Koj Xav Tau
Yam Koj Xav Tau

Rau qhov haujlwm no koj xav tau:

  • Arduino MKR WiFi 1010 los ntawm Arduino khw:
  • Arduino IDE 1.8.5 lossis siab dua:
  • Ib lub micro-usb cable txuas Arduino rau koj lub PC
  • Kev sib txuas hauv is taws nem, nws xav tau SSID thiab tus password. Zoo dua yog tias koj siv koj tus kheej lub tsev router kom ntseeg tau tias nws tsis raug thaiv.
  • Telegram app teeb tsa ntawm koj lub smartphone, tsis hais lub npe twg, txheeb xyuas ntawm no rau PC thiab Web versions ib yam nkaus!

Kauj ruam 2: Txhim kho IDE

Txhim kho IDE
Txhim kho IDE
Txhim kho IDE
Txhim kho IDE
Txhim kho IDE
Txhim kho IDE

Yog, kuv paub, kuv paub … feem ntau ntawm koj twb muaj Arduino IDE teeb tsa hauv PC, tab sis Cov Lus Qhia no yog npaj rau cov pib tshiab. 'tsis yog tus tswj hwm' lossis exe file)

Qhov 1.8.5 tau pom zoo, kuv tsis tau sim cov ntawv qub thiab pawg thawj coj tshiab siv hauv txoj haujlwm tsis tuaj yeem txhawb nqa txhua.

Tam sim no koj yuav tsum teeb tsa cov laug cam tshiab nrog lawv cov tsav tsheb:

  1. pib IDE
  2. Los ntawm Cov Cuab Yeej ntawv qhia zaub mov xaiv Boards tom qab ntawd, nyob rau sab saum toj ntawm cov npe txheej txheem, xaiv Boards manager.
  3. Scroll lub qhov rai tshiab (saib duab) kom txog thaum koj pom Arduino SAMD cov laug cam uas suav nrog MKR WiFi 1010 tshiab.
  4. Nyem rau ntawm lub tab ntawd lossis nyem rau ntawm cov ntaub ntawv ntxiv hauv lub tab, xaiv qhov tseeb version thiab nruab.
  5. Tos kom lub installation tiav. Nws tseem yuav saib xyuas cov tsav tsheb teeb tsa
  6. Koj tseem xav tau lub tsev qiv ntawv WiFi tshiab rau pawg thawj coj no: xaiv Sketch, suav nrog Lub Tsev Qiv Ntawv thiab Tswj Cov Tsev Qiv Ntawv. Tshawb nrhiav Wifinina thiab teeb tsa zoo li koj tau ua nrog tus txheej txheem saum toj no.

Tam sim no txuas koj lub rooj tsav xwm Arduino tshiab thiab tos rau Windows kom ua tiav kev teeb tsa tsav tsheb.

Los ntawm Cov Cuab Yeej-> Cov ntawv qhia zaub mov koj yuav pom cov laug cam tshiab, xaiv MKR WiFi 1010.

Lwm lub tsev qiv ntawv tshwj xeeb xav tau rau txoj haujlwm no, nws yog ESP8266TelegramBot lub tsev qiv ntawv los ntawm Giancarlo Bacchio.

Xaiv qhov chaw nres nkoj com kom raug thiab ntsuas lub rooj tsavxwm nrog Tau Txais Cov Lus Qhia Cov Lus Qhia.

Nrog koj zoo siab, koj ua tiav nrog IDE!

Kauj Ruam 3: Tsim Telegram Bot

Tsim Telegram Bot
Tsim Telegram Bot
Tsim Telegram Bot
Tsim Telegram Bot
Tsim Telegram Bot
Tsim Telegram Bot

Tsim Telegram Bot tshiab yog qhov yooj yim heev.

Qhib Telegram app thiab, hauv kab ntawv tshawb fawb, ntaus @BotFather thiab pib tham nrog nws (duab 1). BotFather yog… Bot Hoobkas. Nws yuav pab koj tsim tus bot tshiab thiab hloov nws cov chaw.

Tom qab /pib hais kom ua koj yuav pom cov npe pabcuam (duab 2).

  • Hom /newbot (duab 3) Tam sim no ntaus lub npe ntawm koj tus bot. Lub npe tau nthuav tawm hauv cov ntaub ntawv tiv toj thiab lwm qhov.
  • BotFather yuav nug koj lub npe siv. Lub npe siv yog lub npe luv, yuav siv rau hauv kev hais txog thiab telegram.me txuas. Cov neeg siv lub npe yog 5-32 tus cim ntev thiab tsis muaj teeb meem, tab sis tsuas yog suav nrog cov ntawv Latin, cov lej, thiab cov cim hauv qab. Koj tus bot lub npe siv yuav tsum xaus rau hauv 'bot', piv txwv li 'Tetris_bot' lossis 'TetrisBot'.
  • Yog tias ob lub npe thiab lub npe siv tau koj yuav tau txais cov kab ntawv ntev hu ua TOKEN. Nov yog koj tus kheej 'tus yuam sij' siv los sib tham nrog Telegram servers. Copy thiab muab nws tso rau hauv cov ntawv sau ntawm koj lub PC tam sim no. Peb yuav siv nws tom qab rau hauv Arduino code Yog tias koj xoob nws tsis txhob txhawj, tsuas yog qhib kev sib tham thiab ntaus /token los tsim qhov tshiab.

Txhua cov kauj ruam tau piav qhia ntawm no:

Advanced (yeem)

Rov qhib kev sib tham thiab ntaus /pab

Nyem rau ntawm (lossis hom) /setuserpic txhawm rau rub daim duab rau koj tus bot. Nyem rau (lossis hom) /setabouttext txhawm rau teeb tsa Hais txog ntu rau koj Bot: Cov tib neeg yuav pom cov ntawv no ntawm tus bot nplooj ntawv profile thiab nws yuav raug xa ua ke nrog txuas rau koj tus bot thaum lawv qhia nws rau lwm tus.

Nyem rau (lossis hom) /setdescription los teeb tsa ntu kev piav qhia rau koj tus bot. Tib neeg yuav pom cov lus piav qhia no thaum lawv qhib kev sib tham nrog koj tus bot, hauv qhov thaiv lub npe 'Tus bot no tuaj yeem ua dab tsi?'.

Kauj Ruam 4: Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch

Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch
Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch
Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch
Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch
Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch
Hloov kho, Tshaj Tawm thiab Kuaj Cov Sketch

Nws yog lub sijhawm los rub tawm software rau Arduino MKR WiFi 1010 lub rooj tsavxwm.

Rub tawm cov ntawv txuas, vim qee qhov kuv tsis tuaj yeem rub tawm ZIP, yog li tsim cov ntawv tais ceev tseg uas muaj npe raws li daim duab thiab luam tag nrho 4 cov ntaub ntawv sab hauv nws, thov tsis txhob hloov npe tshwj tsis yog koj paub tias koj tab tom ua dab tsi.

Hloov kho

Qhib daim duab, peb yuav tsum tau sau qee cov ntaub ntawv (duab 1): sau cov arduino_secrets.h nrog koj li wifi thiab ntawv pov thawj hauv xov tooj.

  • Nrhiav WiFi cov ntaub ntawv xov xwm thiab ntaus koj lub npe network (SSID) thiab tus password.
  • Nrhiav cov ntaub ntawv xov tooj cua Bot thiab ntaus lub npe, lub npe siv thiab tus cim muab los ntawm @BotFather

Upload

Xyuas kom lub rooj tsavxwm raug (duab 2) hauv lub tswv yim thiab txuas nrog tom qab ntawd sim sau cov cai. Yog tias qhov muab tso ua ke mus zoo, xa nws mus rau lub rooj tsavxwm, nws yuav siv sijhawm li ob peb feeb xwb.

Yog tias muaj teeb meem tshawb xyuas qhov ua yuam kev thiab rov ua dua.

Xeem

[TSEEM CEEB!] Daim duab kos xa cav mus rau IDE. Tus txheej txheem muaj ib txwm USB chaw nres nkoj (zoo li Leonardo cov laug cam). Thaum siv lub zog, tus lej yuav tos kom txog thaum lub ntsuas saib ua haujlwm. Yog li, cia nws txuas nrog lub PC thiab qhib qhov saib ua ntej. Arduino yuav xub txuas rau internet, tom qab ntawd nws yuav pib pov npav Telegram server rau cov lus tshiab (duab 3).

Tam sim no qhib Telegram ntawm koj lub cuab yeej nyiam thiab, hauv lub thawv tshawb nrhiav, ntaus lub npe ntawm koj tus bot (tsis yog lub npe siv uas xaus nrog 'bot'). Qhib kev sib tham nrog nws.

Thawj qhov lus txib kom pib sib tham nrog tus bot yog /pib, peb Arduino yuav teb nrog cov lus txais tos tam sim no hom kev pab (tsis muaj slash), nws yuav teb nrog cov npe ntawm cov lus txib txhawb nqa, koj tuaj yeem sim lawv tag nrho (duab 4).

Koj tau ua tiav qhov kev sim, yog tias qee yam tsis ua haujlwm, kos cov ntaub ntawv nkag mus rau hauv daim duab (lub npe, lub npe siv, tus cim …)

Yog tias koj tab tom ntsib teeb meem nrog kev txuas mus rau lub server telegram (cav: Bot tsis txuas nrog):

  • Qhib Cov Cuab Yeej-> Wifi101/wifinina hloov kho
  • Xyuas kom koj lub rooj sib tham txuas nrog, txheeb xyuas cov chaw nres nkoj ntawm sab laug ntawm cov cuab yeej hloov kho tshiab, pawg thawj coj yuav tsum nyob ntawd
  • Nyem Qhib qhov hloov tshiab hloov tshiab thiab muab tso rau hauv lub rooj tsavxwm
  • Tom qab rub tawm, hauv qhov hloov tshiab xaiv qhov tseeb firmware rau koj lub rooj tsavxwm thiab nyem hloov tshiab firmware
  • Tom qab hloov tshiab, hauv qhov hloov tshiab, ntu SSL daim ntawv pov thawj, nyem Ntxiv sau, hauv kev sib tham sau telegram.org:443 ces nias OK.
  • Nyem Upload daim ntawv pov thawj rau wifi module
  • Upload daim duab no mus rau lub rooj tsavxwm

Kauj Ruam 5: Kev txhim kho

Kev txhim kho
Kev txhim kho

Saib ntawm txoj cai nws yooj yim heev rau siv cov lus txib tshiab thiab teb rau tus neeg siv.

Cov lus txib tshiab: Koj tuaj yeem sau ib ntu rau txhua qhov lus txib tshiab. Txhua lub sub yuav saib xyuas ua kom tiav cov lus txib thiab (thaum kawg) xa cov ntaub ntawv xwm txheej rau tus neeg siv.

Txwv cov neeg siv: Tau kawg txoj haujlwm no tsuas yog ua piv txwv. Ib tus neeg siv Telegram tuaj yeem txuas rau koj lub tsev thiab xa cov lus tsis xav tau. Koj tsis xav tau qhov no!.

Zoo, saib ntawm daim duab 1, nws qhia 2 cov neeg siv txuas nrog. Raws li koj tuaj yeem pom txhua tus neeg siv muaj nws tus kheej tus lej ID. Nrog kev ua haujlwm me ntsis ntawm sab chaws koj tuaj yeem lim (lossis tsim cov npe) rau cov neeg siv tso cai nkaus xwb. Tsuas yog kawm txoj cai thiab sim cuam tshuam tus lej ID. Tom qab ntawd ua cov lus txib tsuas yog los ntawm cov neeg siv paub zoo.

Kho vajtse: Ntawm lub khoos phis tawj, ntau lub ntsuas pa thiab xa tawm tuaj yeem txuas nrog I/O pins ntawm Arduino.

Ceev faj: pawg thawj coj siv hauv txoj haujlwm no yog 3.3V zam !!! Siv qhov ntsuas hluav taws xob hloov pauv qhov twg xav tau!

Qhov ntawd yog txhua yam, txaus siab!

Pom zoo: