Web-Accessible Temperature Logger for Raspberry Pi

HomeBrewTalk.com - Beer, Wine, Mead, & Cider Brewing Discussion Community.

Help Support Homebrew Talk:

OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
[...]Couple of quick questions,
1. What version of python are you using?
2. Are you using mod_cgi or mod_wsgi or mod_python?
3. Did you follow the server setup in raspberrywebserver.com?
Thanks again for being available to ask questions.
1. 2.7.3
2. As best as I can tell I've never enabled/installed any of those.
3. Nope. I just installed sqlite3, Apache was already resident and serving pages because of the prior RaspberryPints installation.

Note that I have only ever run this on Wheezy and using Python 2.7.3.
I have no idea if it'll work without some massaging when run on Jessie or using Python 3.x...

Cheers!
 

caretaker

New Member
Joined
Mar 17, 2016
Messages
3
Reaction score
0
Location
Rochester Hills
1. 2.7.3
2. As best as I can tell I've never enabled/installed any of those.
3. Nope. I just installed sqlite3, Apache was already resident and serving pages because of the prior RaspberryPints installation.

Note that I have only ever run this on Wheezy and using Python 2.7.3.
I have no idea if it'll work without some massaging when run on Jessie or using Python 3.x...

Cheers!
First I want to thank you for not only your time spent on putting this together but also trying to help persons like me get it running. Now for the good news I got it running! Turns out there was a space on the first line before the shebang! I must have looked over the script a dozen time and finally saw it. Thanks again and as I play with this some more if I come up with any upgrades I will make sure to post them here.
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Ah, "spaced shebang syndrome". I've had that once or twice ;)
Glad to read you got things sorted!

Cheers! :mug:
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
fwiw, I have my logger running on Raspbian Jessie with the latest/greatest Apache2.
I followed my "instructable" to make sure it still worked, and found I needed to run the following command to get Apache2 to actually execute Python instead of displaying it as text:

Code:
$ sudo a2enmod cgi
Once I ran that everything worked same as "The Good Ol' Days" with Wheezy.

So, add that to the end of the instructions and you'll be good to go...

Cheers! :mug:
 

Aussies

Member
Joined
Jan 13, 2016
Messages
8
Reaction score
0
Hi Guys,

I'm trying to pimp up the webpage a little bit.
I want to add some gauges on the mainpage which so represent the actual temperatures measurd.

I've tried adding some from google. But with no success. :(

Has some one already tried to do this? Or maybe some one can help me check up my added code?
 

jbrewick

Member
Joined
Oct 6, 2015
Messages
6
Reaction score
0
Hi,

Can someone help me I'm almost done. I'm trying to put a clock on the page. I put the code <?php echo date ("h:I"); ?> At the top of the temp_insert. Php file but when I do it puts the time above the thermometer in the right corner and pushes the temp icon into the poured/remaining text. I have no idea what I'm doing and if where it should go any help would be great. Thank you.

image.jpg
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
I think you're going to need to use relative positioning for that, but honest to gawd html is My Weakest Link, so I'm not going to be hella useful.

But if you get it figured out please post the code here :)

Cheers!
 

jbrewick

Member
Joined
Oct 6, 2015
Messages
6
Reaction score
0
Thank you day tripper. I'm not good at html . I'm lucky I got the flow meters working and the temps logging. Only because you gave very good instructions. Thanks for all your hard work.
 

jbrewick

Member
Joined
Oct 6, 2015
Messages
6
Reaction score
0
Hey day_tripper
Can you help me with the purge_dbase.py I don't think it's working I'm sure I did something wrong. I did this sudo crontab -e -u www-data and put this code at the bottom 00 00 * * 0 /home/pi/purge_dbase.py can you help me out? Does it matter if it doesn't get purged. Is there a manual way to purge it or delete it?

Thank you.
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Just checked and it appears I ended up using the root account for the cron task.
And that was so long ago I can't remember why, but for sure it would have had something to do with permissions that I likely could have fixed another way ;)

Anyway...

If you never purge the database back it'll continue to grow and eventually you'll notice the added latency in plotting the graph.

Code:
$ sudo crontab -e

0 0 * * * /home/pi/purge_dbase.py > /dev/null 2>&1
Save it and you should be good. Don't forget to get rid of whatever other purge task you have set up in cron.

You can run the same python script from a terminal:

Code:
$ sudo python purge_dbase.py
Cheers!
 

ratsathome

Well-Known Member
Joined
May 20, 2012
Messages
109
Reaction score
11
Location
Meath
After being absent for awhile I installed everything new and having a problem with the logger. It show on the web page but does not automaticaly plot the time. I have to run the "python script" manualy for it to work.
I did the cron job in both "www-data" and "root" and it is set for 5 min.
Any help would be gr8.

