===== Подключение датчика DHT22 к banana Pi ===== VCC (+) -> контакт 3,3 вольта (1-я ножка) на CON3\\ GND (-) -> контакт GND (6-я ножка) на CON3\\ Data (S) -> контакт GPIO4 (7-я ножка) на CON3\\ {{:bananapi:dht22:dht22-pinout.png?200|}}{{:bananapi:dht22:dht22_circuitry_wiring.jpg?200|}} Устанавливаю WiringBP git clone https://github.com/LeMaker/WiringBP.git -b bananapi cd WiringBP chmod +x ./build ./build git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M1_M1Plus cd BPI-WiringPi chmod +x ./build ./build С первого раза не собралось. Т.к. я собирал из под roota в файле build удалил все sudo. В конце установки вижу All Done. NOTE: This is wiringBPi v1, and if you need to use the lcd, Piface, Gertboard, MaxDetext, etc. routines then you must change your compile scripts to add -lwiringPiDev ./build 6,60s user 1,00s system 41% cpu 18,390 total Проверяю. gpio readall +----------+-Rev3-+------+--------+------+-------+ | wiringPi | GPIO | Phys | Name | Mode | Value | +----------+------+------+--------+------+-------+ | 0 | 17 | 11 | GPIO 0 | ALT4 | Low | | 1 | 18 | 12 | GPIO 1 | IN | Low | | 2 | 27 | 13 | GPIO 2 | ALT4 | Low | | 3 | 22 | 15 | GPIO 3 | ALT4 | Low | | 4 | 23 | 16 | GPIO 4 | IN | Low | | 5 | 24 | 18 | GPIO 5 | IN | Low | | 6 | 25 | 22 | GPIO 6 | ALT4 | Low | | 7 | 4 | 7 | GPIO 7 | IN | Low | | 8 | 2 | 3 | SDA | ALT5 | Low | | 9 | 3 | 5 | SCL | ALT5 | Low | | 10 | 8 | 24 | CE0 | IN | Low | | 11 | 7 | 26 | CE1 | IN | Low | | 12 | 10 | 19 | MOSI | IN | Low | | 13 | 9 | 21 | MISO | IN | Low | | 14 | 11 | 23 | SCLK | IN | Low | | 15 | 14 | 8 | TxD | ALT0 | Low | | 16 | 15 | 10 | RxD | ALT0 | Low | | 17 | 28 | 3 | GPIO 8 | IN | Low | | 18 | 29 | 4 | GPIO 9 | ALT4 | Low | | 19 | 30 | 5 | GPIO10 | IN | Low | | 20 | 31 | 6 | GPIO11 | ALT4 | Low | +----------+------+------+--------+------+-------+ Устанавливаю программу для работы с датчиком DHT22 git clone https://github.com/seblucas/lol_dht22.git cd lol_dht22 ./configure make Проверяю: ./loldht usage: ./loldht description: pin is the wiringPi pin number using 7 (GPIO 4) Raspberry Pi wiringPi DHT22 reader www.lolware.net Humidity = 39.80 % Temperature = 32.00 *C Создаю ссылку на исполняемый файл. root@bananapi /usr/local/bin # ln -s /usr/local/src/lol_dht22/loldht loldht loldht usage: loldht description: pin is the wiringPi pin number using 7 (GPIO 4) Raspberry Pi wiringPi DHT22 reader www.lolware.net Humidity = 42.40 % Temperature = 26.20 *C Для удобства мониторинга и хранения данных использую rrdtool. Создаю базу данных с двумя источниками данных therm и hum. root@bananapi /var/db/rrdtool # rrdtool create dht22_01.rrd --start N --step 300 \ DS:therm:GAUGE:600:U:U \ DS:hum:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:288 \ RRA:AVERAGE:0.5:6:336 \ RRA:AVERAGE:0.5:12:744 \ RRA:AVERAGE:0.5:144:730 Написал скрипт для добавления данных в базу данных. cat ht22_rrd.sh #!/bin/sh TEMP=`loldht | grep Humidity` therm=`echo $TEMP | awk '{print $7}'` hum=`echo $TEMP | awk ' {print $3} '` /usr/bin/rrdtool update /var/db/rrdtool/dht22_01.rrd N:$therm:$hum echo -n ${TEMP} >/run/dht-temp echo -n ${therm} >/var/www/therm/current_temp.csv echo -n ${hum} >/var/www/therm/current_hyg.csv exit 0 Добавил в cron строку для выполнения скрипта каждые 5 минут */5 * * * * root /scripts/dht22_rrd.sh > /dev/null 2>&1 Ссылки:\\ http://blog.slucas.fr/blog/banana-pi-7-DHT22-temperature-hygrometrie\\ https://github.com/BPI-SINOVOIP/BPI-WiringPi\\ http://wiki.lemaker.org/WiringPi\\ https://github.com/LeMaker/WiringBP\\ https://alexbloggt.com/dht11-banana-pi-teil2/