JNie257
Posts: 4
Joined: Tue Oct 03, 2017 9:46 pm

Re: DHT11 readings onto a web page!

Thu Oct 05, 2017 7:43 pm

I have two things in crontab... readTemp.py every 5 minutes and something like "@reboot pigpiod". for some reason pigpiod would not automatically start even after setting up the service so i put that in there and now readTemp.py script runs without complaining about pigpiod not being started. refreshing my browser on "RASPBERRY IP"/webdata/CurrentData.txt, I see that there is indeed changes every 5 minutes.

User avatar
DougieLawson
Posts: 30142
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: DHT11 readings onto a web page!

Fri Oct 06, 2017 6:07 am

Don't put pigpiod in any crontab.

If you need pigpiod to always start at boot
sudo systemctl enable pigpiod.service

If you want to start it now
sudo systemctl start pigpiod.service
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

devtapra
Posts: 4
Joined: Thu Sep 28, 2017 11:51 pm

Re: DHT11 readings onto a web page + an led

Wed Oct 18, 2017 8:29 am

danjperron wrote:
Fri Jan 16, 2015 4:41 am
There is a small differences between the DHT11 and the DHT22

The DHT11 is way less precise and don't go below 0 Celsius.

The data stream output of the DHT22 is 16 bit big endian with the bit 15 for negative indicator.
The DHT11 is 16 bit little endian and both MSB byte are set to zero.

This is a problem when you decode the data.
On the DHT22 the formula is ( (MSB * 256) + LSB) /10
On the DHT11 it is simply the LSB data which is in a swapped position from the DHT22

To have Joan code behave correctly , I just modify it by adding a variable to check if the sensor is a DHT11.

Then If you want to use Joan method with PIGPIO use this step by step method,

1 - update

Code: Select all

sudo apt-get update
2 - Get pigpio

Code: Select all

cd ~
wget abyz.co.uk/rpi/pigpio/pigpio.zip
unzip pigpio.zip
cd PIGPIO
make
sudo make install
3 - Create pigpio service. This way we don’t need to start it all the times


let’s load my pigpio script version

Code: Select all

cd /etc/init.d
sudo wget -O pigpiod \
https://googledrive.com/host/0B9H9nJFy3HJcWVhsY2xUel9uUk0
sudo chmod 755 /etc/init.d/pigpiod
sudo update-rc.d pigpiod defaults 9
complete -W "$(ls /etc/init.d/)" service
sudo service pigpiod start
ref: http://blog.scphillips.com/2013/07/gett ... e-on-boot/

4 - Let’s download my modified version of Joan’s DHT22 code

Code: Select all

cd ~
wget https://www.dropbox.com/s/326si04qiheqfw1/DHT22.py


Be sure that you are using GPIO22 (pin 15) otherwise you will have to change the pin information in the code.


if everything is ok just type

Code: Select all

sudo python DHT22.py
and it should returns

Code: Select all

pi@raspberrypi ~ $ sudo python DHT22.py
1 33 23 0.19 0 0 0 0
2 34 23 0.19 0 0 0 0
3 34 23 0.19 0 0 0 0
Temperature 23 Celsius humidity 34%

I will continue tomorrow with the script to store into rrdtool

Daniel
i get

1 -999 -999 -999.00 0 0 0 0
2 -999 -999 -999.00 0 0 0 0
3 -999 -999 -999.00 0 0 0 0
4 -999 -999 -999.00 0 0 0 0
5 -999 -999 -999.00 0 0 0 0
6 -999 -999 -999.00 0 0 0 0
7 -999 -999 -999.00 0 0 0 0
8 -999 -999 -999.00 0 0 0 0

can you help me ?

danjperron
Posts: 2667
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: DHT11 readings onto a web page!

Wed Oct 18, 2017 1:45 pm

can you help me
@devtapra Yes I do have a big crystal ball but I only see some strutures magnification of the table.

Well If you need help you need to give more hints.

1- How is your sensor connected. Which pins? Do you add the 4k7 pull-up resistor ?
2- I hope you connect 3.3V on it and not 5V!
3- Is it a DHT22 or a DHT11 ?
4- Did you check if pigpio is working. Did you try to toggle some GPIO with pigpio and check if it toggles?
5- Also what kind of Raspberry Pi do you have ?

The DHT22.py script has the DHT11=True. if you are using a DHT22 it should be set to False. (line 265). And the GPIO pin is set to GPIO22.

A picture of your setting will help. We need to see the wires connection from the sensor to the GPIO connector of the Raspberry Pi.

Daniel

danjperron
Posts: 2667
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: DHT11 readings onto a web page!

Wed Oct 18, 2017 1:59 pm

@devtapra the step 3 is different with systemd

sudo systemctl enable pigpiod
sudo systemctl start pigpiod


B.T.W. Readings with -99 -999 -999.00 means that the sensor is not detected at all.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 21 guests