Subscribe to Arduino Academy and start learning today for FREE!

Volt Meter & Temperature Monitor – Part 2

I was unhappy with the previous version of this project, which used a TMP36 analog temperature sensor. The output moved around alot, up to 5 degrees, and wouldn’t stabilize. I replaced it with my favorite, the DS18B20 digital sensor. Now I have rock solid temperature readings, rock solid voltage measurement, and everyone is happy.

Since my waterproof DS18B20 is already wired, I wanted to keep the leads together, so I wrote a LOW to D2 to make it the Gnd, and a HIGH to D6 to make it +5vdc to power the DS18B20. A 4.7k resistor goes between data (D3) and +5vdc (D6).

This version measure 0-29vac. To measure DC, remove bridge rectifier and capacitor.

Find the address of your DS18B20

Become the Maker you were born to be. Try Arduino Academy for FREE!

See the changes below:

#include “OneWire.h”
#include “DallasTemperature.h”
#include “LiquidCrystal.h”
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

DeviceAddress insideThermometer = { 0x28, 0x27, 0xB0, 0xBD, 0x04, 0x00, 0x00, 0xF0 };

int tempNegPin = 2; // Gnd for DS18B20
int tempPosPin = 6;  // +5vdc for DS18B20

int voltPin = 0;     // voltage divider (middle terminal) connected to analog pin 0
// outside leads to 0-29vac
int val = 0;           // variable to store the value read
int volt = 0;           // variable to store the voltage calculated

void setup(void)
{
// Used two unused digital ports as +5v and Gnd for the DS18B20
pinMode(tempPosPin, OUTPUT);      // sets the digital pin as output
pinMode(tempNegPin, OUTPUT);      // sets the digital pin as output
digitalWrite(tempPosPin, HIGH);       // sets digital pin to +5vdc
digitalWrite(tempNegPin, LOW);     // sets digital pin to Gnd

lcd.begin(20, 4);            // setup LCD

// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);

}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.setCursor(0, 2);
lcd.print(“Error getting”);
lcd.setCursor(0, 3);
lcd.print(“temperature”);

} else {
lcd.setCursor(0, 2);
lcd.print(“Temp “);
lcd.print((char)223);
lcd.print(“C: “);
lcd.print(tempC);
lcd.setCursor(0, 3);
lcd.print(“Temp “);
lcd.print((char)223);
lcd.print(“F: “);
lcd.print(DallasTemperature::toFahrenheit(tempC));

}
}

void loop(void)
{
delay(500);

val = analogRead(voltPin);    // read the input pin

volt = map(val, 0, 1023, 0, 29); // map 29v range

lcd.setCursor(0, 0);
lcd.print(“VAC  “);
if (volt<10 br=”” lcd.print=”(” nbsp=””>   lcd.print(volt);

sensors.requestTemperatures();

printTemperature(insideThermometer);

}

Become the Maker you were born to be. Try Arduino Academy for FREE!

</10>

 

Subscribe
Notify of
guest
2 Comments
Inline Feedbacks
View all comments
Deneys De Beer
4 years ago

Hi Steve.

you say it can measure 0-29vac but I see you are using two 10K pots would the max volume not be 55v then? As you can adjust R1 and R2 to 10K and 1K.

Love your site by the way.

Steve Spence
4 years ago

The 29v is set by the transformer. the voltage divider allows me to fine tune to get 5v maximum. See http://www.ohmslawcalculator.com/voltage-divider-calculator

Archives

2
0
Would love your thoughts, please comment.x
()
x