rfeyer
Posts: 102
Joined: Sun Nov 23, 2014 9:25 pm

Best way to log Temp Sensor data periodically?

Sat Jan 16, 2016 9:10 pm

With the help of many, and lots of reading, I have been able to write a little python program which includes extracting temperature data from ds18b20 sensors and write them to an html.

As a further task, I would like the temp data to be logged, preferably either to a spreadsheet or database which can be easily read by a spreadsheet (OpenOffice).

So I have been reading about MySQL, writing data to MySQL inside Python.

My questions are:
Is Python the way to go (having to, say every hour, write tempsensor data to MySQL), or, is it possible and more proficient to use a bash script and have it access the Python function once per hour which extracts the TempSensor data?

I would hate to start a whole new chapter right now on MySQL if it was possible to do it easier with Bash.

Rainer

User avatar
rpdom
Posts: 12581
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Best way to log Temp Sensor data periodically?

Sat Jan 16, 2016 9:21 pm

Do the MySQL from your Python code. Python has modules for accessing MySQL databases. Bash doesn't, you'd have to use the MySQL CLI with bash, which is yet another level of code.

rfeyer
Posts: 102
Joined: Sun Nov 23, 2014 9:25 pm

Re: Best way to log Temp Sensor data periodically?

Sat Jan 16, 2016 9:43 pm

TY rpdom,
I will download MySQL and will see what I can learn - getting too old for this :)

Rainer

User avatar
rpdom
Posts: 12581
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Best way to log Temp Sensor data periodically?

Sat Jan 16, 2016 10:13 pm

rfeyer wrote:TY rpdom,
I will download MySQL and will see what I can learn - getting too old for this :)
Age matters not ;)

I can manage it, even in my advanced years :)

scotty101
Posts: 2909
Joined: Fri Jun 08, 2012 6:03 pm

Re: Best way to log Temp Sensor data periodically?

Sun Jan 17, 2016 7:55 pm

SQLite is my database of choice. For most of the things you are likely to need it is much simpler.

You don't need to mess about with user permissions and the data is just stored in a binary file.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

PI_Stuart
Posts: 4
Joined: Mon Jan 04, 2016 6:42 pm

Re: Best way to log Temp Sensor data periodically?

Sun Jan 17, 2016 9:17 pm

I have been tinkering with the project linked below
http://raspberrywebserver.com/cgiscript ... nitor.html
Great project. I have modified it to read in a second transmitter and cope when the temperature goes sub zero.
It has a CGI script which produces a trend of the temperature which is very nice. I am currently trying to figure out how to "scroll" the trend back which is rather defeating me.

asandford
Posts: 1999
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Best way to log Temp Sensor data periodically?

Sun Jan 17, 2016 10:04 pm

I used to monitor and control a greenhouse environment with loads of python scripts. I now do all this sort of stuff with Node-Red.

rfeyer
Posts: 102
Joined: Sun Nov 23, 2014 9:25 pm

Re: Best way to log Temp Sensor data periodically?

Mon Jan 18, 2016 10:03 pm

rpdom,
words of encouragement - TY!! I am in advanced age as well - so it should work (experience is on our side :) )

as for my original question: I have been able to get the data from multiple sensors, using a recursive function, and put data into a MySQL database/ table. Then I started doing some research on how to access this information with something GUI such as LibreOffice spreadsheet. Did not go so well.
But, during the research found an example of batch commands cat in conjunction with grep, and, wow, have not been able to use past experience to echo the info into a .cvs file.

So, am doing a little more with bash as well as, when time permits, some research on MySQL and SQLlite.

Hope this thread will continue with ideas as it is an interesting bash vs SQL topic at this point.

martinhj
Posts: 23
Joined: Mon Jan 09, 2012 1:05 pm

Re: Best way to log Temp Sensor data periodically?

Tue Jan 19, 2016 12:53 pm

Try reading this....

https://leanpub.com/RPiMRE

Im in no way connected to the author but stumbled across it...is well written for beginners

Martin

rfeyer
Posts: 102
Joined: Sun Nov 23, 2014 9:25 pm

Re: Best way to log Temp Sensor data periodically?

Tue Jan 19, 2016 1:00 pm

Martin,
Great suggestion!

TY
Rainer

Captron
Posts: 1
Joined: Tue Dec 12, 2017 2:52 pm

Re: Best way to log Temp Sensor data periodically?

Tue Dec 12, 2017 3:09 pm

You have been chatting about the software solution for the Pi and Temps, I would like to hear about the hardware solutions being used.

I need up to 20 inputs and up to 16 outputs, and have found a source of commercial quality boards for the Pi :P . Altogether they are very good but quite expensive. :cry:

I like the Node Red idea and am looking into it now, so far am impressed. I also am looking at MySql-Lite for the Db.

Return to “Python”

Who is online

Users browsing this forum: No registered users and 17 guests