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.
Another update.

Occasionally (especially the first read after a system power-cycle) a DS18B20 probe may return a nonsensical temperature value (typically 0 or 185°F). This will cause a "spike" in the temperature plot, which in turn causes the plot Y-axis to be scaled to fit the "spike", compressing the plot and attenuating the curves. An example is shown below.

To filter these events there are two values added to the probe monitoring scripts (monitor*.py).

# read bounds for probes, probe readings not within bounds will be retried
# set the desired limit values
hibound=100
lobound=20

When each probe is read the returned value is tested to be within the lobound/hibound limits. If the value passes the filter the reading is stored in the database, otherwise a retry of the probe read is performed.

The default values should work for virtually any environment but can be edited if desired.

I've updated the three monitor scripts and the instructions in the temperature logger kit on my Google Drive...

Cheers!

spike_suppression.jpg
 
Day_trippr, got a question for you: After my flow meters are all set up and working with V2 of Raspberry Pints, I'm going to attempt this project of yours as well. I don't have a whole lot of knowledge when it comes to Linux, but I would like it if I could somehow display the temp of my keezer in real-time right on the Raspberry Pints tap list page, similar to how JonW did it on page 123 of the Raspberry Pints thread. I DO like the idea of having the logger, and I intend to use that. I just would like for the additional feature of real-time temp monitoring at a glance on the tap list page if it's at all possible(I know that auto refresh will probably be what changes the "temp" on the screen but that's good enough for me). If so, how would you recommend I go about doing this? I don't know Linux enough to know if the lines of code JonW used in his tap list would work for this particular setup of yours and if they do/don't, where I would even put them. Please forgive my ignorance here, and thank you for any help you(Or anyone else) can provide!
 
Could you provide the permalink for JonW's post? My page length is non-standard.

There are at least two ways to do it: read the last entry from the database and extract the data for the channel of interest; or periodically read the desired probe directly. I've already written both methods, obviously, but getting that into a form that I could use to replace the thermometer icon I use to link the logger to the 'Pints taplist page is something I need to figure out.

In any case, this is a feature I'm definitely planning on doing one way or the other. If JonW came up with a method that'll work for me I'm not above liberating some code ;)

Cheers!
 
Ok, so JonW is using javascript to pull temperature data from a networked BCS unit that apparently is the interface for his keezer/kegerator probe, and using it for that slim ribbon across the bottom of the display.

I might get something out of that useful for my configuration but there's not a lot of process similarity evident...

Cheers!
 
Ah. Gotcha. I didn't know what a BCS unit even was until I clicked the link below his signature just a little bit ago. I see now. Well like I said I'm gonna worry about V2 and the flow meter setup first, this project is going to come immediately after( so roughly a week from now) Thank you, and great work!


Sent from my iPhone using Home Brew
 
I'd like to know how you have the 5 sensors hooked up to the pi?

Are you running one wire over to the keggerator in through a single mini xlr panel mount through the back of the lid. Then five wires on the inside of the lid with mini xlr male or female connectors and then to your sensors that have mini xlr male or female connected to them?
 
I have a mini-version of my perf board 1-wire breakout boards that only has three connector positions plus the pull-up resistor. I connected one end to the 'Pi, then the Room Temperature probe plugs into the second position, and then I connected 8" Dupont jumpers from the third position to run under the keezer lid seal and into the keezer.

Those connect to one end of a "full-boat" breakout board (with 6 connector positions plus the pull-up). I don't connect the pull-up on this one, just the other four probes (for the Tower, Upper Keezer, Lower Keezer, and Keg temperatures).

It's temporary, of course. I had been waiting for the R'pints V2 impact to my keezer wiring to decide how many wires have to pass through the back edge of the lid and how to integrate the R'Pints stuff with BrewPi stuff and my own stuff.

Now that things have settled out I'm pretty sure I'm going to use a DB-25 for the bulkhead connector to bring everything through the lid and install a panel in the lid liner that will be loaded with 3 pin mini-XLR receptacles for all the probes and the flow meters. Another pair of mini-XLR receptacles will go in the lid edge for room temperature probes for BrewPi and my logger. I'll need 18 pins of the DB-25 for what I have in mind, leaving a decent number of spares for whatever comes in the future.

fwiw, I found 24 mini-XLR 3-pin receptacles for $1.20 each and 24 mating plugs that will accommodate the 4mm thick cables used by the DS18B20 sensors for $1.40 each.

By my current calculations I'll need 16 of each...

Cheers!
 
