A few months ago I came on here asking for help with an Arduino aquarium monitor only to find that the crossover between the reefing and Arduino is extremely slim. So a few weeks of research later I am back with my Arduino Temperature Monitor. Now, before I show pictures, let me tell you that what I built is an over glorified digital thermometer, so don't get your hopes up. I will say however this project could be expandable to read PH, Salinity, water level, etc. However, considering I somehow fried the USB connection on the board, an Arduino UNO, I will not be doing any expanding (unless I upgrade to the mega). I have pictures and the code below. I will also include the parts you need. Overall the price to build it was around $35, so its a nice little project if you are interested in this kind of stuff.
The Code
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
[HASHTAG]#include[/HASHTAG] <Wire.h>
[HASHTAG]#include[/HASHTAG] <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars
[HASHTAG]#include[/HASHTAG] <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
void setup(void) {
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Jack's Reef");
lcd.setCursor(0,1);
lcd.print("Temp:");
}
void loop(void) {
float temperatureInCelcius = getTemp();
float temperatureInFahrenheit = (temperatureInCelcius * 1.8) + 32.0;
Serial.println(temperatureInFahrenheit);
//just here to slow down the output so it is easier to read
lcd.setCursor(7,1);
lcd.print(temperatureInFahrenheit);
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
return TemperatureSum;
}
Item list:
x1 Arduino UNO (or mega)
x1 I2C LCD screen (I used an Arrela 16x2)
x1 DS18B20 Temp Probe (water proof obviously)
x1 bread board
x1 4.7k ohm resistor
x7 male to male jumper wires
x4 male to female jumper wires
There you have it. A really simple, and cool little project. Enjoy and good luck!!!
thenanoreef
The Code
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
[HASHTAG]#include[/HASHTAG] <Wire.h>
[HASHTAG]#include[/HASHTAG] <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars
[HASHTAG]#include[/HASHTAG] <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
void setup(void) {
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Jack's Reef");
lcd.setCursor(0,1);
lcd.print("Temp:");
}
void loop(void) {
float temperatureInCelcius = getTemp();
float temperatureInFahrenheit = (temperatureInCelcius * 1.8) + 32.0;
Serial.println(temperatureInFahrenheit);
//just here to slow down the output so it is easier to read
lcd.setCursor(7,1);
lcd.print(temperatureInFahrenheit);
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
return TemperatureSum;
}
Item list:
x1 Arduino UNO (or mega)
x1 I2C LCD screen (I used an Arrela 16x2)
x1 DS18B20 Temp Probe (water proof obviously)
x1 bread board
x1 4.7k ohm resistor
x7 male to male jumper wires
x4 male to female jumper wires
There you have it. A really simple, and cool little project. Enjoy and good luck!!!
thenanoreef