And the graph is gone to
 

ratsathome

Well-Known Member
Joined
May 20, 2012
Messages
109
Reaction score
11
Location
Meath
Ok got it working:D
Another question: if you are on the "webgui" web page the temp log is shown for "the last 24 hours" as default. What do I change to have it say "last 6 or 1 hour" as default in the webgui.py folder.
tx
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
In webgui(x).py, look for two instances of these two lines:

if option is None:
option = str(24)

You can change the value of str to 1, 6, 24, 48, 168, or 240, to have the graph and table display the corresponding number of hours of data by default...

Cheers!
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
What browser are you using? And have you tried others?

When you click on the thermometer the log graph and tables are displayed correctly?
The only thing missing is the "scrolling" display?

The fact that the thermometer appears at all says you have an entry in the RaspberryPints index.php pointing to the temp_insert.php correctly, so I expect if there's a problem it's with your edit of the latter...

Cheers!
 

hawkdrvr

Member
Joined
Mar 6, 2016
Messages
13
Reaction score
3
No I've only tried Chromium.

Nothing happens when I click on the thermometer as well. I put the code in for the graphic as per the instructions.

I'm thinking I've missed something in the coding to put the scrolling temps in.

When I go to the localhost/cgi-bin/webgui2.py I get the page with the temp logs but no graph. I think that might be an issue with the browser. I can't get to most websites on my Pi with Chromium due to bad certificates. Not sure what is going on with that as well.

Thanks.
 

hawkdrvr

Member
Joined
Mar 6, 2016
Messages
13
Reaction score
3
Got it. Post 118 for the header right I was missing the code to get to the temp sensors. Every time I tried it last night it would cut the taps out of the screen. I think I had it going to the wrong file.

Works now and I have my flow meters working as well. Just have to install it in my beer frig as I've been bench testing everything before install

Thanks for all the info between the threads I've been able to get this all working!

View attachment ImageUploadedByHome Brew1497837103.887476.jpg
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Well, that was easy :D
Happy you got it working!

Cheers!
 

TheSkaz

Active Member
Joined
Jul 8, 2017
Messages
33
Reaction score
2
Hello guys!

So in another thread I mentioned a great idea of adding temp displays to the raspberrypints screen. Awesome "original" thought....

you guys beat me to it by a LONG shot. I have a different approach though. decouple the uno and the pi. I abandoned the Uno for the ESP series MCUs. mainly for their form factor and built in Wifi/BT. I want to implement what we have here, but dont want to have a USB between the pi and the ESP.

that could lend itself to scalability as you can have multiple ESPs (keezers, ferm chambers, fridges, brewday, whatever) and 1 pi. Ive mentioned before that I dont know python or php, but I do know html sql, and c/c++/c#. also a network engineer by trade. I will eventually ask some questions regarding how all this actually work, but I have more reading to do first. my goal is to convert it to take readings from wifi instead of serial.
 

TheSkaz

Active Member
Joined
Jul 8, 2017
Messages
33
Reaction score
2
I just found others that have done similar in other threads... I should stop posting until i read through it all lol...
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Somewhere I posted an RPints python file showing how to use an AlaMode on the RPi serial port per the original scheme, or an Uno connected via USB, Bluetooth (using an HC-05) or Wi-Fi (using an esp8266)...

Cheers!
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
That's the one.
I would have provided the link had I been home...

Cheers!
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Whoops!
Someone forget to re-enable the keezer compressor control after swapping kegs and pulling the Eva-Drys for a drying cycle last night.
I can testify that a +14°F warm-up definitely affects pours :drunk:

keezer_plot_17oct2017.jpg

Stupid brewer trick, and almost enough to get me to add some alarms to this project...

Cheers!
 

GregB79

New Member
Joined
Feb 20, 2018
Messages
3
Reaction score
0
HI Thank you for the project,

Is there any way to change the date format that displays on webgui2.py to DD-MM-YYYY??
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
For each recorded temperature reading monitor_(n)sensor.py writes a database row with datetime('now','localtime'), then webgui(n).py extracts the first value of each record as 'Time' with no evident formatting.
You'd have to insert a conversion in webgui(n).py to convert datetime into the format you desire, and then hope the Google graphing API doesn't puke on it...

Cheers!
 

GregB79

New Member
Joined
Feb 20, 2018
Messages
3
Reaction score
0
For each recorded temperature reading monitor_(n)sensor.py writes a database row with datetime('now','localtime'), then webgui(n).py extracts the first value of each record as 'Time' with no evident formatting.
You'd have to insert a conversion in webgui(n).py to convert datetime into the format you desire, and then hope the Google graphing API doesn't puke on it...