I know this is a little off topic but im debating building a brewpi and was wondering if it can control two keezers? Or should I still with 2 seperate STC-1000 controllers and just monitor my temps with these probs integrated into RPints?
 
This gets asked a lot :)

You can totally run two or more keezers or kegerators or fermentation chambers with one RaspberryPi and a pair of USB-connected Unos or Leonardos. You can also layer on multiple packages, such as RaspberryPints for a tap list display, and have some fun using a passive IR motion sensor to wake up your tap list display when someone comes in range of your dispensing system - even play a greeting or music; or add a comprehensive temperature logger that you can get to from anywhere on the planet.

I'm running a configuration that would manage any two systems - kegerator, keezer, fermentation chamber. Pick any combination of two. Two instances of BrewPi running on a pair of Unos. At the same time, I have a five channel temperature logger, and a tap list display, that I can see from virtually anywhere (including the 19" display above my keezer - which wakes up from a black screen when someone comes within about 10 feet of my keezer).

Another HBTer is going to be controlling four fermenters using four instances of BrewPi, so there's plenty of headroom on the 'Pi side. The rest is connectivity - you quickly end up needing a USB hub to tie things together...

Cheers!
 
This gets asked a lot :)

You can totally run two or more keezers or kegerators or fermentation chambers with one RaspberryPi and a pair of USB-connected Unos or Leonardos. You can also layer on multiple packages, such as RaspberryPints for a tap list display, and have some fun using a passive IR motion sensor to wake up your tap list display when someone comes in range of your dispensing system - even play a greeting or music; or add a comprehensive temperature logger that you can get to from anywhere on the planet.

I'm running a configuration that would manage any two systems - kegerator, keezer, fermentation chamber. Pick any combination of two. Two instances of BrewPi running on a pair of Unos. At the same time, I have a five channel temperature logger, and a tap list display, that I can see from virtually anywhere (including the 19" display above my keezer - which wakes up from a black screen when someone comes within about 10 feet of my keezer).

Another HBTer is going to be controlling four fermenters using four instances of BrewPi, so there's plenty of headroom on the 'Pi side. The rest is connectivity - you quickly end up needing a USB hub to tie things together...

Cheers!

Great work on everyones part: RaspberryPints, BrewPi and you day_trippr!! :mug: I am working on buying up all the parts to basically minic your setup. I will probably be bugging you a lot when assembly and install time comes. One question: where would you go to get the 4.7K resistor for the BrewPi? Last part to get.
 
Radio shack has them. That's where I got mine. They are also carried at Frys, eBay, Amazon, and many other places.


Sent from my iPhone using Home Brew
 
Just got this up and running! I was going to wait till after the flowmeter installation but I figured "Why wait?" I only have one sensor at the moment, probably will find myself adding more as time goes on. I can't thank you enough, Day_tripper. You made this awesome program very easy and quick to install. Next up are flowmeters and the PIR. After that? Hmmm.....
 
Excellent! Happy to see folks are enjoying this aspect of the hobby, the convergence of hardware and beerware has been a hella lot of fun for me :D

Cheers!
 
The "purge database" Python script is its own file.
You can create it in /home/pi and call it anything you like.

You can then manually run it once a week or put an entry in cron to run it weekly. It does require root privs so preface the command line entry with sudo...

Cheers!

To get back to an old Q.
If I run this, should the "temp_data.db" folder be empty after every "purge"
Tx
 
To get back to an old Q.
If I run this, should the "temp_data.db" folder be empty after every "purge"
Tx

Oh no - that would be very bad, as that's not a folder but the actual database file with the tables within. If it went to zero, that'd be one dead database ;) It should be winnowed down, but definitely not empty.

My latest set of web guis in the kit have a "Last 10 Days" selector, meaning they'll go back 240 hours if there are database entries that old. The purge script deletes records older than 200 hours; so you can now display the "before" and "after" effects of running the purge script...

Cheers!
 
If I want to use 4 probes and used the 5 probe database, should it still function? Just wondering if I did something wrong or maybe should have set up the database for 4 probes.
 
If I want to use 4 probes and used the 5 probe database, should it still function? Just wondering if I did something wrong or maybe should have set up the database for 4 probes.

Jeeze, I'm honestly not sure what might happen or not if you ran the five-probe setup with a missing probe. The script that polls the probes and updates the database probably isn't going to be happy - I check that a probe responds to the first attempted read and if that fails try once more before punting. So I think it'd be problematic.

