technik007_cz Posted November 22, 2015 Posted November 22, 2015 Hi guys, do you know some article about how to run DHT11 or DHT22 sensors on Banana Pi? I have one sensor bmp180 on I2C bus and reading temperature and barometric pressure was quite easy but this is different bus and move code from Raspberry needs more effort. Basically I need proper binary able to read from gpio pins and I want to record/show values from this sensor on Rpi Monitor. If somebody have previous experiences with that and want to share them I will be very appreciated.
zador.blood.stained Posted November 23, 2015 Posted November 23, 2015 I think you can install WiringBP library ( http://wiki.lemaker.org/WiringPi) and then use any DHT11/DHT22 library designed for Raspberry Pi / WiringPi, for example, this: https://github.com/technion/lol_dht22 Should work according to this: http://4pda.ru/forum/index.php?showtopic=575249&st=440#entry43235483 Edit: WiringBP may depend on specific kernel version or configuration options, but I believe it should work with legacy 3.4.10x kernels.
tkaiser Posted November 23, 2015 Posted November 23, 2015 I used both zador's attempt with DHT22 and a more simple approach I found here (both requiring WiringPi) for DHT11. But since I had the need to continually write to a logfile that has been parsed by another process (RPi-Monitor) I had to made an adjustment: adding "fflush(stdout);": http://pastebin.com/j1ec3Aqx Just follow LeMaker's instructions and ensure that dht11.c is lying next to the WiringBP folder.
Rui Ribeiro Posted November 25, 2015 Posted November 25, 2015 I have been toying for this ideia for a while. Where do you have your sensors, only in the indoors, or do you have sensors for outdoors too? How much are they good/sensitive? Are they good enough to join online communities like Awekas? (I doubt it, just asking...)
tkaiser Posted November 25, 2015 Posted November 25, 2015 Where do you have your sensors, only in the indoors, or do you have sensors for outdoors too? How much are they good/sensitive? I use one inside a Lamobo R1's enclosure where measuring humidity makes absolutely no sense at all This was just sort of a test run between DHT11 and DS18B20 regarding temperature (the latter won -- see post 20 in this thread), it's important to always take ambient temperature into account when doing thermal measurements (eg. how behaves a SoC when you adjust dvfs tables). And since the DHT11 was already inside, I left it there to measure internal enclosure temperatures. I would better ask in another place (without knowing where, but I asked another community member to contribute here) since it seems the knowledge we collect here is more software/server centric. And I would also have a look how to query the sensor (dealing with eg. DHT11/DHT22 is timing critical and I get a lot of read-out errors and had to write a filter script to drop erroneous values). All stuff that applies to RPi or any other SBC combined with sensors will fortunately apply to the ARM boards we use too. It's just a matter of settings sometimes, eg. https://github.com/igorpecovnik/lib/issues/125
OldMan Posted November 25, 2015 Posted November 25, 2015 I have also a BMP180 and its absolutely easy to read it out since there exists a kernel module bmp085 for it ... however if you only want to read temperatures I would prefer the LM75(A) chip which uses also I2C, and there exists a kernel module too ... Armbian has already the bmp085 module included IIRC; the lm75 module is currently missing, but I asked Igor already for it, and next release comes with a bunch more of sensor modules (see the link tkaiser posted above); till then we can still use Python or a C program for reading the LM75; ready-ro-use breakouts are really cheap on the Bay: http://www.ebay.com/itm/331655700684http://www.ebay.com/itm/400974994990 and if you want to solder self, the chips only + adapter pcb are even cheaper: http://www.ebay.com/itm/221852588460http://www.ebay.com/itm/321572647120 but I would not extend the I2C bus more than 70cm; so if you're looking for temp sensors for outdoors then the DS18B20 seems the right choice; waterproof versions are really cheap, f.e.: http://www.ebay.com/itm/171422502025 although I have some DS18B20 which I used already with Arduinos, I've not yet connected one to a BPi board, so cant tell how well this will work or what software support exists for it (kernel module?) ...
zador.blood.stained Posted November 25, 2015 Posted November 25, 2015 My experience with different sensors: DHT11 doesn't have neither temperature nor humidity range to be used as outside sensor. And even when I used it indoors, it looked like it was measuring humidity somewhere on Mars rather then in my room. Maybe DHT22, which also has wider range, would have better accuracy, but I switched to SHT10 sensor for temperature and humidity. Not mentioning that it has no kernel support, and using time-critical protocol from user space can lead to errors, as @tkaiser pointed out. SHT10 is much better compared to DHT11 (although it is more expensive), has wide enough range to be used outdoors, but wire length will be main limiting factor. Supported by kernel module "sht15". However, any resistive (DHT11/DHT22) or capacitive (SHT1x) humidity sensors should be protected from direct sunlight, dust, extreme high humidity or water (dew, steam, rain, snow, ...) - it may be problematic. For reading only temperature - DS18x20 sensors are good. They are supported by kernel too (w1therm module if I'm not mistaken).
tkaiser Posted November 25, 2015 Posted November 25, 2015 Three more things to add regarding 1-Wire: It has been recommended to me to buy an I2C-to-1Wire bridge like 1 Wire Pi to protect the board from ESD damage and to have easier access to sensors: http://forum.lemaker.org/forum.php?mod=redirect&goto=findpost&ptid=8312&pid=40322 Worth a look: OWFS Here a user has shown a solution to use 1-Wire reliably over longer distances. 1
tkaiser Posted November 25, 2015 Posted November 25, 2015 Basically I need proper binary able to read from gpio pins and I want to record/show values from this sensor on Rpi Monitor. LOL, I've not realized that you're already using RPi-Monitor. In case you use my sunxi addons it would be easy to replace the temperature daemon (/usr/share/rpimonitor/scripts/sunxi-temp-daemon.sh) with this extended version where you might want to disable some stuff (eg. querying external weather stations via HTTP to also monitor your town's temperature and exact parsing of /proc/stat to get an idea what's really going on -- average load is so misleading): http://pastebin.com/U08kPTxt I start the daemon as such through an init script: root@lamobo:~# cat /etc/init.d/sunxi-tempd #!/bin/sh ### BEGIN INIT INFO # Provides: sunxi-tempd # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # X-Interactive: true # Short-Description: RPi-Monitor sunxi-temp helper # Description: Sunxi-temp helper for daemon for RPi self monitoring daemon ### END INIT INFO # Source function library. . /lib/lsb/init-functions DAEMON="/usr/share/rpimonitor/scripts/sunxi-temp-daemon.sh" PIDFILE="/var/run/sunxi-tempd.pid" [ -x $DAEMON ] || exit 0 checkroot(){ if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" exit 1 fi } start() { touch $PIDFILE for pid in $(cat $PIDFILE); do if ( kill -0 $pid > /dev/null 2>&1 ); then echo "Sunxi-temp helper is already running."; status; return 0; fi done; log_daemon_msg "Starting Sunxi-temp helper for RPi-Monitor" "sunxi-tempd" nice -n 19 $DAEMON $PIDFILE & status=$? log_end_msg $status } stop() { touch $PIDFILE log_daemon_msg "Stopping Sunxi-temp helper RPi-Monitor" "sunxi-tempd" for pid in $(cat $PIDFILE); do kill -15 $pid > /dev/null 2>&1 done status=$? log_end_msg $status rm $PIDFILE } restart() { stop sleep 2 start } status(){ echo -n "Sunxi-temp helper RPi-Monitor status: " if [ ! -f $PIDFILE ]; then echo "Not running" exit 0 fi for pid in $(cat $PIDFILE); do kill -0 $pid > /dev/null 2>&1 && echo -n "[ \033[1;32mok\033[0m ]" || echo -n "[\033[31mFAIL\033[0m]"; done; echo } checkroot case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo "Usage: $0 {start|stop|restart|status}" ;; esac exit 0 But it should also work if you just start it from /etc/rc.local -- then uncomment the last line. You need the first 2 lines to query the DHT11: echo 'Humidity = 300 % Temperature = 300 °C' >/var/log/enclosure.log /usr/local/bin/dht11 >>/var/log/enclosure.log & # /usr/share/rpimonitor/scripts/sunxi-temp-daemon.sh & My /etc/rpimonitor/data.conf looks like on this system: include=/etc/rpimonitor/template/version.conf include=/etc/rpimonitor/template/uptime.conf include=/etc/rpimonitor/template/pispy.conf include=/etc/rpimonitor/template/memory.conf include=/etc/rpimonitor/template/swap.conf # include=/etc/rpimonitor/template/sdcard.conf include=/etc/rpimonitor/template/lamobo-disks.conf include=/etc/rpimonitor/template/network.conf All that's necessary (including the /usr/local/bin/dht11 binary) you'll find here: http://kaiser-edv.de/downloads/sunxi-temp-daemon-with-dht11.tgz 1
tkaiser Posted November 25, 2015 Posted November 25, 2015 "Enclosure" is a DHT11 and "Ambient" a DS18B20. And you will need to adjust the templates a bit since I monitor a lot of stuff there: 1
Rui Ribeiro Posted November 28, 2015 Posted November 28, 2015 Thanks for all the valuable information and your time. I guess I am not buying then the DHT11.
Rui Ribeiro Posted April 13, 2016 Posted April 13, 2016 guys, what do you think am3220 or sht10 for measuring humidity?
Igor Posted April 13, 2016 Posted April 13, 2016 You mean AM2320B ? http://www.ebay.com/itm/201502785138 I2C, so 4 wires, don't have it but I guess it looks ok.
Rui Ribeiro Posted May 22, 2016 Posted May 22, 2016 Hi guys, been trying to read a AM2301/DHT21 in a Lamobo R1, kernel 4, and it is driving me nuts. Already installed WiringBP, tried DHT21-AM2301, lol_dht22 and a few others. Using GPIO5, WiringPI PIN 5, PIN 18 in the Lamobo R1. The temperature reads fine, however humidity always at 99.9%. With or without the resistor....To give them credit, the procedure seems straightforward for a raspberry pi.
Rui Ribeiro Posted June 22, 2016 Posted June 22, 2016 I ended up writing my own daemon based on lol_dht22. https://github.com/ruyrybeyro/rdht
Recommended Posts