sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 4:31 pm

danjperron wrote:It is not a problem.

Just don't implement it!

B.T.W. The LM35 sensor is analog. You will have to get an A/D converter if you want to read it.
Sorry whats an A/D converter? :(
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 4:45 pm

google "raspberry pi A/D converter " and read about it

A/D is analog to digital

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 4:50 pm

danjperron wrote:google "raspberry pi A/D converter " and read about it

A/D is analog to digital
http://www.ebay.in/itm/USB-To-RS232-PL2 ... 2594c73e00
Is this what you are talking about?
Forgive me for my grammar :(.


sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 5:21 pm

Can we do it without it?
Because it is not avail in here ,I need to go to local market again :(
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 5:38 pm

Could you have access to an Arduino ? http://www.arduino.cc/

http://www.instructables.com/id/ARDUINO ... NSOR-LM35/

any model will do.

This way you could use the arduino A/D to read analog signal from the LM35 and send it the raspberry Pi via serial communication.

http://www.raspberrypi.org/forums/viewt ... 51#p665551

Daniel

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 5:43 pm

danjperron wrote:Could you have access to an Arduino ? http://www.arduino.cc/

any model will do.

This way you could use the arduino A/D to read analog signal from the LM35 and send it the raspberry Pi via serial communication.

http://www.raspberrypi.org/forums/viewt ... 51#p665551

Daniel
I don't have arduino but i am thinking of buying it :).
This would take time tho :(.
http://www.ebay.in/itm/DS18B20-Programm ... 3ceb596723
Is this the other sensor?
if it is then i could buy it tho :P
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 5:52 pm

The question is ?

Do you really need another sensor? In Canada where I live the external temperature is quite different from inside the house.

Last Week it was below -20 °C with peak at -29 °C . Today it's 0°C but will plunge to -18 °C tonight and the rest of the week it will be around -10°C during the day.

For me it is nice to compare inside versus outside temperature.

You could put another DHT11.

Daniel

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 5:58 pm

Yes this is exactly that one but I use one from dx.com. It is inside a stanless steel probe.

http://www.dx.com/p/water-proof-ds18b20 ... L1FmdLF8m8

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 6:02 pm

danjperron wrote:The question is ?

Do you really need another sensor? In Canada where I live the external temperature is quite different from inside the house.

Last Week it was below -20 °C with peak at -29 °C . Today it's 0°C but will plunge to -18 °C tonight and the rest of the week it will be around -10°C during the day.

For me it is nice to compare inside versus outside temperature.

You could put another DHT11.

Daniel
Actually DHT11 is more costly as the shipping is to high ,This one is fine and yeah now a days i can see google telling me 0C but the DHT11 saying 24C that's it :?
I have observed that it is super cold but it still says the same.
I wanna try a new one so i could be sure before showing it to my professor.
What would you recommend,Just wanna be double sure i just don't wanna go wrong as my friends are buy HQ shit :lol:
and yeah this one http://www.ebay.in/itm/DS18B20-Waterpro ... 2a49f3347c
Forgive me for my grammar :(.


sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 6:14 pm

Should i buy? ;)
Waiting for your reply ,Then will buy :D ;)
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 7:20 pm

I'm not the one to decide! It is your decision.

I.M.O. it is okay.

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

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 7:22 pm

Anyway I will post something for people who want to read data from an arduino since I do have arduino and some LM35.

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Mon Jan 19, 2015 7:25 pm

danjperron wrote:Anyway I will post something for people who want to read data from an arduino since I do have arduino and some LM35.
Sure I will buy it by tomorrow and get it by Friday.
Gotta wait till then and the time issue have started again :( :(
The ntp is not updating time and my pi is in 1970 right now lol.
I am going to sleep now will post details later.
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 3:32 am

OK The LM35 connected directly on a Arduino has a range from 2 to 150 Celsius.

That won't solve your problem with temperature below 0.

From a post I demonstrate how to read an arduino analog input using the serial communication

http://www.raspberrypi.org/forums/viewt ... 51#p665551

I attached the LM35 to A0 pin of the arduino UNO which is connect directly on the USB port.

The serial port is detected as /dev/ttyACM0

Image

Ok similar to the DS18B20, you need to add a new data point into the rrdtool

Code: Select all

sudo ./rrdaddsource.pl temperatures.rrd r.rrd th_lm35:GAUGE:1200:0:150
sudo rm temperatures.rrd
sudo cp r.rrd temperatures.rrd
And a new readTemp.py is needed. This one include the DS18B20 and the Arduino serial communication

Code: Select all

cd ~
rm readTemp.py
wget -O readTemp.py https://dl.dropboxusercontent.com/u/48891705/rpi/DHT11Chart/readTempLM35.py
chmod +x readTemp.py
Now just wait 15 minutes to have the sensor on the Chart.

You have other analog on the arduino. It is possible to add light sensor, pressure sensor, etc..
Also you could export other data for other charts.

Now only thing left for you is to understand all that info and figure how they work together.
Last edited by danjperron on Sun Jan 25, 2015 2:27 am, edited 2 times in total.

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 2:24 pm

DougieLawson wrote:If your system is connected to the public internet then the ntpd task that's running will fix the clock and keep it sync'd to the public time servers. You can test whether that's working with the ntptime and ntpq -p commands.
Brother I tried the commands and found out they were not working, so I installed an alternative chrony but it is also not working. I have also tried this thread http://www.raspberrypi.org/forums/viewt ... 2&p=506585
But nothing have changed I think my pi is not working to get time from servers.
Can you help me diagnose this problem?
Forgive me for my grammar :(.

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 3:28 pm

@danjperron How can i stop the script for a while?
I wanna try my new leds that i bought and it is safe to directly remove the DHT11? :?:
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 3:32 pm

Is your firewall blocking NTP (udp 123) packets?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 3:39 pm

DougieLawson wrote:Is your firewall blocking NTP (udp 123) packets?
No i don't think so ,I only have a router and did not found the port 123 blocked anywhere.
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 4:37 pm

I wonder if I should let you check in backward what we did ;-)!

Just add a # in front of the line in crontab

Code: Select all

sudo crontab -e

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 4:38 pm

danjperron wrote:I wonder if I should let you check in backward what we did ;-)!

Just add a # in front of the line in crontab

Code: Select all

sudo crontab -e
Lol sorry i did that :lol: ;)
Forgive me for my grammar :(.

sultan
Posts: 58
Joined: Wed Jan 14, 2015 4:50 pm
Location: India

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 7:11 pm

danjperron wrote:I wonder if I should let you check in backward what we did ;-)!

Just add a # in front of the line in crontab

Code: Select all

sudo crontab -e
I got a new achievement lol ,After searching through the code i found that it has some led code. After trying for 20 min i got the DHT22.py working.The edited DHT22.py is down.

Code: Select all

def trigger(self):
      """Trigger a new relative humidity and temperature reading."""
      if self.powered:
         if self.LED is not None: 4 # This is the GPIO port.
         self.pi.write(self.LED, 1)        # This was on another line just removed the space and got it working.

         self.pi.write(self.gpio, pigpio.LOW)
         time.sleep(0.017) # 17 ms
         self.pi.set_mode(self.gpio, pigpio.INPUT)
         self.pi.set_watchdog(self.gpio, 200)
and the other part

Code: Select all

if __name__ == "__main__":

   import time

   import pigpio

   import DHT22

   # Intervals of about 2 seconds or less will eventually hang the DHT22.
   INTERVAL=3

   pi = pigpio.pi()

   s = DHT22.sensor(pi, 22, LED= 4, power=None,DHT11=True) # Here we added LED = 4 which is our GPIO pin.

   r = 0

   next_reading = time.time()
Now another problem is the readTemp.py is not reading the temp but the DHT22.py is here is the error it is throwing me .

Code: Select all

[email protected] ~ $ sudo python readTemp.py
Traceback (most recent call last):
  File "readTemp.py", line 78, in <module>
    readDHT_sensor()
  File "readTemp.py", line 51, in readDHT_sensor
    probe.trigger()
  File "/home/pi/DHT22.py", line 236, in trigger
    self.pi.write(self.LED, 1)
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 1022, in write
    return _u2i(_pigpio_command(self.sl, _PI_CMD_WRITE, gpio, level))
  File "/usr/local/lib/python2.7/dist-packages/pigpio.py", line 745, in _pigpio_command
    sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
struct.error: cannot convert argument to integer
I think i messed up all thing's :( :( :( :( .
Help me bro.
Forgive me for my grammar :(.

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

Re: DHT11 readings onto a web page!

Tue Jan 20, 2015 8:34 pm

First DHT22.py is used as a module and evrything under the line

Code: Select all

if __name__ == "__main__":
won't run. Classic way of verifying module when run standalone.


They way DHT22.py is build we don't need to modify it to pass parameter.
I did modify it to enable the DHT11 but that's it.



The proper way to implement the LED will be to modify readTemp.py

Find the line for the DHT22 sensor construction and set it to

Code: Select all

#set  LED BCM23 pin16 to output
pi.set_mode(23,pigpio.OUTPUT)

probe = DHT22.sensor(pi,SENSOR_GPIO,LED=23,DHT11=ISDHT11)

Now my DHT22 just hang for no reason! :-/
I will have to implement the power reset cycle.


Daniel

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

Re: DHT11 readings onto a web page!

Wed Jan 21, 2015 1:29 am

I know that the DHT22 has tendency to lock up. The only method I found without locking the DHT22 was the SPI method.

But since Joan's code include a power cycle method to put it back ON, let's use it.

I connect the power of the DHT22 with the pull-up resistor of the data pin to GPIO24. This way when GPIO24 pin is low, the DHT22 loss power.

So this is the line to modify in readTemp.py to make it effective.

Code: Select all

pi=pigpio.pi()

#set LED BCM23 pin16 to putput
pi.set_mode(23,pigpio.OUTPUT)

#set DHT22 POWER using GPIO 24
pi.set_mode(24,pigpio.OUTPUT)
#power up GPIO for DHT22 power
pi.write(24,1)

probe = DHT22.sensor(pi,SENSOR_GPIO,LED=23,power=24,DHT11=ISDHT11)
GPIO 22 => DHT22 data
GPIO 23 => external LED to display DHT22 activity
GPIO 24 => DHT22 power. Enable full reset of the DHT22 device

With all the sensors connected, another problem occured. We grab data points every 5 minutes and we export them in the same step.
The datas are pushed in real time, "N" , it is possible that some points will be recorded with a time stamp bigger than 300 seconds and we will miss the 5 min. point.

There is two alternatives,

1 - Sampling every 2 minutes. This way we will have always some data every 5 minutes. The data structure already specify average mode.

2 - Instead of pushing data into real time we could force the time to be exactly 5 minutes step.

For simplicity I decided to change the crontab to 2 minutes. Problem fixed!


Daniel

Return to “Python”