If you really want a four probe setup it would only take a handful of minutes to cobble that together by chopping down the five probe files. Let me know...

Cheers!

[edit] It was quicker to just go ahead and crank out the files for four sensor support. They're in the kit on my Google Drive here...
 
That was quick... I'll try it tomorrow. I was going to use this to monitor my new double pipe wort chillers input and output temps as I adjust the flow rates.

I'll also adjust it to read the temps every 2 seconds or so.

Looking forward to it.
Thanks
 
Subsetting supersets is usually pretty easy work. The other way around is harder ;)

If there's any problem let me know. I confess it was an ordeal of a day and I'm just a bit too wiped to actually test the four sensor files out tonight. It should be ok but you never know 'til you run it. If I can get to it I'll set it up on my dev system tomorrow and check it out...

Cheers!
 
Cool stuff. I have mine running in two rooms a bit different. Arduino picks up ferm temps sends to xively then pi apache web server uses JSon to display the data. I need to make a python script to log into a MySQL db so. Can save fermentations.

Pi is in garage and arguing is in back room.
 
Besides being intrinsically useful, getting stuff like this up and running is a lot of fun isn't it? :)

One of the primary goals of this crude effort was to explicitly avoid dependence on resources outside of my home lan. There were quite a few alternative - pretty much canned - solutions that vectored through various web sites, but I really wanted to avoid that. The result isn't as pretty as what some of those alternatives offered, but I just wanted the data - my PowerPoint days are way behind me ;)

Cheers!

[edit] I should acknowledge that the charting is provided by a Google API. Eliminating that dependency is a project for the winter...
 
That it is!!

I plan on updating to take out xively altogether. Trying to figure out how to pull info from arduino on the pi. New to the pi. Seems a python script should be able to do it over Ethernet but that needs to be determined. Not sure how to go serial over Ethernet. Got a few arduino projects going now.

The Biggest being for my brew stand. One wire temp probes and a sf500 flow meter for filling and transferring. To accurately measure volumes.
 
Found another sensor so I just used the 5 sensor db.
I found out that crontab only allows 1 minute intervals so I used a command in the terminal to run the monitor_5sensors.py command every 1 second. It only stops when I hit ctrl c.

Code:
while true; do sudo /usr/lib/cgi-bin/monitor_5sensors.py; sleep 1; done

It takes about 5 seconds to read all the probes, post the data, then waits 1 second and does it again, so the database gets posted every 6 seconds.

Perfect for what I want to do.

Thanks

Now I gotta mount my probes in their SS homes.

Did you guys use thermal grease, epoxy, or something else? I have 6" SS tubes with a spun closed end.
 
6 seconds? You're gonna generate a ton of data with that! :D

As for the probes and wells: often you don't need any thermal conductor between probe and well - some testing might be useful in that regard. But if you want to use something definitely don't use epoxy: most are quite poor thermal conductors, and it's tough to replace an epoxied probe.

Either silicone thermal grease (like heat sink compound) or mineral oil or citrus oil will be effective...

Cheers!
 
Cool thanks.
For this go round I'll be using this in 5-10 min runs testing different flow rates and temp changes.
Having it all recorded will let me go back and compare the temp differentials and then dial it in for my next batch so that when the wort hits the fermenter it will be exactly 70*
 
day_trippr, can I annoy you for a sec? Lol, I've added two more sensors to my setup for a total of three. I tried running the 1,2,and 5 sensor setup instructions. Webgui1, and 2 work as supposed to, but 5 basically gives me nothing. Constant message of "No Data Found" Since I know nothing about "Building" these files, is a 3 probe database on your google drive the only way it would work? Or am I missing something simple?
 
lol! With 1, 2, 4 & 5 sensors covered I supposed it was inevitable I'd need to cobble up a 3 sensor set eventually ;)

Yes, if you don't have enough probes to cover the expected set the scripts will be very unhappy.

I should be able to whip up that last set of files tomorrow.
I'll post when they're available...

Cheers!
 
Awesome! Thank you so much. I just added two more today. It was kinda one of those "Just for the hell of it" sorta things. With my particular setup, I don't really have a need for more than three, personally. I'm wanting mine to read ambient air temp, keezer temp, and coffin temp.
 
Ok, I've created the two files to support 3 sensors and revised the instructions.

The updated kit is available on my Google Drive here.

Let me know if there are any problems...

Cheers!
 
Got everything up and logging 4 probes (keg, kegerator, tower, and room), even figured out how to change the 'Ch0' to display the right name like "Keg". Two questions:

