Cov txheej txheem:

Yuav Ua Li Cas Ua Yooj Yim IOT Nrog Telegram Daim Ntawv Thov: 5 Cov Kauj Ruam
Yuav Ua Li Cas Ua Yooj Yim IOT Nrog Telegram Daim Ntawv Thov: 5 Cov Kauj Ruam

Video: Yuav Ua Li Cas Ua Yooj Yim IOT Nrog Telegram Daim Ntawv Thov: 5 Cov Kauj Ruam

Video: Yuav Ua Li Cas Ua Yooj Yim IOT Nrog Telegram Daim Ntawv Thov: 5 Cov Kauj Ruam
Video: 10000 подключений на LinkedIn | Влиять и развивать свой бизне... 2024, Kaum ib hlis
Anonim
Image
Image
Tsim Bot hauv Telegram
Tsim Bot hauv Telegram

Hauv tiam tam sim no Internet yog txhua yam. Internet ntawm Yam Ua lub luag haujlwm tseem ceeb hauv ntiaj teb tam sim no.

Tsis tas yuav nkim sijhawm ntau, peb tuaj yeem txav mus rau qhov ua haujlwm ntawm IOT. Ntawm no peb yuav tswj hwm tus coj thiab tseem muaj lwm yam zoo siab los ntawm xov tooj xa xov.

Kauj ruam 1: Tsim Bot hauv Telegram

Tsim Bot hauv Telegram
Tsim Bot hauv Telegram
Tsim Bot hauv Telegram
Tsim Bot hauv Telegram
Tsim Bot hauv Telegram
Tsim Bot hauv Telegram

1. Hauv cov kauj ruam no teeb tsa Telegram app hauv xov tooj. Kev teeb tsa yog yooj yim li whats app teeb tsa.

2. Hauv Telegram tshawb rau Bot txiv thiab tsim tus bot tshiab los ntawm kev ua raws cov duab hauv qab no.

3. Thaum kawg, theej the HTTP API token. (Tsis txhob qhia rau lwm tus) thiab nkag mus pib hauv bot

Kauj Ruam 2: Txhim Kho Bot hauv Raspberry Pi

Txhim Kho Bot hauv Raspberry Pi
Txhim Kho Bot hauv Raspberry Pi

Yog li bot tau tsim thiab nws yuav tsum tau khiav ntawm ib qho ntawm cov cuab yeej yog li ntawd rau txhua cov lus peb xa nws yuav teb raws li.

Ntawm no peb tab tom siv raspberry pi nrog tus lej Api thiab ua haujlwm nws hauv cov nab npawb nab npawb. (Nws kuj tseem tuaj yeem ua haujlwm hauv peb li kev ua haujlwm ib txwm muaj)

1. Kev teeb tsa tus lej xov tooj ntawm raspberry pi

Ua ntej peb pib ua haujlwm bot ntawm raspberry pi ua kom ntseeg tau tias koj tab tom khiav qhov tsim nyog ntawm nab hab sej 2. Tsis tas li Yog tias koj muaj kev ua xyem xyav txog qhov pib ntawm Raspberry pi koj tuaj yeem saib thawj 2 kauj ruam hauv qhov kev qhia no ntawm kuv Txhawm rau teeb tsa tus lej xov tooj hauv nab hab sej hauv kab hais kom ua ntawm raspberry pi nkag mus hauv qab no (lub npe module yog telepot))

sudo pip nruab telepot

2. Txhua tus ntawv nab hab sej

Python tsab ntawv tau ua tiav hauv kab hais kom ua siv cov lus txib hauv qab no sudo python telegrambot.py

Kauj Ruam 3: Tshooj Cai

Yog li thaum peb xa cov lus mus rau bot, nws teb zoo ib yam.

Hauv txoj cai peb yuav qhia tus bot kom teb rau peb cov lus txib.

Ntawm no kuv yuav tsis qhia koj li cas cov ntawv nab nab ua haujlwm zoo li nws yuav piav qhia ntau ntxiv.

ntshuam RPi. GPIO raws li GPIO lub sijhawm ntshuam, hnub tim ntshuam telepot los ntawm telepot.loop ntshuam MessageLoop GPIO.setmode (GPIO. BCM) coj = 23 GPIO.setup (coj, GPIO. OUT) tam sim no = datetime.datetime.now ()

def kev ua (msg):

chat_id = msg ['tham'] ['id'] hais kom = msg ['ntawv']

print 'Txais: % s' % hais kom ua

yog hais kom ua == 'nyob zoo':

telegram_bot.sendMessage (chat_id, str ("Hi!.minute)) elif command == 'pic': telegram_bot.sendPhoto (chat_id, photo = "https://raw.githubusercontent.com/engineerlookts/engineerlookts/gh-pages/E.png") elif command == 'ledon ': telegram_bot.sendMessage (chat_id, str (' Led is on ')) GPIO.output (coj, Muaj tseeb) elif hais kom ua ==' ledoff ': telegram_bot.sendMessage (chat_id, str (' Led is off ')) GPIO. cov zis (coj, Tsis tseeb) lwm qhov: telegram_bot.sendMessage (chat_id, str ('Tsis tuaj yeem tau txais koj pls kom meej!'))

telegram_bot = telepot. Bot ('Nkag mus rau koj tus lej API')

luam tawm (telegram_bot.getMe ())

MessageLoop (telegram_bot, nqis tes ua).run_as_thread ()

luam 'Up and Running ….'

thaum 1:

sijhawm.sleep (10)

i. Qhov no kuv tau ua nyob zoo thiab cov lus teb rau nws yog "Nyob Zoo! Txais tos rau Engineerlookts.com". Ib yam li ntawd, rau txhua qhov hais kom ua, koj tuaj yeem hloov kho koj Lub Tswv Yim.

ii. Enter your API ID here in this line "telegram_bot = telepot. Bot ('Nkag mus rau koj tus ID API')"

Kauj Ruam 4: Xaus

Xaus
Xaus
Xaus
Xaus
Xaus
Xaus

Ua tsaug …! koj tau ua tiav koj Thawj DIY IOT project.

Ntxiv mus, Kuv tso nws rau koj tus kheej txhawm rau txhim kho tus qauv los ntawm kev ntxiv koj lub tswv yim. Qee qhov Kev Xav ntawm kuv yog.

i. Home Automation -Connecting Output to the relays.

ii. Can tsim koj tus kheej cov neeg rau zaub mov-uas tuaj yeem teb koj cov lus

iii. Muaj koj tus kheej chatbot-uas tuaj yeem teb cov lus zoo li Natasha hauv kev taug kev.

Yog li IDEAS tsis muaj qhov kawg yog tias koj tuaj yeem tshawb xyuas ntawm koj tus kheej. HOPE Kuv tau pib me me rau IOT rau koj. Kuj tawm tswv yim koj Cov Tswv Yim hauv cov lus.

Ua tsaug

N. Aranganathan

Pom zoo: