Arduino Project : Temperature Measurement

The forum for discussing all kinds of brewing paraphernalia.
Post Reply
User avatar
awalker
Under the Table
Posts: 1018
Joined: Fri Apr 20, 2007 1:57 pm
Location: Colchester, Essex

Arduino Project : Temperature Measurement

Post by awalker » Sun Nov 16, 2014 4:52 pm

Right, time to stop hijacking Andy's thread and do my own.

Have programmed before, but with Pics and Hitachi micros
Arduino is easy, cheaper and more fun.

Arduino Uno is £6 off ebay and all software (IDE) is free http://arduino.cc/en/Main/Software

Loads of free help on http://arduino.cc/ if you cant find what you want on there, just do a google search for arduino and what you need to know i.e. arduino temp. loads of stuff out there.

Lots of free examples in arduino IDE built in
Image

So having got an arduino uno (Loads of different types) from ebay
Also obtained two Maxim one wire temperature DS18B20, called one wire but need three (power 5V, Gnd and the data wire)

All i wanted to start off is monitor temperature

Another good program to use is http://fritzing.org/home/ as you can document your project easily

Like this Image

This is all you need to start a basic temperature monitor
As there is example code in the Arduino IDE for the DS18B20. Under the One Wire example above.

This puts out the temperature by default to a serial port which you can look at on the Arduino IDE

Like this Image

Note the ROM id 24 D4 50 DB 2 0 0 49, every one wire device has its own id. So you can use multiples on one data line. The example is supposed to work up to 7 devices. I have used it with two.

Shows Fahrenheit and Celsius by default in example, I just hacked it for oC only.

Have also now added a screen, sorry the pic is rubbish. Small silver cylinder on picture contains the DS18B20 temp probe. Only one temp shown on screen so far.

Image



Future ideas - read temp via wifi / bluetooth on mobile /tablet in house
Data logger of temp to sd card
Last edited by awalker on Sun Nov 16, 2014 5:16 pm, edited 1 time in total.
Fermenter(s): Lambic, Wheat beer, Amrillo/Cascade Beer
Cornys: Hobgoblin clone, Four Shades Stout, Wheat Beer, Amarillo/Cascade Ale, Apple Wine, Cider, Damson Wine, Ginger Beer

AnthonyUK

Re: Arduino Project : Temperature Measurement

Post by AnthonyUK » Sun Nov 16, 2014 5:14 pm

A raspi in my opinion makes a better basis for this sort of thing as it has the connectivity required.
Of course it can be done on Arduino but the cost soon mount up with the various shields.

User avatar
awalker
Under the Table
Posts: 1018
Joined: Fri Apr 20, 2007 1:57 pm
Location: Colchester, Essex

Re: Arduino Project : Temperature Measurement

Post by awalker » Sun Nov 16, 2014 5:25 pm

AnthonyUK wrote:A raspi in my opinion makes a better basis for this sort of thing as it has the connectivity required.
Of course it can be done on Arduino but the cost soon mount up with the various shields.

Opinion noted.

However this screen + two temp probes + arduino = £20
Shields do cost money so I avoid them where possible.

Unless you are running Linux the PI is a bit much.

All bluetooth and wifi modules are spi or serial so can talk to the Arduinos fine.
If you want a database or something complicated i.e. web server with real time temp graphs then the PI speed and storage would be useful.

I work with i7 and Atoms all day. So for me I want something cheap and simple. I dont want to automate my brewery, just have remote temperature monitoring.

I currently have a collection of 4 arduino unos, 2 Arduino nanos, four temp probes and three LCD displays Total cost £50
4 of the arduinos have projects on going so I don't have to disconnect anything to use in another project

pays your money and take you choice.
Fermenter(s): Lambic, Wheat beer, Amrillo/Cascade Beer
Cornys: Hobgoblin clone, Four Shades Stout, Wheat Beer, Amarillo/Cascade Ale, Apple Wine, Cider, Damson Wine, Ginger Beer

User avatar
Andy
Virtually comatose but still standing
Posts: 8716
Joined: Fri Nov 18, 2005 1:00 pm
Location: Ash, Surrey
Contact:

Re: Arduino Project : Temperature Measurement

Post by Andy » Sun Nov 16, 2014 5:44 pm

=D>

I like those DS18B20 temp probes, each one has a unique address and you can wire them up in a daisy chain, adding more as required to the same "bus", cool!
Dan!

User avatar
awalker
Under the Table
Posts: 1018
Joined: Fri Apr 20, 2007 1:57 pm
Location: Colchester, Essex

Re: Arduino Project : Temperature Measurement

Post by awalker » Sun Nov 16, 2014 10:10 pm

If any one does try this, I recommend not using the stock one wire example as I said above.

This seems to be a lot better.

Dallas Temperature Control Library
http://www.milesburton.com/?title=Dalla ... ol_Library

How to use it is here
http://www.hobbytronics.co.uk/ds18b20-arduino

This basics of it are you dont need to know the ROM id for each device.
Other examples mean running the basic program to get each ROM ID then adding it to your other program for use.

The library above allows you to just go

Serial.print(sensors.getTempCByIndex(0)); // to serial output sensor 1
Serial.print(sensors.getTempCByIndex(1)); // to serial output sensor 2
etc

It does not care what the ROM id is, which means the code is portable and makes replacing a sensor simple

so all I am doing now is
lcd.print("HLT ");
lcd.print(sensors.getTempCByIndex(0));
or
lcd.print("MASH ");
lcd.print(sensors.getTempCByIndex(1));

Simples
Fermenter(s): Lambic, Wheat beer, Amrillo/Cascade Beer
Cornys: Hobgoblin clone, Four Shades Stout, Wheat Beer, Amarillo/Cascade Ale, Apple Wine, Cider, Damson Wine, Ginger Beer

User avatar
Hairybiker
Hollow Legs
Posts: 350
Joined: Tue Oct 14, 2014 10:28 am

Re: Arduino Project : Temperature Measurement

Post by Hairybiker » Mon Nov 17, 2014 12:33 pm

So how does it know which is the first ?
I suppose you can just do a scan and print the temp results but if they are all at the same temp????

Something like:
#setup sensors
HLT=sensors.getTempCByIndex(0);
MASH=sensors.getTempCByIndex(1);

Would make it easier to code later.

I have an Uno and want to play with this, I also have some DS18B20's (loose) to play with. Eventually I will get something like the probe show above.
I am thinking about a simple data logger to start with, if I use my cheap lcd/keyboard shield (looks same as yours) I can have some o/p displayed.

wmk

Re: Arduino Project : Temperature Measurement

Post by wmk » Mon Nov 17, 2014 1:13 pm

Hairybiker wrote:So how does it know which is the first ?
I suppose you can just do a scan and print the temp results but if they are all at the same temp????

Something like:
#setup sensors
HLT=sensors.getTempCByIndex(0);
MASH=sensors.getTempCByIndex(1);

Would make it easier to code later.

