Web-Accessible Temperature Logger for Raspberry Pi

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
So I have a sixth channel logging the compressor state successfully.
Makes it easy to determine my keezer compressor is currently running at a ~24% duty cycle. I can live with that :)

Having this working opens up all kinds of "alert" possibilities. Eg: excessive on-time, on-time with no temperature response, temperature above setpoint + differential but compressor not running.

I was surprised to see was how small an effect that period immediately following compressor shut off where the evaporator is still sucking heat has on the keezer temperature. Granted the 5 minute polling resolution means there could be nearly 5 minutes of "jitter" between events, but still it looks like there's very little overshoot. This may be due to all six kegs being roughly 2/3rds full right now - there's around 180 pounds of beer in there and they're not going to move in a hurry :D

Cheers!

brewpints_49.jpg
 
I also have been curious about my compressor cycle time. My chest freezer is pretty old and not really energy efficient. The only way I could "kinda" monitor this was by using this temp logger to get a rough estimate. What did you have to do to make this work, Day_trippr?


Sent from my iPhone using Home Brew
 
A little code here and there to provide the added database column and chart plot for the compressor state, then connecting the Chamber Cooler relay control signal from BrewPi's Arduino digital GPIO 5 through a resistor divider to a free RPi GPIO - the Arduino speaks 5V when the RPi only wants to hear 3.3V. [My setup is actually a little more complicated but the above captures the gist of it].

The modified monitor_sensors.py script reads the state of that input, translates the on/off state into temperature values, then stuffs the result in the database with the probe readings. The modified webgui.py script then pulls out and plots the added value.

If you're interested and you tell me how many channels you're tracking I could cobble up the files when I get the time.

Cheers!
 
A little code here and there to provide the added database column and chart plot for the compressor state, then connecting the Chamber Cooler relay control signal from BrewPi's Arduino digital GPIO 5 through a resistor divider to a free RPi GPIO - the Arduino speaks 5V when the RPi only wants to hear 3.3V. [My setup is actually a little more complicated but the above captures the gist of it].

The modified monitor_sensors.py script reads the state of that input, translates the on/off state into temperature values, then stuffs the result in the database with the probe readings. The modified webgui.py script then pulls out and plots the added value.

If you're interested and you tell me how many channels you're tracking I could cobble up the files when I get the time.

Cheers!

I'm currently tracking 3 channels, but I'm also using a Johnson A419 to control temperature in my Keezer. I suppose it wouldn't be too difficult to dig into it and find the relay, but finding the time to do such a thing is another story. However, you've caught my interest. For what it's worth, I have the Johnson's probe taped to the side of my beergas cylinder since it's changed out so infrequently in my setup, versus taping it to a keg. Meaning I don't have to move the probe each time I change the keg. This solution not only eliminated the problem but using my ol' calibrated eardrum, I have found that my compressor cycled WAY less frequently. I've always been curious to when it starts/stops without having to actually listen for it, and this just might be my solution.
 
The tricky part would be monitoring the state of the A419 output and conveying that status to the RPi - without blowing up the latter ;)

There's actually an IC that'd do that. It takes in 120vac and drives a full-wave rectifier through an RC circuit to one side of an opto-coupler, and the other side becomes essentially a DC switch. So the "AC side" could be hooked up between the A419 (or STC-1K, MH1210, WH7016, etc) relay output and AC neutral, then hook the "DC side" to the RPi 3.3V and DC ground and bring back the A419 relay status.

It could be stuck inside an outlet box I suppose. Something to consider....


The last few days I noticed my keezer was starting to cycle more frequently, more than the recent warm spell should cause. It had gone from once every 6 hours down to 2. Finally got 'round to investigating and - duh - the beer level in the monitored keg had dropped to almost below the probe location. Slid the probe down a foot and things are settling back down...

Cheers!

keezer_plot_november.jpg
 
fwiw, I found a web management tool for sqlite3 written in php that comes in handy if you get a spike that's mucking with the chart dynamic range.

It's called phpliteadmin and in minimum form is a single php file (optionally you can use a config file with it).
Park it on the RPi, set the password, and you can hit on it from any browser and massage probe records if desired...

Cheers!
 
I just noticed I had a cut and paste error in the code box within this reply that would likely render the crontab entry invalid.

This

Code:
*/1440 * * * * /home/pi/purge_dbase.py

should actually look something like this

Code:
00 00 * * * /home/pi/purge_dbase.py

to run the purge nightly at midnight, or like this

Code:
00 00 * * 0 /home/pi/purge_dbase.py

