Stap 8: De hulpprogramma's installeren
Nu, zullen we:
- Update de RPI
- activeren van de camera (al gedaan in stap 2)
- Bedrading Pi installeren
Verbinding maken met de RPI in SSH terminal (door de standaard login: pi / wachtwoord: framboos):
Update de RPI:
sudo apt-get update sudo apt-get upgrade => y sudo apt-get dist-upgrade => y
Installatie van bedrading Pi: bron link
sudo apt-get install git-core git clone git://git.drogon.net/wiringPi cd wiringPi git pull origin cd wiringPi ./build
Vervolgens kun je als de installatie ok is:
gpio -v => check the version gpio readall => check the gpio table
Opmerking: de pin 2, 3 en 4 van BCM overeen met 8, 9 en 7 van WiringPi tabel.
Voor test, kunt u controle van leds door dit onder opdrachten: hier beschreven
gpio mode 8 out (to set the pin 8 in out mode) gpio write 8 0 (to set the pin 8 at OFF) gpio write 8 1 (to set the pin 8 at ON)
Init de GPIO bij elke opstart van RPI:
- Maak een script aan init aan de GPIO:
cd /etc/init.d/ sudo nano init_gpio.sh
********************************************************************** #! /bin/bash #Initialisation GPIO pin in out mode and set to 0 #GPIO 8 in out mode and set to 0 (OFF): for white leds (or like you want) /usr/local/bin/gpio mode 8 out /usr/local/bin/gpio write 8 0 #GPIO 9 in out mode and set to 1 (ON): for IR leds (or like you want) /usr/local/bin/gpio mode 9 out /usr/local/bin/gpio write 9 1 ***********************************************************************
CTRL + X = > Y (Ja) = > Enter
- Voeg een regel toe in rc.local-dossier (vanaf bestand):
sudo nano /etc/rc.local
*********************************************************************** ..... # By default this script does nothing. #Init GPIO sudo bash /etc/init.d/init_gpio.sh .... exit 0 ************************************************************************
Nu, na elke herstart van RPI, zullen de leds worden geïnitialiseerd afhankelijk van uw keuze.
Dat de temperatuur en vochtigheid: bewerken van 12 oktober
cd wiringPi/examples sudo nano rht03.c
************************************************************************ => add library #include <time.h> => change the pin #define RHT03_PIN 7 => declare variable int mesure=0; struct tm*t ; time_t tim ; FILE *fichier_log = NULL ; => start : modify the loop in do{}while do { => change delay delay(500); ... => init time variable tim = time(NULL) ; t = localtime(&tim) ; ... => write date in log.csv file fichier_log = fopen("/var/www/log.csv","w"); //open log file fprintf(fichier_log,"%02d/%02d/%04d;%02d:%02d;%2.1f;%2.1f\n",t->tm_mday,t->tm_mon+1,t->tm_year+1900,t->tm_hour,t->tm_min,temp/10.0,rh/10.0); //write date;time;temperature;humidity fclose(fichier_log); //close log file printf ("Temp:%5.1f;Hum:%5.1f\n", temp / 10.0, rh / 10.0) ; mesure=1; //measure ok ... => end : modify the loop in do{}while }while(mesure==0); //go out loop ... *************************************************************************
Ctrl + x = > Y (Ja) = > Enter
make rht03 $[CC] rht03.c $[link] sudo ./rht03 $Temp: 16.4, RH: 63.6
Een script maken:
sudo nano temp_hum.sh #!/bin/sh /home/pi/wiringPi/examples/rht03
Machtiging wijzigen:
sudo chmod 775 temp.hum.sh
Voeg een script in crontab om het script alle 15 minuten (als je wilt):
sudo crontab -e
einde lijn toevoegen:
with temp_hum.log file for degug 0,15,30,45 * * * * /home/pi/temp_hum.sh >> /home/pi/temp_hum.log 2>&1 or without temp_hum.log file 0,15,30,45 * * * * /home/pi/temp_hum.sh
Volgende...