Cov txheej txheem:
- Kauj Ruam 1: Teeb Peb Raspberry Pi Kho Vajtse
- Kauj Ruam 2: Teeb Peb Ib puag ncig ntawm Raspberry Pi
- Kauj Ruam 3: Tsim Ib Daim Python Code Nyeem Ntawv Los Ntawm Peb Lub Sensor
- Kauj Ruam 4: Pib Peb Cov Neeg rau zaub mov kom pom nws hauv Kev Ua
Video: IoT - Portable Mood Reporter: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Yam peb yuav xav tau:
- Raspberry Pi nrog Raspbian
- Kov Sensor los ntawm adafruit
- Hwj chim Source (Roj teeb/DC)
- Ethernet lossis WiFi rau Raspberry Pi
- Lwm lub computer
Kauj Ruam 1: Teeb Peb Raspberry Pi Kho Vajtse
Ua ntej tshaj, txuas peb lub ntsuas ntsuas mus rau GPIO pins ntawm peb Raspberry Pi. Siv qee cov kab uas hloov pauv tau
Txheeb xyuas 3 tus pin ntawm peb lub sensor:
- GND - txuas rau tus pin hauv av
- VCC - txuas rau 5V tus pin
- SIG - txuas rau tus lej cim npe
Peb yuav siv 5V, hauv av thiab GPIO 18 ntawm peb cov raspberry pi hauv qhov piv txwv no.
Kauj Ruam 2: Teeb Peb Ib puag ncig ntawm Raspberry Pi
Tau txais IP chaw nyob ntawm peb raspberry Pi.
Tom qab ntawv txuas rau peb cov raspberry pi siv ssh:
ssh username@ipaddress
tom qab ntawd ntaus peb tus password.
Thaum peb nyob hauv, tom qab ntawd nruab apache2 raws li peb lub vev xaib los ntawm kev ntaus hauv:
sudo apt-tau nruab apache2
Kauj Ruam 3: Tsim Ib Daim Python Code Nyeem Ntawv Los Ntawm Peb Lub Sensor
Tsim
Hauv peb tus lej piv txwv, peb siv ob peb qhov lus txib sib txawv.
Txhawm rau qhia tias peb zoo siab, peb ua 2 ntev nias
Txhawm rau qhia tias peb tu siab, peb ua ib lub kais luv, thiab nias ntev
Txhawm rau qhia tias peb tsis meej pem, peb ua ib lub kais luv, tos kom nrawm, tom qab ntawd 2 lub kais dej luv. Txhawm rau qhia tias peb zoo siab, peb ua ib tus kais luv, ib qho luv luv, thiab nias ntev
Txhawm rau qhia tias peb tau dhuav, peb 3 lub kais dej luv
Txhais cov no rau cov lus txib: (t rau kais luv, T rau nias ntev, g rau qhov sib txawv luv, G rau qhov sib txawv ntev)
zoo: tgt
siab: tg
tsis meej: tGtgt
siab: tgtgt
Tom qab ntawd peb yuav muaj peb cov cai tso tawm peb qhov kev xav tam sim no rau hauv browser-phooj ywg html cov ntaub ntawv rau kev ua haujlwm.
Code
ntshuam RPi. GPIO ua GPIOimport lub sijhawm
GPIO.cleanup ()
GPIO.setmode (GPIO. BCM) GPIO.setup (18, GPIO. IN)
cov_count = 0
touch_state = 0 touch_duration = 0 gap_duration = 0 current_cmd = ""
def cmd (): ua
ntiaj teb tam sim no_cmd yog tam sim no_cmd [-3:] == "TgT": current_cmd = "" kev xav ("Tu siab") yog tam sim no_cmd [-3:] == "tgT": current_cmd = "" kev xav ("Zoo siab") yog tam sim no_cmd [-5:] == "tGtgt": current_cmd = "" mood ("Tsis meej pem") yog current_cmd [-5:] == "tgtgt": current_cmd = "" mood ("Bored")
def mood (kev xav):
file = qhib ("index.html", "w") html = """
Portable Mood Reporter
Hav, kuv qhov kev xav tsis ntev los no yog
{}
"""
file.write (html.format (kev xav))
thaum (1):
time.sleep (0.001) yog (GPIO.input (18)): yog touch_state == 0: yog gap_duration> 2000: gap_duration = 0 yog gap_duration> 200: current_cmd = current_cmd + "G" ntxiv: current_cmd = current_cmd + "g "gap_duration = 0 touch_state = 1 touch_count = touch_count + 1 yog touch_state == 1: touch_duration = touch_duration + 1 ntxiv: yog gap_duration 200: current_cmd = current_cmd +" T "ntxiv: current_cmd = current_cmd +" t "touch_duration = 0 cmd ()
GPIO.cleanup ()
Teeb kom ua haujlwm nrog peb lub vev xaib
ntaus lossis xa cov ntaub ntawv nab hab sej saum toj no rau hauv peb qhov chaw webserver, uas yog defaulted rau/var/www/html
cd/var/www/html
sudo nano touch.py
Tom qab ntawv ntaus cov cai saum toj no
Kauj Ruam 4: Pib Peb Cov Neeg rau zaub mov kom pom nws hauv Kev Ua
cd/var/www/html
sudo nab hab sej touch.py
Tom qab ntawv ntaus tus IP chaw nyob rau peb Raspberry Pi, tom qab ntawd peb yuav tsum pom peb tus kws tshaj lij xov xwm ua haujlwm!
Sim sib txawv hom kev hais kom ua, thiab nplooj ntawv yuav tsum pib kho tshiab kom pom qhov ntawd!
Pom zoo:
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom - Cov Kauj Ruam ntawm Kauj Ruam: 4 Kauj Ruam
Arduino Tsheb Rov Qab Chaw Nres Tsheb Ceeb Toom | Cov kauj ruam ib kauj ruam: Hauv txoj haujlwm no, kuv yuav tsim qhov yooj yim Arduino Tsheb Rov Qab Tsheb Nres Tsheb Nres Sensor Siv Arduino UNO thiab HC-SR04 Ultrasonic Sensor. Qhov no Arduino raws Lub Tsheb Rov Qab ceeb toom tuaj yeem siv rau Kev Tshawb Fawb Txog Tus Kheej, Robot Ranging thiab lwm yam
IOT Mood Teeb: 8 Kauj Ruam (nrog Duab)
IOT Mood Teeb: Lub IoT Mood teeb ua los ntawm Node MCU (ESP8266), RGB LEDs thiab Jar. Cov xim ntawm lub teeb tuaj yeem hloov pauv siv Blynk App. Kuv tau xaiv Tony Starks Memorial Statue uas kuv muaj 3D luam tawm los tso rau hauv lub teeb no. Koj tuaj yeem nqa txhua tus pej thuam uas tau ua tiav lossis koj tuaj yeem
Mood Speaker- Tus Hais Lus Muaj Hwjchim rau Mood Music Yuav Ua Raws Li Qhov Kub Kub: 9 Kauj Ruam
Mood Speaker- Tus Hais Lus Muaj Hwjchim rau Mood Music Yuav Ua Si Raws Li Qhov Kub Kub: Nyob Zoo! ledstrip suav nrog Tus hais lus ua suab paj nruag tom qab raws li qhov ntsuas kub tab sis tuaj yeem
Tsev Automation Kauj Ruam ntawm Kauj Ruam Siv Wemos D1 Mini Nrog PCB Tsim: 4 Kauj Ruam
Tsev Automation Kauj Ruam Ib Leeg Siv Wemos D1 Mini Nrog PCB Tsim: Tsev Automation Kauj Ruam los ntawm Kauj Ruam siv Wemos D1 Mini nrog PCB Tsim cov tub ntxhais kawm ntawv qib siab. Tom qab ntawd ib tus ntawm peb cov tswv cuab tuaj
Nixie Mood Mood Barometer: 7 Kauj Ruam (nrog Duab)
Nixie Clock Mood Barometer: Ib qho cim tsis zoo ntawm Kev Txhim Kho yog qhov ntsuas qhov ntsuas hauv tsev. Hnub no, koj tseem yuav tuaj yeem pom cov piv txwv hauv tsev ntawm tib neeg ntau dua cuaj caum, tab sis ntau lab ntxiv nyob hauv qhov chaw pov tseg, lossis ntawm eBay