0

DHT 22 Temperature and Humidity sensor with adafruit code
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by thonka on Wed Feb 11, 2015 4:59 pm

adafruit_support_rick wrote:Make sure you have the Date/Time column in the spreadsheet formatted to display the time as well as the date


I do have the format with Date and hour, but it still shows it without the hour.

thonka
 
Posts: 4
Joined: Tue Feb 10, 2015 4:37 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by adafruit_support_rick on Wed Feb 11, 2015 7:58 pm

What if you make the column wider?

The thing is, the date and time are all contained in one single number. So it must be a formatting issue in the spreadsheet.

adafruit_support_rick
 
Posts: 35009
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by thonka on Fri Feb 13, 2015 1:18 pm

adafruit_support_rick wrote:What if you make the column wider?

The thing is, the date and time are all contained in one single number. So it must be a formatting issue in the spreadsheet.


Hi,

I check it once again but the result is the same, I create a new google doc, but the time doesn't appear.. only the date. I didn't change anything in the code, only the pin number.. any other advice? :(

thonka
 
Posts: 4
Joined: Tue Feb 10, 2015 4:37 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by tdude on Sat Feb 14, 2015 11:44 am

I think i know how to solve the random stopping, is it possible to make a crontab script that would stop the sensor script and start it again? Currently I have it set up to restart every day and it is working, but i don't think you necessarily need to restart the whole thing to get it going again.

tdude
 
Posts: 4
Joined: Mon Feb 02, 2015 3:06 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by tdicola on Sat Feb 14, 2015 4:00 pm

thonka wrote:
adafruit_support_rick wrote:What if you make the column wider?

The thing is, the date and time are all contained in one single number. So it must be a formatting issue in the spreadsheet.


Hi,

I check it once again but the result is the same, I create a new google doc, but the time doesn't appear.. only the date. I didn't change anything in the code, only the pin number.. any other advice? :(


Try adjusting the date formatting for the column in the google spreadsheet UI. At a low level the full date is being sent to the spreadsheet but google's UI can choose to format it in different ways like only showing a date, time, etc. Adjusting the date format for the column should let you pick how you want it displayed.

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by tdicola on Sat Feb 14, 2015 4:08 pm

tdude wrote:I think i know how to solve the random stopping, is it possible to make a crontab script that would stop the sensor script and start it again? Currently I have it set up to restart every day and it is working, but i don't think you necessarily need to restart the whole thing to get it going again.


Yep that's a good idea to help keep things running consistently. I think the easiest option is to make a little shell script that kills any running script process and then runs it again, for example create a file called run_spreadsheet.sh and put something like this in it:
Code: Select all | TOGGLE FULL SIZE
#!/bin/sh
pkill -9 google_spreadsheet.py
python /path/to/google_spreadsheet.py


That script will use the pkill command to force the google_spreadsheet.py script to stop running, and then run a new instance of it again right afterwards. Make sure to change /path/to/google_spreadsheet.py to the right path for your system and setup. Also make the script executable by running:
Code: Select all | TOGGLE FULL SIZE
chmod +x run_spreadsheet.sh


Now try running the script just to test it works with no instance running (note that you need to run it as root with sudo):
Code: Select all | TOGGLE FULL SIZE
sudo ./run_spreadsheet.sh


You might see an error that pkill couldn't find a process to kill, but that's ok and can be ignored. You should see the spreadsheet code starts running. Now in a new tab / connection to the terminal run the script again. You should see your original process stop running and the new one take over running.

Once that looks good you're ready to setup a cron job that runs it every day/few hours. I've actually found these instructions for using cron are really nice: https://help.ubuntu.com/community/CronHowto Give that a read through and it should point you in the right direction for making the run_spreadsheet.sh script a new cron job. Good luck!

tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by thonka on Sun Feb 15, 2015 9:20 am

tdicola wrote:
thonka wrote:
adafruit_support_rick wrote:What if you make the column wider?

The thing is, the date and time are all contained in one single number. So it must be a formatting issue in the spreadsheet.


Hi,

I check it once again but the result is the same, I create a new google doc, but the time doesn't appear.. only the date. I didn't change anything in the code, only the pin number.. any other advice? :(


Try adjusting the date formatting for the column in the google spreadsheet UI. At a low level the full date is being sent to the spreadsheet but google's UI can choose to format it in different ways like only showing a date, time, etc. Adjusting the date format for the column should let you pick how you want it displayed.


I did it, but it seems that nothing changes, I recorded it - http://youtu.be/9wkzom15SmY
I've made a test with a form and sending the answers to the google doc, and in this case, with the answers from the form there was the date and hour.. but not with the sensor reading.. :(

thonka
 
Posts: 4
Joined: Tue Feb 10, 2015 4:37 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by Myke974 on Tue Feb 17, 2015 3:24 am

Raspberry Pi and DHT22 :
2015_02_16_MP8X02.jpg
MP8X + Rasp.Pi + DHT 22
2015_02_16_MP8X02.jpg (204.77 KiB) Viewed 757 times

- Strange problem with the google sheet data logging : 95 % of time ,it doesn't write/log the temperatures but some strange date ! :O
- Problem with the time in the sheet : only date and some 0:00:00 visible for the hour,minutes and seconds.

Fixed with :
1] A clean install : https://github.com/adafruit/Adafruit_Python_DHT and download the .zip
2] From the decompressed directory : sudo python setup.py install
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~/adafruit/Adafruit_Python_DHT-master/examples $ sudo ./AdafruitDHT.py 22 22
Temp=28.7*C  Humidity=61.0%

3] Time fixed with old google sheet : https://g.co/oldsheets
rob61280 wrote:I encountered the same problem, it seems that gspread isn't working the new google spreadsheets, use the link below to create an old version of a google spreadsheet, then your code should work.
https://g.co/oldsheets
Source (https://github.com/burnash/gspread/issues/111)
Thanks multivoxmuse!

Thanks rob61280 !
----------------------
This far, I am able to log the time + temperatures + humidity, please see attached cap:
mp8xdatalog1.jpg
mp8xdatalog1.jpg (25.8 KiB) Viewed 757 times

----------------------
Problems:
- When I try to choose only 2 decimals in the format option of the sheet, nothing happens !
- When trying to insert/create a graph from the valors !

Myke974
 
Posts: 1
Joined: Mon Feb 16, 2015 3:12 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by ts on Wed Feb 18, 2015 7:25 pm

I have just been using the code to build a temperature logger and I found I had to change my account details and enable "access to less secure apps"

Access for less secure apps has been enabled

ts
 
Posts: 1
Joined: Wed Feb 18, 2015 7:23 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by ayushkhemka on Wed Feb 18, 2015 9:30 pm

If I use a Beagleboard-xM instead of BBB, do the steps remain the same? Only the GPIO pins should change right? I'm completely new to Beagleboard development.
Also, I would appreciate if you could provide some links on how to get started with BBB/xM from scratch, meaning right from receiving the board to writing my first program.

ayushkhemka
 
Posts: 2
Joined: Fri Jan 23, 2015 12:02 am

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by adafruit_support_rick on Thu Feb 19, 2015 10:39 am

Don't know. We don't support the Beagleboard xM here.

adafruit_support_rick
 
Posts: 35009
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by Josefan on Sun Mar 08, 2015 10:07 pm

Hi

I had problems logging with 2-step verification. Solved it by generating an app password.
https://support.google.com/accounts/answer/185833

Josefan
 
Posts: 2
Joined: Sun Mar 08, 2015 9:42 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by ssdd1985 on Fri May 08, 2015 6:03 pm

**I AM A NOOB** i followed the instructions fully enabled drive api shared the speadsheet with the client id put .jon file in the examples but when i run it i get this message.

Logging sensor measurements to DHT humidity Log every 30 seconds.
Press Ctrl-C to quit.
Unable to login and get spreadsheet. Check OAuth credentials, spreadsheet name, and make sure spreadsheet is shared to the client_email address in the OAuth .json file!

ssdd1985
 
Posts: 3
Joined: Fri May 08, 2015 5:55 pm

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by adafruit_support_rick on Sat May 09, 2015 9:33 am

Unfortunately, google changed the authorization for spreadsheet docs on April 20. Please see this thread:

viewtopic.php?f=19&t=72568&hilit=+oauth2#p368130

The tutorial should have been updated with the new OAuth2 requirements. Is that what you're having a problem with?

adafruit_support_rick
 
Posts: 35009
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: DHT 22 Temperature and Humidity sensor with adafruit cod

by ssdd1985 on Sat May 09, 2015 9:51 am

That's is same tutorial I followed. I only started a couple of days ago so I will of gotten the updated one. One think I will scrap and start for scratch keep thinking I must off missed something going over and over it.

ssdd1985
 
Posts: 3
Joined: Fri May 08, 2015 5:55 pm

Please be positive and constructive with your questions and comments.