Page 1 of 1

Best way to log Temp Sensor data periodically?

Posted: Sat Jan 16, 2016 9:10 pm
by rfeyer
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

Re: Best way to log Temp Sensor data periodically?

Posted: Sat Jan 16, 2016 9:21 pm
by rpdom
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.

Re: Best way to log Temp Sensor data periodically?

Posted: Sat Jan 16, 2016 9:43 pm
by rfeyer
TY rpdom,
I will download MySQL and will see what I can learn - getting too old for this :)

Rainer

Re: Best way to log Temp Sensor data periodically?

Posted: Sat Jan 16, 2016 10:13 pm
by rpdom
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 :)

Re: Best way to log Temp Sensor data periodically?

Posted: Sun Jan 17, 2016 7:55 pm
by scotty101
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.

Re: Best way to log Temp Sensor data periodically?

Posted: Sun Jan 17, 2016 9:17 pm
by PI_Stuart
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.

Re: Best way to log Temp Sensor data periodically?

Posted: Sun Jan 17, 2016 10:04 pm
by asandford
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.

Re: Best way to log Temp Sensor data periodically?

Posted: Mon Jan 18, 2016 10:03 pm
by rfeyer
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.

Re: Best way to log Temp Sensor data periodically?

Posted: Tue Jan 19, 2016 12:53 pm
by martinhj
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

Re: Best way to log Temp Sensor data periodically?

Posted: Tue Jan 19, 2016 1:00 pm
by rfeyer
Martin,
Great suggestion!

TY
Rainer

Re: Best way to log Temp Sensor data periodically?

Posted: Tue Dec 12, 2017 3:09 pm
by Captron
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.