to run the purge at midnite every Sunday.

I actually have no idea what the original entry would do - if anything ;)

Cheers!
 
This is not working as intended. I'm leaving the code up as someone else might find the problem.

This is fine for a quick fix and I myself used this originally to refresh. The problem with this is it refreshes the whole page so everything has to be reloaded and thus puts a lot of extra work on to the Pi. I have webalizer running for the Pi so I can see who visits my Pints page so I notice it slows down on a full page refresh. If you are watching the screen at the refresh time you may see that it takes awhile to fully load.

A less intrusive and less intensive way to do this is to just refresh the the section we want, not the whole page.

So where you have
Code:
<meta http-equiv="refresh" content="300">

we delete that entire line and replace with
Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function autoRefresh_div()
{
$("#temprefresh").load();
}

setInterval('autoRefresh_div()',60000); //every 1,000 = 1 second
</script>
This is under the assumption that you are continuously connected to the internet. If not then you would have to download the jquery.min.js package into your /var/www folder and then call it as localhost/jquery.min.js (I think, I haven't tried calling it locally)
and we then replace our insert code
Code:
<?php include'temp_insert.php'; ?>
with this
Code:
<div id="temprefresh"><?php include'temp_insert.php'; ?></div>

I have mine set at 1 minute (60000) as I have a clock added to the temp_insert.php.

You can set the timer shorter but don't set it any shorter than the time it takes for all your sensors to scroll through.

As always to see it working go here. If you visit you may have to wait up to 1 minute to see the temperature as it is set to 1 minute refresh.

[rant]Why did this get moved to fermenters? This should reside and be attached to anything RaspberryPi[/rant]

I've tried to get this to work but with no avail. It will load the page without the temp_insert.php stuff in it and then upon reloading that file it goes to a blank page. Has anyone got this to work?

I have reverted to refreshing the entire page for now but I don't like how the screen will go all white for a few seconds while it reloads.
 
Sounds like the same issue I found, and I'm still using the refresh tag.

But in all this time I don't think I've ever seen the white-screen thing on the RPi monitor atop my keezer. Might just be luck, but the times I've caught it refreshing I don't recall an all-white interval...

Cheers!
 
Can anyone show me a close up of how they have the probes attached to the RPi? Ordered the probes, now just want to figure how to attach multiple probes without soldering if I can get away with it.

Thanks Dave
 
Pretty sure soldering would be required. I built a small project box that has 3 headphone jacks in it, which then goes to a RJ45 breakout prototyping board. I soldered a headphone plug onto each probe I wanted in the kegerator. Internally, the wires are ganged together to the screw terminals of the RJ45 board. I run Cat 5 from my kegerator to another matching board up on the Pi, where I break from there and go to the various pins I need. Either way, you need to solder something together to get the pins set on the Pi / Alamode. I don't think there's another way around it. The upshot of the probes is that they can share the same power, ground, and signal lines, so you can run them all to the same 3 points.
-Kevin
 
For my connections to the Rpi I used crimp pins that go into a 2x10 receptacle that plugs directly onto the Rpi's header. I am not running flow meters so I don't have an alamode to deal with. The only problem with crimp pins is that if you don't have the expensive crimp tool for those tiny little pins it is a pain to get a good crimp with needle nose pliers. I still hit the crimp connection with a dab of solder to make sure the wire doesn't slide out. The advantage of going this route is you aren't soldering on the RPi it self so you don't have to worry about damaging it in any way and I can easily pull th e receptacle off and bend a plastic tab back to pull the pin out, so reconfiguring it or a ding more connections later is very easy.
 
If one was bound and determined to go totally solder-less, a combination of Dupont jumpers and tiny wire nuts would work.

The jumpers would need to be cut and stripped at the junction ends. And the pull-up resistor leads would need to be trimmed so there'd be minimal exposed wire between the body and the nutted-junction on each side, or you could add in some tape or tubing, but it could be accomplished.

One would need to be careful not to literally shear the very few copper strands in any of the jumpers when twisting everything up - those Dupont jumpers are wicked thin gauge. And I'd do something to keep strain off the junctions for the same reason. Wire ties, for instance, placed ahead of the nuts...

Cheers!
 
A little code here and there to provide the added database column and chart plot for the compressor state, then connecting the Chamber Cooler relay control signal from BrewPi's Arduino digital GPIO 5 through a resistor divider to a free RPi GPIO - the Arduino speaks 5V when the RPi only wants to hear 3.3V. [My setup is actually a little more complicated but the above captures the gist of it].

The modified monitor_sensors.py script reads the state of that input, translates the on/off state into temperature values, then stuffs the result in the database with the probe readings. The modified webgui.py script then pulls out and plots the added value.

If you're interested and you tell me how many channels you're tracking I could cobble up the files when I get the time.

Cheers!

I think I might take you up on this offer. I've been thinking about it and I'm going to redo the smart-parts of my keezer and in the process I'm going to do away with my A419 controller, and replace it with a Brewpi setup on my 'pi. It's gonna happen little by little as time allows but if you saw my current setup you might have a mild heart attack. I have wires running everywhere, whether it's flowmeters, PIR wires, power cords, LED lighting, temp sensors...it all works but it's time for me to clean it up and throw it all in a project box of some sort. (LOVE that "BrewPints" box you have built, by the way. That thing is slick as hell and I've been taking as many notes as I can)