1 - To add the purge_dbase cron, I did:

$ sudo crontab -u www-dat -e

then I added:

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

The 1440 would run it once a day, and /home/pi/purge_dbase.py should point it to the home directory where the purge_dbase.py is located - is that all correct?

2 - When I edited the 'Ch0' column headers for Current, Min, Max, and Avg temperatures - the spacing of the actual values doesn't line up as well anymore. Is there anything I can do to space the values out more to line up? Of all things, this is the slightest of issues - especially because I will probably reference the graph most.

Thank you so much day_trippr for developing AND supporting this! I'm going to be spending a lot of time tracking my temperatures for no reason other than I can, and it's cool!

Now, to get rPints fully working...
-Kevin
 
Well done! And happy you're enjoying the logger :)

If it isn't obvious, the "formatting" of the tabular data is as crude as could ever be imagined - just an imperial crap ton of space characters every friggin' where ;)

It needs a lot of love that I haven't had time for, but I've also been hankering to replace the Google graphing API with something that absolutely doesn't need the internet, so there is some motivation to revisit this project eventually. Hopefully once winter settles in I'll get back into it a bit.

As for your cron task to run the purge script, what you have looks correct.
The script uses an absolute reference to the database file as well, so you should be good...

Cheers!
 
day_trippr this is great! Your instructions are spot on and with the all the scripts for multiple sensors I can easily add more when I want to.
I was also easily able to change the code so the temps are in Celsius.

As I was looking at it all it occurred to me that since the data for the temps are written in to the database every 5 minutes and my Rpints page refreshes every 5 minutes, why couldn't I be able to call up the last entry of the temp_data2.db and insert them into my Rpints page.

My html coding is O.K. but my PHP is almost non existent. I searched the web and tried various ways to call the last entry but none of them worked. And why are there so many ways to do this? Drives me crazy...

Anyhow here is the PHP I was using to call up the last database field. If you have the time can you fix it or at least tell what about it is wrong. I would really like to have this up on my Rpints page.

Thanks in advance.

PHP:
<?php

$dbd = sqlite_open('/var/www/temp_data2.db', 0666, $error);

if (!$dbd) die ($error);

$query = "SELECT temp0, temp1 FROM temps ORDER BY timestamp DESC LIMIT 1";
$result = sqlite_query($dbd, $query);
if (!$result) die("Cannot execute query.");

while ($row = sqlite_fetch_array($result, SQLITE_ASSOC)) {
echo "Tower Temperature" . $row['temp0'] . "C";
echo "<br>";
echo "Fridge Temperature" . $row['temp1'] . "C";
}
sqlite_close($dbd);
?>
 
My php skills are essentially zero so I'm not going to be a huge help there.

But the logger script pulls the latest row from the database using the MAX(timestamp) descriptor, so you might try something like this:

$query = "SELECT MAX(timestamp),temp0,temp1 FROM temps";

Cheers!
 
You can do it a little dirtier too by sorting it descending order by time stamp but then not doing a loop to return the rows. It'll return just the first row.


ORDER BY timestamp DESC

Sent from my iPhone using Home Brew
 
WOW-that was like trying to read a chinese newspaper, not a clue but looks cool
Very impressive what you guys can do with these PI`s:mug:
 
Did you get the PHP figured out?

Yes I did!

After a few frustrating attempts I had to step back from it for awhile but coming at it fresh today got it nailed down, at least on my rig.

As long as you have a stock install of RaspberryPints and followed day_trippr's instructions this should work.

First open LXTerminal and type
Code:
sudo apt-get update
and hit enter and when it finishes type
Code:
sudo apt-get install php5-sqlite
and hit enter

Install the following code anywhere you want a temperature reading on the Rpints index page

Code:
<?php
$db = new SQLite3('temp_data2.db');
$result = $db->querySingle('SELECT temp0 FROM temps ORDER BY timestamp DESC', true);
foreach ($result as $row) {
echo $row;
}
?>

Change temp_data2.db to whichever temp_data db you are using and then to use multiple instances, just change temp0 to whichever sensor you want.

A screen shot of my Pints page with two sensors.

HTnj2C2.png


Sensor temps are a little high as they are not installed into my kegerator yet.

Next up getting my PIR motion sensor working.
 
Looks good! I've been wanting to do exactly this for some time now but I suck when it comes to code. Glad it's finally up here in a way I can understand. Where did you insert this code to display in the upper right hand corner like you have?


Sent from my iPhone using Home Brew
 

Latest posts

Back
Top