Cheers!
HI sorry to bother you how would I do that ??
 

GregB79

New Member
Joined
Feb 20, 2018
Messages
3
Reaction score
0
Hi Day_trippr
just wondering if you would have an example on how to change

curs.execute("SELECT * FROM temps WHERE timestamp>datetime('now','localtime','-%s hours')" % interval)

to display date and time in day-month-year hour:min

thankyou in advance

Greg
 

ichbinbier

Active Member
Joined
Sep 21, 2014
Messages
32
Reaction score
7
Location
Toronto
Hi Day_trippr
just wondering if you would have an example on how to change

curs.execute("SELECT * FROM temps WHERE timestamp>datetime('now','localtime','-%s hours')" % interval)

to display date and time in day-month-year hour:min

thankyou in advance

Greg
That line only grabs the time from the database.

The line that prints the time is:

Code:
 rowstr="<tr><td>{0}&emsp;&emsp;</td><td>{1}F&emsp;&emsp;</td><td>{2}F</td></tr>".format(str(row[0]),str(row[1]),str(row[2]))
        print rowstr
and the line that puts the time into the database is from monitor_2sensors.py here:

Code:
curs.execute("INSERT INTO temps values(datetime('now','localtime'), (?), (?))", (temp0,temp1))
That would be the first two places to start.
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
I cobbled this package together from open source chunks found in various locations on the web, and while most of the pieces I understood well enough to modify, the big exception is the Google graphing API. I have literally zero knowledge about what it will accept for input, so while clearly it graphs correctly using the string generated from the Raspbian datetime value, I don't know that it will work at all if one were to use a different time format.

As the package does what it claims and I'm busy up to my eyeballs these days, I have no time and pretty near zero motivation to get into it deep enough to understand what changes are possible, never mind execute same. I'll leave that option to anyone who wants to take it on for their own requirements...
 

mvrinaldi

New Member
Joined
Dec 22, 2016
Messages
3
Reaction score
0
Hi,

I try to do this:

$ python test_sensors.py


But didn't work. Return this:

bash: python test_sensors.py: comando não encontrado


If I running directly to the home/pi, return this:

File "/home/pi/python/test_sensors.py", line 36
print 'Read Sensor',
^
SyntaxError: Missing parentheses in call to 'print'



What's wrong, please.

I'm sorry I'm noob in linux.
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
Try running as root. Here's an example run:

Code:
[email protected] ~ $ sudo python test_sensors.py
Looking for W1_Slave Temperature Sensor Devices...

Number of W1_Slave Devices found: 5

Sensor 0 ID: /sys/bus/w1/devices/28-00000689f325
Sensor 1 ID: /sys/bus/w1/devices/28-0000068a2030
Sensor 2 ID: /sys/bus/w1/devices/28-0000068a3443
Sensor 3 ID: /sys/bus/w1/devices/28-0000068a0cee
Sensor 4 ID: /sys/bus/w1/devices/28-0000068a8e2b

Read Sensor 0
Raw Data =  22062
22.062 Degrees C
71.7116 Degrees F
71.7 Rounded
Sensor 0 Temperature = 71.7 F

Read Sensor 1
Raw Data =  21562
21.562 Degrees C
70.8116 Degrees F
70.8 Rounded
Sensor 1 Temperature = 70.8 F

Read Sensor 2
Raw Data =  21750
21.75 Degrees C
71.15 Degrees F
71.2 Rounded
Sensor 2 Temperature = 71.2 F

Read Sensor 3
Raw Data =  22187
22.187 Degrees C
71.9366 Degrees F
71.9 Rounded
Sensor 3 Temperature = 71.9 F

Read Sensor 4
Raw Data =  22250
22.25 Degrees C
72.05 Degrees F
72.0 Rounded
Sensor 4 Temperature = 72.0 F

0
Compressor Off
45
[email protected] ~ $
Cheers!
 
OP
day_trippr

day_trippr

Covid-19 Vaccine Effectivity Test Subject
Joined
May 31, 2011
Messages
35,859
Reaction score
18,285
Location
Stow, MA
fwiw, I needed to correlate a bunch of probes so I ginned up versions of the logger and web gui files for 6, 7, 8 and 9 sensors, and generated a new zip file with them. The archive is on my Google Drive, location provided in the first post...

Cheers!

[7 of 9 read within .1°F, the other two have a -.1°F offset but otherwise track with the rest]

9_sensor_plot.jpg
 
Top