For now, I'm currently logging 3 channels. With my plans to update my keezer, I don't think I'll be adding any more sensors. My situation doesn't require more than 3. (Keg temp, Tower temp, Room temp)
 
Ok getting ready to do this. I have ordered there Vtech Probe

How are people attaching these to their breadboards? Not done much of this so learning as I go.

Dave
 
Last edited by a moderator:
fwiw, at the start I actually removed the female crimped sockets from Dupont jumpers and soldered those onto the sensor leads. Then I could plug them onto male headers. It's rather hard core but I do that kinda stuff all the time.

Now all my probes use three pin mini-XLR connectors as everything's in enclosures so I needed inexpensive panel mounted connectors...

Cheers!
 
FYI: Updating/upgrading Raspbian to the latest/greatest OS revision will likely break One-Wire support. It did here.

They've introduced "Device Trees" to better manage devices and their drivers.
And as part of implementing this, many external interfaces are disabled by default.
Like SPI, I2C, One-Wire, Audio...it's a long list of breakage.

So you will either need to edit your /boot/config.txt file or use raspi-config to either disable Device Tree (which will magically make everything that didn't work suddenly start working) or leave Device Tree enabled and then enable each interface needed.

I went the expedient route for now and used $ sudo raspi-config then selected Advanced and turned off Device Tree.
After a quick reboot et voila! One-Wire and my temperature logging were back on the air...

Cheers!

[edit] Gah! Unfortunately, while disabling Device Tree automagically allowed the One-Wire bus to work again, it killed my PIR sensor.
Well, not the sensor, but my PIR code uses GPIO8 to turn on a panel LED when motion is detected (along with everything else that happens) and with Device Tree disabled GPIO8 was not doing what I wanted it to do.

Soooo...bit the bullet, enabled Device Tree again (which let the LED thing work), then added this line to /boot/config.txt to enable One-Wire support:

dtoverlay=w1-gpio,gpiopin=4

Saved, rebooted, and now both One-Wire and my motion LED are working together.
 
FYI: Updating/upgrading Raspbian to the latest/greatest OS revision will likely break One-Wire support. It did here.

They've introduced "Device Trees" to better manage devices and their drivers.
And as part of implementing this, many external interfaces are disabled by default.
Like SPI, I2C, One-Wire, Audio...it's a long list of breakage.

So you will either need to edit your /boot/config.txt file or use raspi-config to either disable Device Tree (which will magically make everything that didn't work suddenly start working) or leave Device Tree enabled and then enable each interface needed.

I went the expedient route for now and used $ sudo raspi-config then selected Advanced and turned off Device Tree.
After a quick reboot et voila! One-Wire and my temperature logging were back on the air...

Cheers!

[edit] Gah! Unfortunately, while disabling Device Tree automagically allowed the One-Wire bus to work again, it killed my PIR sensor.
Well, not the sensor, but my PIR code uses GPIO8 to turn on a panel LED when motion is detected (along with everything else that happens) and with Device Tree disabled GPIO8 was not doing what I wanted it to do.

Soooo...bit the bullet, enabled Device Tree again (which let the LED thing work), then added this line to /boot/config.txt to enable One-Wire support:

dtoverlay=w1-gpio,gpiopin=4

Saved, rebooted, and now both One-Wire and my motion LED are working together.

Thanks for posting this. I just had the very same issue happen to me. Followed your instructions and everything is good to go now. Found that I may need to replace a sensor though. I have one that is constantly reading 185 at all times. It's not a spike, it's a constant reading at 185 and never changes. Is it time for a new sensor? Or is there a way to debug this little issue of mine? For what it's worth, I was never hard on the sensor. Never pulled on it or dropped it or anything...
 
It's probably gone to Probe Heaven. Out of the ~30 probes I have hooked to various things here I managed to electrically whack one. It was last summer so memory isn't perfect but I think I wired its mini-xlr plug with power and ground swapped.

It was stuck at 185, too. I just checked my code and there's nothing on either side of the database that would default to 85°C/185°F, so either the W1 service is returning that value or it's actually coming from the probe's front end.

In any case I tossed the probe. At a couple bucks apiece if I spent any time on it at all it'd turn into a significant loss.

Cheers!
 
I figured as much, but wanted to ask the experts before I toss it. Fortunately for me it was the room temp sensor so not much harm done.
 
I had a problem with running multiple and had to play with the resistor value. I think everyone usually uses a 4.7k, I ended up with a 2.2k. Worth a shot.
 
I had a problem with running multiple and had to play with the resistor value. I think everyone usually uses a 4.7k, I ended up with a 2.2k. Worth a shot.


Interesting thought, but I do believe this one is dead. Just for testing purposes, I plugged it into my Brewpi setup, and it wouldn't even recognize that it was there. I just went ahead and ordered two more.
 
You'll get that message from webguin.php if there are no database entries with a time-stamp within the default (24 hour) window.
First suspicion is that the monitor script is either never executing or it can't open the database for writes.

You can try manually running the sensor polling script to stick an entry in the database:

sudo python /usr/lib/cgi-bin/monitor_1sensor.py (or monitor_2sensors.py)

If you don't get a permissions issue with writing the database, try the web page again. If you get the graph this time, check that you actually added the crontab entry for www-data to run the script:

sudo crontab -u www-data -e

There should be an entry that looks like this:

*/5 * * * * /usr/lib/cgi-bin/monitor_1sensor.py (for one sensor), OR
*/5 * * * * /usr/lib/cgi-bin/monitor_2sensors.py (for two sensors)

If you still get the no data message go back through the procedure and especially check files are in the right places and permissions have been set. If manually running the polling script causes file open errors with the database, fix that first :)

Cheers!


I had this same problem as well. I went back through and got it working. However, I am only able to see data on the webpage when I manually call the monitor_1sensor.py. I checked my crontab and it is correct as well.

Any ideas as to why I can't get it to automatically poll the data?

Btw, awesome write up, super simple and quick. Just what I was looking for!
 
Check the ownership of the database file, it should be www-data. The manual poll command given uses root privs (sudo) hence it will plow right through regardless of who owns the file...

Cheers!
 
Okay. Just checked the file and here is what it said:

/var/www $ stat temp_data.db
File: `temp_data.db'
Size: 2048 Blocks: 8 IO Block: 4096 regular file
Device: b302h/45826d Inode: 63968 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 33/www-data) Gid: ( 33/www-data)
Access: 2015-03-29 18:26:23.168773005 -0400
Modify: 2015-03-29 18:50:01.333173595 -0400
Change: 2015-03-29 18:50:01.333173595 -0400
Birth: -

I'm guessing since I see it in the Uid and Gid that it has ownership? I appreciate the quick response.

I'm sure I'm missing something simple, but I just don't see it. Been a while since I've played around with a raspberry Pi or arduino.
 
I'm a bit removed from my systems as I'm down on a Bahamas Out Island for the next two weeks. But in the meantime here's something to try: instead of using www-data's crontab, use root's crontab.

$ sudo crontab -e -u root

Enter the same string as used in www-data crontab. Also, comment out the crontab entry in www-data's crontab (stick a pound sign in front of the string) so the result will be clear.

If that works you're still looking at either ownership or access rights...

Cheers!
 
Thanks! I appreciate the response while you're away.

I finally got to try this today (been travelling the past 2 weeks for work). Using the root crontab worked. So I'll try to track down my ownership issue.
 
Hi all,

Just set this up today. Working great and will help me keep an eye on the old 1bbl whilst I'm away from the brewery. Is there any simple way to set this to Celsius rather than Fahrenheit?

Thanks in advance!

Ben
 
So I've run into a bit of a problem. I've been helping a friend set the logger up on his own pi, an older model B. Even though we followed the instructions to the letter, we were having several issues, and I suspect that it has to do with the latest apt-get update/upgrade. To begin with, four sensors are being used and not a single one could be found by the pi until we went into /boot/config.txt and added this line:

dtoverlay=w1-gpio,gpiopin=4

Now, the pi sees the four sensors and picks up the temp readings, but the database, while it WAS created and a cron job was set up, is not logging anything. All we see is "no data found" when trying to access the webgui4 page. On the same note, we tried to set up the temp display in the upper right corner and once again, no temps are showing up. The labels are but their coresponding temps are not. Of course, I'm sure it's because the database is acting weird but I'm really not sure what to begin. We went over all the instructions several times, everything seemed proper but still, no go. Thoughts?
 
Ah, the dreaded Device Tree paradigm.

Been there, done that. Check out my post here.

So you have that covered, and there wasn't anything else I needed to do to get everything running again. I'm guessing there's some generic issue, perhaps with file ownership.

If you run test_sensors.py do you see all the probes?

You can run the monitor script in a terminal session to see if it's running normally or abending in some way. If it works it will populate the database with a record of values. If it fails hopefully it'll give you a hint what's up.

Also, often these things are due to improper access rights, so make sure the files have been given the rights needed...

Cheers!
 
@day_Trippr Thank you so much for the time and effort of assembling this guide and continuing to provide support.

I recently became interested in the Rpi for Temperature logging in my ferm chamber and I initially used Privateeyepi (which is actually a pretty foolproof web based option for noobs like me). Your temp logger was much more in line with what I was looking for, although I'm still working on setting up external network access. I had read the tutorials on raspberrywebserver.com which I know you credited, but I found your approach to be much easier to follow.

Anyway, thanks again - I'll be following this thread.
 
Trying to set this up on an RPI2 has been a bit of a challenge for me. When I go to the webpage, it keeps reading "not found" even though I know I have done everything the instructions list and I am entering the web address correctly. The first raspberry pi I had, I had no trouble at all. This one is proving to be a bit more difficult. Is there anything that's supposed to be done differently on a Jesse install? For what it's worth, all of the files are in /var/www/html/ since that's where raspberry pints is installed, I thought it was the right thing to do. Thoughts?
 
Funny you say that! I just set up my 4th instance today on a rpi2. No issues with any of them, but this one today..... Same issue as you!
 
If you're into Jessie, you're way ahead of me.

If you move the files that normally reside in /var/www to /var/www/html, you need to edit the /usr/lib/cgi-bin/monitor_(N)sensors.py file and the /usr/lib/cgi-bin/webgui(N).py file to change the explicit path to the database from /var/www/ to /var/www/html.

example:

Code:
$ sudo nano /usr/lib/cgi-bin/monitor_5sensors.py

Change   dbname='/var/www/temp_data5.db'
To   dbname='/var/www/html/temp_data5.db'

Save the file and exit the editor

Next, the same change has to be made to /usr/lib/cgi-bin/webgui(N).py:

Code:
$ sudo nano /usr/lib/cgi-bin/webgui5.py

Change   dbname='/var/www/temp_data5.db'
To   dbname='/var/www/html/temp_data5.db'

Save the file and exit the editor.

I think that should fix you up.
Give those two changes a try and let me know what happens...

Cheers!
 
Unfortunately that didn't work for my application. I followed the instructions to the letter(except of course for changing any /var/www/ to /var/www/html) and changed the two files to reflect, but still a no-go. Perhaps Jessie requires something extra. Either way, I'm a bit stumped.
 
Start with the basics: what happens if you run test_sensors.py?

Cheers!

btw: did you ever get your problem back in June resolved?
 
The sensors are indeed being recognized, and their readings seem accurate. Actually, the whole install goes together flawlessly, with no error messages until I try to access the webgui page(3, in my case) And then I'm given the "not found" message

Jessie really seems to be more of a pain in the butt than it's worth. I'm thinking about reverting back and starting over. Oh, and issue that I was having back in June? It's solved but not by me. That Raspberry Pi I was actually helping a friend set up. To make a long story short, he corrupted his card, and when he started over, everything worked properly after fresh installs. So it must've been some error on our part in the install. I'll blame it on the homebrew. Lol
 
Ok, so if that much works, let's try the next step:
run the monitor program in a terminal session and see what happens.

Example for a 5-sensor setup:

Code:
pi@rpints ~ $ sudo python /usr/lib/cgi-bin/monitor5.py
24562

24.562
76.2116
76.2
temperature0=76.2
23937

23.937
75.0866
75.1
temperature1=75.1
23937

23.937
75.0866
75.1
temperature2=75.1
24625

24.625
76.325
76.3
temperature3=76.3
24625

24.625
76.325
76.3
temperature4=76.3
pi@rpints ~ $

Let me know what happens...

Cheers!
 
Back
Top