Edited by actkk2000 at 2014-10-22 01:23 |
This is an update for http://forum.lemaker.org/thread- ... art_2_ds18b20_.html
Seeing that the temperature sensor DS18B20 was quite unstable or very sensitive, but in the end I was not sure, and since I found another sensor for humidity, I decided to buy it for a test.
It is the famous DHT11:
The DHT22 would be better, but I got this one (two, one for the Raspberry) very cheap ... (Not from Adafruit: P)
I was going to lose the decimals, but I would gain the possibility to measure humidity...
I used this tutorial as a guide:
http://forum.lemaker.org/thread- ... ure_from_dht11.html
And again I had to adapt the output to show it on the character display.
This time it was more difficult because despite this software worked, it wasn't enough...
Previously when connecting DS18B20 in 1-wire mode, the software modules write a file and update it with temperature.
If you run this at the end you get temperature and you can read it with a program in Python:
With the DHT11 I had to make the program create two files, one for temperature and one for humidity, constantly updated and available for reading from Python. Copy the Code
- sudo modprobe w1-gpio
- sudo modprobe w1-therm
- cd /sys/bus/w1/devices
- cd 28-xxxx (change this to match what serial number pops up)
- cat w1_slave
Then I had to modify the program written in C++ to generate those files in an infinite loop, and also to be implemented as service on the Pi.
Nevertheless, I was unable to find other programs to do the reading from DHT11 sensor on BPI, and the only one that worked is this tutorial from julie20082004.
One more drawback was that because of lack of decimals, I had to replace the last two digits with special characters to differentiate humidity from temperature: °C and %
But leaving the previous sequence when changing temperature / humidity with the switch key, the 3rd. digit was always fixed in a small circle.
So I also had to change the sequence and decided to use a model I saw on a street clock where both temperature and humidity appear replacing time, based on a fixed scale of time. The switch key now change time / temperature <-> time / humidity.
Here some pictures and video of how it turned out and how the sensor works.
There are a couple when I tried to attach DHT11 to the front, but in the end I decided to leave it on the top.
I like it more because it is mounted on a little board with a red LED:
click to enlarge:
What I also added is the RPI-Monitor program to monitor BPI from a web page, with configurable parameters:
There are also tutorials on how to customize it and add sensors. Of course DHT11 and DS18B20 as well:
http://rpi-experiences.blogspot. ... -advance-usage.html
http://rpi-experiences.blogspot. ... dht22-humidity.html
It works like this (I marked the part with temperature and humidity):
Another problem I found is that from time to time the character display hung, stopping clock or temperature / humidity.
The only solution was to restart the service to load it again.
But it was annoying have to restart manually every time it happened, so I also had to find a program to monitor services and automatically restart them when needed.
The best program for that is Monit. It is also good to show BPI parameters and send alerts, and more.
To me was enough if the service stopped to crash. And it really works:
https://www.digitalocean.com/com ... and-configure-monit
Monit looks like this, for now with just one service which is good enough:
See you soon on the next update!