A forum dedicated to design and program aquatic tanks
It is currently Tue Feb 20, 2018 12:34 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Thermometer with display
PostPosted: Wed Aug 24, 2016 2:29 pm 
Site Admin

Joined: Fri Nov 30, 2012 1:54 pm
Posts: 275
So Paronaram made the DIY par meter and he had the circuit board printed. You can only print out in batches so he had a few on his hands. I decided to find different uses for the printed boards.


The thermometer I used is a onewire DS18B20.

Theoretically you can hook up multiple sensors since it's oneWire but you'll have to play with that.
You can also leave out the 15K resistor and POT on the signal line. That's not needed but I had it soldered in already.

Here's the code

#include <OneWire.h>
#include <LiquidCrystal.h>

//Celsius=(Fahrenheit–32)×5÷9. Fahrenheit=Celsius×9÷5+32

int DS18S20_Pin = A0; //DS18S20 Signal pin

//Temperature chip i/o
OneWire ds(DS18S20_Pin); 

// create the LCD
LiquidCrystal lcd(8, 7, 5, 4, 16, 2);
// set up backlight
int bkl = 6; // backlight pin

void setup(void) {
   lcd.begin(16, 2);
   lcd.begin(16, 2);
    // Print a message to the LCD.
   pinMode(bkl, OUTPUT);
   digitalWrite(bkl, HIGH);

void loop(void) {
  float temperature = getTemp();
   lcd.setCursor(0, 1);
    // print the number of seconds since reset:
    lcd.print("C   ");
    lcd.setCursor(9, 1);
    lcd.print("F   ");
  delay(1000); //just here to slow down the output so it is easier to read

float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( ! {
      //no more sensors on chain, 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.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();;   
  ds.write(0xBE); // Read Scratchpad

  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] =;
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  return TemperatureSum;

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Copyright 2noodles LLC 2012