I have an Uno and want to play with this, I also have some DS18B20's (loose) to play with. Eventually I will get something like the probe show above.
I am thinking about a simple data logger to start with, if I use my cheap lcd/keyboard shield (looks same as yours) I can have some o/p displayed.
Short answer is it's based in the address, which isn't simply a random number. To do this is uses the arduinos one wire library search function (https://github.com/ppicazo/OneWire/blob ... neWire.cpp).
Here is the code in the Dallas temp probe library https://github.com/milesburton/Arduino- ... rature.cpp
You should see it call and include the one wire library functions as _wire.

This will explain the structure of the probe addresses which have a format and built in error detection. http://www.maximintegrated.com/en/app-n ... mvp/id/187
It also explains the functioning of the search algorithm.

in search mode the arduinos will send out a special command byte to the devices , they then respond in unison sending their first address bit, if all of them has a first bit that is 1 the arduinos will read a 1(logical and) it then asked for another bit and they all in unison will send the opposite of their first bit ( if it was 1 they send 0 and visa versa).
again the result is effectively and Of the inverse of the first bit (not and or nand). O if the first bit is a 0 and the second bit is a 0 there is a mixture of 1, 0 bits being sent, if the first bits are 0,1 then all the first bits are 0. If the result is 1,0 then they are all 1.

From this it's possible to tell if all the devices address start with 1,0 or a mixture. It then selects either 1, 0 and sends it to all the devices, only when there is a match will the devices continue to listen to the arduino ( weather it first goes down the route of 0 or 1 is decided by searchdirection flag in the one wire library), it keeps doing this until it gets an address then it'll restart from the first discrepancy and find the rest.



Best analogy I can come up with, in a large class room where everyone has a fixed length name in binary, the teacher asked everyone who's name starts with 1 one to shout yes everyone else shouts no. Then everyone who's name starts with a 0 to shout yes everyone else shouts no
If everyone's name starts with 1 she will hear yes in unison then no in unison visa versa if they all start with 0. If there is a mixture then she won't be able to make out any answers and will assume a no.
if she can't make out any answers either time she knows there is a mixture and will base her next response on searchdirection. If she knows the all begin with a certain bit obviously she simply goes by that not search direction.
She may say, stop answering if your name doesn't begin with 1.
She repeats the process for the next bit.
Last edited by wmk on Mon Nov 17, 2014 1:42 pm, edited 1 time in total.

User avatar
Hairybiker
Hollow Legs
Posts: 350
Joined: Tue Oct 14, 2014 10:28 am

Re: Arduino Project : Temperature Measurement

Post by Hairybiker » Mon Nov 17, 2014 1:33 pm

Cheers for that will have a read.
called one wire but need three (power 5V, Gnd and the data wire)
You can use them as one wire (+gnd) you only connect to the data wire and it uses parasitic power, but using all 3 is more accurate.

JabbA

Re: Arduino Project : Temperature Measurement

Post by JabbA » Mon Nov 17, 2014 2:10 pm

The One-Wire devices are great and even better-Maxim will send you out free samples! I used them in my Plastic HERMS V1 set-up and am using them again in my V2 upgrade. I did have issues with delays in the first version of my code, button presses would be missed if pressed during the 750ms calculation time that the Dallas Temperature Control Library uses. I have overcome that issue by not waiting for the conversation to end before polling the next sensor:

Code: Select all

void GetTemps (){
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > SecondInterval) {
    previousMillis = currentMillis;  
    DeviceAddress deviceAddress;
    sensors.requestTemperatures();
    ****sensors.setWaitForConversion(false);****
    HLTTemp = sensors.getTempC(HLTProbe);
    HERMSTemp = sensors.getTempC(HERMSProbe);
    MTTemp = sensors.getTempC(MTProbe);
    BoilerTemp = sensors.getTempC(BoilerProbe);
  }
}
I did use the getTempCByIndex function but have opted to specify the address now just to eliminate any chance of sensors being wired up wrongly, it just feels a more 'robust' way of doing it!

Cheers,
Jamie
Last edited by JabbA on Mon Nov 17, 2014 2:13 pm, edited 3 times in total.

User avatar
awalker
Under the Table
Posts: 1018
Joined: Fri Apr 20, 2007 1:57 pm
Location: Colchester, Essex

Re: Arduino Project : Temperature Measurement

Post by awalker » Mon Nov 17, 2014 2:10 pm

My technical test to find out the first one is, I hold one. Not just a pretty face.
Fermenter(s): Lambic, Wheat beer, Amrillo/Cascade Beer
Cornys: Hobgoblin clone, Four Shades Stout, Wheat Beer, Amarillo/Cascade Ale, Apple Wine, Cider, Damson Wine, Ginger Beer

User avatar
Hairybiker
Hollow Legs
Posts: 350
Joined: Tue Oct 14, 2014 10:28 am

Re: Arduino Project : Temperature Measurement

Post by Hairybiker » Mon Nov 17, 2014 3:02 pm

lol, KISS mode eh?

JabbA

Re: Arduino Project : Temperature Measurement

Post by JabbA » Mon Nov 17, 2014 3:22 pm

If you want to make your own thermowells, 1/4" bore copper pipe is a perfect fit for the DS18B20s!

This lunchtime was spent in the lab at work soldering up a new probe and mini-DIN connector to my HERMS coil:

Image

Image

Cheers,
Jamie

Post Reply