Cov txheej txheem:

Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi: 6 Kauj Ruam
Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi: 6 Kauj Ruam

Video: Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi: 6 Kauj Ruam

Video: Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi: 6 Kauj Ruam
Video: Computer Vision with Python! Resizing Images 2024, Kaum ib hlis
Anonim
Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi
Kub & Vaum Los Ntawm Arduino mus rau Raspberry Pi

Saib xyuas qhov kub thiab txias yog qhov tseem ceeb yog tias koj muaj lub tsev cog khoom, lossis muaj phiaj xwm yav tom ntej txhawm rau txhim kho koj lub tsev cog khoom mus rau hauv mini-smart-farm.

Rau kuv thawj Kev Qhia Kuv yuav qhia yuav ua li cas thiaj tsim tau ib qho qauv:

  • Txuas DHT11 qhov ntsuas kub thiab av noo mus rau Arduino Mega 2560
  • Program Arduino hauv C los nyeem cov ntaub ntawv sensor
  • Muab cov ntaub ntawv ntsuas kub thiab av noo ntawm LCD txuas nrog Arduino
  • Qhia Arduino kom xa cov ntaub ntawv ntsuas mus rau Raspberry Pi 3 Model B+
  • Sau cov cai hauv Python los tso saib cov ntaub ntawv ntsuas

Vim li cas siv RPi thiab Arduino ua ke?

Kev sib txuas Arduino thiab RPi tuaj yeem tso cai rau muaj peev xwm loj yog tias koj xav tau I/O uas Arduino ua tau zoo ntawm thiab kev sib txuas lus network/ntau yam nyeem/pom uas RPi zoo dua ntawm.

Hauv lwm lo lus, peb yuav siv Arduino rau kev tswj hwm cov haujlwm hnyav thiab siv RPi rau suav cov haujlwm hnyav.

Ruggedized versions ntawm Arduinos muaj nyob ntawm Rugged-Circuits

Kauj Ruam 1: Tau Arduino & RPi Kho Vajtse

Arduino cov khoom siv pib yog npaj tau thiab tso cai rau koj sim nrog ntau hom kev ntsuas thiab khoom siv. Kev yuav cov khoom siv pib ua haujlwm pheej yig dua es tsis xaj ntau qhov sib txawv. Kuv tau muab qee qhov kev koom tes txuas hauv qab no taw tes rau Banggood thiab Amazon Asmeskas.

Arduino Starter Kit (Banggood)

Arduino Starter Kit (Amazon Asmeskas)

Element14 RPi 3 B+ Motherboard (Amazon Asmeskas)

Raspberry Pi 3 B+ Case (Amazon Asmeskas)

32GB Micro SD daim npav (Amazon Asmeskas).

Kauj Ruam 2: Txuas DHT11 & LCD mus rau Arduino

Txuas DHT11 & LCD rau Arduino
Txuas DHT11 & LCD rau Arduino

Kauj ruam 3: Program Arduino

#arduino-dht11-lcd2004

#Tus Sau: Vasoo Veerapen

#https://www.instructables.com/member/VasooV/ #Nyeem cov ntaub ntawv los ntawm DHT11 txuas nrog Arduino, nthuav tawm ntawm LCD2004 thiab xa cov ntaub ntawv hla mus rau Raspberry Pi

#suav nrog

#suav nrog

// LCD zaub tau txhais raws li tus lej 0x27 ntawm I2C npav

LiquidCrystal_I2C lcd (0x27, 20, 4);

// DHT11 txuas nrog tus pin 8

dht DHT; #define sensorPin 8

// Raspberry Pi txuas nrog Serial 0

#define serialPi Serial

void teeb tsa () {

lcd.begin (20, 4); // Pib lub interface rau lub vijtsam LCD, thiab qhia qhov ntev (dav thiab qhov siab) ntawm cov zaub lcd.init (); lcd.backlight (); serialPi.begin (9600); // Arduino rau tus saib xyuas txuas}

void voj () {

// Nyeem cov ntaub ntawv sensor

int sensorData = DHT.read11 (sensorPin); ntab kub = DHT.temperature; ntab ntub = DHT.humidity;

// Luam kub

lcd.setCursor (0, 0); lcd.print ("Kub"); lcd.print (kub); lcd.print ("C");

// Sau cov av noo

lcd.setCursor (0, 1); lcd.print ("Vaum"); lcd.print (av noo); lcd.print (" %");

// Xa cov ntsuas kub thiab av noo mus rau Raspberry Pi

serialPi.print ("");

// Tos 10 vib nas this

ncua (10000); }

Kauj Ruam 4: Kev Ua Haujlwm Arduino, LCD & DHT11 Teeb

Kev Ua Haujlwm Arduino, LCD & DHT11 Teeb
Kev Ua Haujlwm Arduino, LCD & DHT11 Teeb

Kauj Ruam 5: Txuas Raspberry Pi mus rau Arduino

Txuas Raspberry Pi mus rau Arduino
Txuas Raspberry Pi mus rau Arduino

Kauj Ruam 6: RPi Python Code txhawm rau Nyeem USB Port Serial Data

#rpi-arduino-dht11

#Raspberry Pi nyeem cov ntaub ntawv ntsuas kub thiab av noo los ntawm Arduino

ntshuam serial, hlua, sijhawm

#Hauv qhov piv txwv no /dev /ttyUSB0 tau siv

#Qhov no tuaj yeem hloov pauv hauv koj rooj plaub rau/dev/ttyUSB1,/dev/ttyUSB2, thiab lwm yam. Ser = serial. Serial ('/dev/ttyUSB0', 9600)

#Cov kab hauv qab no ua haujlwm zoo li no:

#Yog tias cov ntaub ntawv muaj nyob tam sim no, nyeem kab ntawv, txiav txim siab cov ntaub ntawv UTF8, #… tshem cov kab tom ntej ntawm kab cim #… faib cov ntaub ntawv mus rau qhov kub thiab txias #… tshem tawm qhov pib thiab xaus cov lus qhia () #… luam tawm cov ntawv thaum Tseeb: yog ser.in_waiting> 0: raws = ser.readline () cookedserial = raws li.decode ('utf-8'). Strip ('\ r / n') datasplit = cookedserial.split (',') kub = datasplit [0].strip ('') luam tawm (kub) luam tawm (av noo)

Pom zoo: