Log data with a DHT22 temp sensor & a Pi to Google Spreadsheet

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today it's about a referee by temperature sanli but we connect these two and how we can read the data out of it and put in good-looking chart so stay tuned so what we have here is raspberry pi 3 model B and a dht22 temperature sensor this sensor is about 5 euros and it comes on a little PCB and it's so ready to use we are going to use the raspberry PI's GPIO ports that's this 40 pin header on the top of it as you can see here we are going to connect the orange cable to the GPIO port 4 which is actually pin 7 we connect ground to pin 6 and we connect the red cable to pin 1 which is 3.3 volts yum that's basically it so let's take into the software powered first of all we are going to clone the software we need you'll find a link in the description of this video I made a so called fork of this project because this library we are using is actually a bit duplicated but it's for our purpose quite good in order to get this running we have to install this Lorient to build it this only takes a little moments depending on the speed of your little raspberry and then we are almost ready to go this library already brings some examples and we are going to use them so we switch into the examples folder and we are going to use the arrow fruit DHT dot py squared it's important now what you are typing you have to add the 22 which stands for the sensory you are using if you are using the dht11 sensor for example you are going to type 11 here the last digit is number of the GPIO port you connected your Sansa to you remember we connected it to GPIO pin four so we talked before and if you made no mistake it should now display the temperature and the humidity easy huh so that's nice but let's continue next thing is to put this data into a Google spreadsheet fortunately this library already has a good example for this too but to get rolling we need some additional software just copy and paste this line and install these dependencies if you are asking yourself why are we using Google for this there is an easy explanation for this the lifetime of the SD card in the raspberry pi is slightly limited when you write every minute to it and since this library already brings a great example of writing to Google Spreadsheets I thought it might be a great idea to use Google just as our database next we reopen this Google spreadsheet dot py there is some documentation in the code and you will find a link to a little tutorial on how to configure your Google account the link is under this video too first of all we need API access for our project therefore we open the Google developer console and create a new project I name my project this is pi after that we search for the drive API we have to enable access to it after that we search for the sheets API because we need access to this - just click enable again now comes the tricky part we need to create some credentials for this we need a so-called service account service account needs a name take anything you want I used pi [Music] it needs permissions editor permissions to write to sheet that's important and click continue with this we are now able to create a key so click create key and make sure Jason is selected click create again download the file and remember where you saved it now we switch to docs.google.com and create a new sheet this is going to be our database we give that spreadsheet a name and it's important to remember the name because we need it later now we need the file you just downloaded just open it in the text editor of your choice and look for a line starting with client email copy the value behind and go back to your spreadsheet hit the share button on the top and paste that email address you just copied make sure the user has editor permissions and click Share again and if this was a bit too quick you can always go back or pause the video back in our text editor we copy all the contents of the downloaded file and we create a new file on the raspberry pi called Google Earth dot Jason we paste all the contents and save the file next we add a to Google spreadsheet py again we scroll a bit down and we'll find this here we can configure which type of sensor we are using remember we are using the dht22 but if you are using the dht11 you could change that here below you will find the configuration for the GPIO pin of the sensor we used pin for a little further down we now add our Google Earth dog Jason we just created below that we have to add the name of the Google spreadsheet remember that was our P I - tab and then you can configure the frequency how often this should update we'll leave that at 30 now for the next step we have to find this line append the data in the spreadsheet including a timestamp we are going to change there just a bit we comment this out so it won't have any effect and we type this with this we do not advance data but prepends of data on the sheet that's important for us and mourn that later besides that we change the format of the date just a tiny little bit that will help us with our chart later you can pause the video if this is too quick when you are done save the file we are ready to roll therefore we type dot slash Google Karachi dot py to run the script and if we didn't do any mistakes it should look like this and by opening our browser there should be some data in our spreadsheet the first column is the date the second time then we have the temperature in celcius you can change that to Fahrenheit if you like and the humidity in the spreadsheet we are able to set some formats here that's quite important because they will also apply in the chart we create in a moment so far so good you are still with me how great you did a great job we are almost there for the last part of this tutorial and to see your chart in your browser we are going to install a web serve on the raspberry pi we are using apache 2 for this [Music] after the installation script is through we have to start the server and to verify its running we type the hostname of the Raspberry Pi in my case it's PI it might be an IP address of the local host that's depending on your configuration the Apache web server stores its documents under whare www HTML there is an index.html which we are going to move next is Santa Claus a little git repository are created it contains the HTML and JavaScript stuff we need now you'll find that link to in the description of this video now you can edit the index.html if you like to but you don't have to we concentrate on the app.js in here you will find a bunch of stuff which you can ignore right now but you have to change this very link you have to add your spreadsheet buddy you will find this ID in the URL of your spreadsheet right here [Music] copy/paste it just like this one thing to make sure is that this cheat variable has set to the exact same name as your document and finally after you safety up GS make sure that the spreadsheet has read access for everyone that's important to access the data from our chart view X's is enough if you are done click done and there is ok it's a little bit empty right now but I can tell you this will grow fast the blue line shows the temperature and the red line shows the humidity you can modify what you see from the fjs for example you can remove column D which is the humidity remove this go back to the end and remove the label save the file and reload the browser or change some other values and you will see the humidity is gone now you only have the temperature and the label has changed one little thing that might be handy is an auto refresh just edit the index.html with this and it will reload every 60 seconds well he made it until your respect if you like what you see please hit the subscribe button or give me a thumbs up thank you very much and see you next time [Music]
Info
Channel: datort
Views: 7,873
Rating: undefined out of 5
Keywords: Arduino, Computer, DHT11, DHT22, Google, Google Visualisation API, Howto, Line Chart, Pi, Raspberry Pi, Sensor, Spreadsheet, Temperature, Tutorial, arduino project, arduino projects, arduino projects for beginners, arduino tutorial, best arduino projects, easy arduino projects, humidity, humidity sensor, temperature sensor, top arduino projects
Id: nDzbGB6hdeA
Channel Id: undefined
Length: 12min 6sec (726 seconds)
Published: Sat May 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.