Detecting when a device is on and running

So ive been wanting to work on some device monitoring and instead of adding sensors that listen to sound or other indicators, i wanted to see if there is anyway to determine if a device, appliance is on or turns on.

In other words, i know how to control devices with relays and such, but i would like to monitor other devices for run time and when they are running.. specifically our HVAC, i have a pretty nice digital thermostat, but when we arent home i have no idea if its running all day or for that matter how long it has run within 24hrs..

there are times we seem to notice its always running, but that could be misleading as we arent really sitting around watching or listening for it..

Is there a way to add monitoring to our HVAC and other appliances in our home with a arduino, probably log the data to a SD card for review later and maybe upgrade that to a daily notification or something..


It all depends on what means you have available to sense "on". If you have a simple wired thermostat it may be possible to identify the control line back to the master and monitor it that way. If you have a more sophisticated system the thermostat may be exchanging codes so you will need to decode them.

Once you have a signal its pretty easy to do the rest of the project. If you can connect your arduino to the internet you can use services like thingspeak and ifttt to handle the logging and notifications for you.

If you want to start with an SD card perhaps this example might assist?

Well if i remember correctly, i believe the wiring to the thermostat is only 4 wires.. So if i were able to identify the control line would i just tap into that connection and use that as my signal wire back to the arduino? As for sophisticated system, i was merely referring to the thermostat itself, unfortunately not the entire HVAC, thats why i want try and monitor it to better understand what is going on..

And to explain a little on sensing "on", so in the case of the AC, id like to know how many times it kicks on during the day while we are not home and runtime per time its running. Also at night when we are home and while sleeping(basically 24hr logging) to better understand. As for other appliances say our washer and dryer, they both have buzzers to indicate when they are done, sometimes we dont hear them being on the other side of the house and if you leave the laundry room door open so you can hear it. So those im looking to setup more of a alert that we can hear in the other side of the house or a simple text or something so we dont forget or at least catch it within minutes of it finishing so the clothes dont sit around all wet for to long.

Other appliances that we use through out the house that we tend to use alot id like to monitor usage and power consumption so again more monitoring of being turned on and run time..

This is alot more explanation where im going with the detecting if a device is on and running, but gives idea where i want to go with everything..

Maybe this link might help with your thermostat?

I also found this link on using arduino for measuring power consumption.

I appreciate the links, ill have a look at my thermostat tonight and see what im dealing with. but looking at the wire breakdown for the 4 wire setup, which would i be tapping into to get back data?

would it be the red?

G – Fan (green wire)
R – 24 VAC / Rc and R or Rh (red wire)
Y – Compressor / air conditioner (yellow wire)
W – Heat (white wire)

Four wire smart thermostats are not easy to use with Arduino. That type of thermostat makes a connection between 24VAC (R) and one or more of the other three pins, relative to a common ground (C), which is not made available.

C is available on a five wire thermostat and is required for use with an Arduino. On a five wire thermostat, if you monitor the voltage at the G (Fan) connection, you will see 24VAC appearing on that terminal (relative to ground pin C), when the thermostat is telling the fan to run.

Here is some info on adding a C terminal/wire to a four wire thermostat. Thermostat C Wire: Everything you need to know about the “common” wire – Smart Thermostat Guide

Beware that there is actually NO thermostat wire color standard.

Thats great information! Is it correct to assume that any thermostat with a LCD display has to have the ground wire connected in order to power its display?

I found - can anyone comment on its accuracy and usefulness?

So just to be clear, what you are calling a “Smart Thermostat” is truely smart in the sense of accessibility with apps and wifi? Or just one that is LCD screen enabled?

Mine is the latter, its a digital screen thermostat that is atleast 7+ years old, but works as expected and easy to use. But i would like to tap into it for monitoring and so on.

Ill make a note to pull it off the wall tonight and check what wires i have available. it may be 5 wire or not… hopefully so to make integrating with it easier… :wink:

is truely smart in the sense of accessibility with apps and wifi? Or just one that is LCD screen enabled?

Just the latter.

Is it correct to assume that any thermostat with a LCD display has to have the ground wire connected in order to power its display?

. I don’t know, but I suspect so.

well i pulled my thermostat off the wall yesterday and its only 4 wires.. but after reading the link provided above, ill have to check if in fact my unit in the attic has 4 or 5 wires running off it.. but because of the heat in texas right now, climbing up there is not on my list of things to do.. now maybe when its cooler or when i need to get up there to re-do some electrical for bathroom remodel.

Why don't you just use a current sensor. DFrobot makes one for about $20US, this is an analog signal so you will use up your analog inputs.

I have my arduino measuring the temperature of the intake side and discharge side of my HVAC. You can use the dallas one wire temperature probes, this will also tell you when you system is on. If you need a switch, you can also use the dallas one wire and the DS2413 chip by adafruit. This is nice because you can have humidity, temperature and IO all on just one data wire (actually it is 3 wires, +5, common and data).

Another choice is to use an optical isolator, I believe sparkfun makes a breakout board.

So I do have a current sensor , would I tap into one of the 4 wires? If so I guess I would need to read what comes across and determine the thresholds for what is normal when not on and what comes across when turned on?

Yes, you would read the analog value. The ones I've seen are not a full range of 0-5VDC. Most of an offset on the low end and only span a few volts. Some of the more expensive ones have all the circuitry built into them while the one from DFrobot has a separate circuit board to connect the Current Transformer up.

CRmagentics makes a nice split core current switch, so you don't need analog inputs. The non split ones are cheaper if you can disconnect the wire to slip the CT on. You can get these from digikey. They aren't cost effective if you require a lot of switches but for just two or three then it would be OK depending on your budget.

So before working on the actual thermostat wiring and trying to read from that, I wanted to start with simple sketch to measure a 9v battery lighting up a LED strip.

Here is the sketch I'm working with that I found online.. really simple and to the point.

Measuring Current Using ACS712
const int analogIn = A0;
double Current = 0;
double OutputSensorVoltage = 0;

void setup(){ 

void loop(){
 OutputSensorVoltage = analogRead(analogIn)*5.0/1023.0;
 Current = (OutputSensorVoltage - 2.5)/0.185;

 Serial.print("Current = " );  

As soon as I open serial monitor, its already spitting out values, but it never changes with or without the battery connected..

Here is what is presented no matter if I have the batter connected or not
Current = 0.07
Current = 0.04
Current = 0.01
Current = 0.04
Current = 0.04

Its mostly 0.04 and every so often the 0.01 and 0.07 show up

I'm using a Mega Board, LED, 150 ohm 1/8 watt resistor, GY-712 Current sensor, connected to A0, 5v and ground. Current sensor is connected to the power/positive side of the battery then to the led positive, the negative pin of the led is connected to the resistor then to the negative of the battery.

The LED lights up as soon as I connect the battery, so that circuit is ok to a degree, but I can disconnect the battery and the readings will still be the same.. no what I did notice is that when I have it disconnected, I tend to get a lot more frequent 0.01 readings along with the 0.04, and the 0.07 is not showing up any more..
Current = 0.01
Current = 0.04
Current = 0.01
Current = 0.01
Current = 0.04
Current = 0.04
Current = 0.01
Current = 0.04
Current = 0.01
Current = 0.04
Current = 0.04
Current = 0.04
Current = 0.01
Current = 0.01

plugging in the 9v and 150 into a few online calculators to check the math, all show that the current should be around 0.06, so I was kinda glad when I saw the 0.07, but its not consistent.. is the calculations above correct?

Up above you said you were trying to read an appliance. You would add the CT (current transducer) on the 115VAC leads to the appliance (something like the fan for the HVAC). The full load amps (FLA) should be listed on the fan motor. Of course you need to be careful what you are doing, AC greater than 50 can kill.

More reason to start simple and safe, if I can get the concept working with the 9v battery then I can move up and research more on interfacing with the appliance, in my case the HVAC system.

Since you mentioned the CT is what I have not sufficient to tap into the wiring behind the thermostat?

I was looking for something I can do with the wiring behind the thermostat since its not up in the attic, its right next to the office, so I can run temporary wiring to it from my desk for testing.

By no means am I trying to jump ahead, I want to make sure I understand the concept, test with something simple and move up..

But my current issue is that with or without the battery connected, it never changes readings.. I can add the battery and the readings are the same..

Can anyone see anything wrong with the logic that would prevent actual current readings from the sensor?
Checking all my connections with multimeter and I do get just under 8v from the battery being read thru the current connections.

Is it possible your readings are so low because you are monitoring the thermostat switch leads and so will only see the small current needed to actuate a relay, not the total current of the fan motor in the HVAC unit?

Most thermostats only have 24VAC supplied to them, not the full mains voltage. You may be better off trying to measure voltage rather than current in this case. Even if its only 24V you will still need to rectify and step-down the voltage before its suitable for arduino.

Well I'm not even working on the hvac leads yet.. I'm currently working on a breadboard and a 9v battery and the current sensor..

Once I get that working and understand the logic, I can move over to the thermostat, this project is for the thermostat itself, but I don't want to do anything there until I know I can accomplish what I need on my desk.

Everything I find when looking up voltage sensor for Arduino points me back to the same current sensor I have..

So is there something different I need to be using or is it a calculation change I need to make?

I don't really care to know actual voltage or current, my first step is merely to detect when the unit comes on, and when it turns off..

Today alone, I know that since I got home from work, the AC has been running non-stop and barely dropping the temps in the home.. we are planning on changing the outside unit within the next few days, but this project is for monitoring run time.. then I can move on to other things to monitor..

I would suggest you use a dallas one wire network. Purchase several temperature sensors that have the DS18B20 chips in them, I use the ones with the stainless steel ends, you can purchase in groups of 5 with 3m length cord. To do a dallas one wire network you can come directly off the input pin of the Arduino with a 4.7k pullup resistor but you will will find that this causes all sorts of issues when your cable lengths start to increase. The best way to do the dallas one wire network it to purchase a board that uses the DS2482-100 chip with a slew circuit. Modtronics makes an assembled board, search for "modtronics 1-Wire Interface Module with I2C bus". I think these come from Australia so they take a few weeks to come to the US. Now instead of the standard one wire setup you will need a library that uses the I2C bus connections. Now you can put one temperature sensor before your HVAC inlet and the other after. I'm doing that now to see how much my temperature drops across my AC A coil.

As far as connecting to the thermostat, these use 24VAC versus DC power. Your going to want an optical isolator for this, such as a Vishay K824P. You can connect this to the dallas one wire through a DS2413 chip or directly to the Arduino, of course you will need a breadboard and some resistors, caps, etc. Several outfits make such a board (try the Elexol 8 channel opto I/O board, never used it but the specs indicate it should work, kind of expensive).

I think you will find that temperature gives you what you need, most thermostats only have heating or cooling modes, in which case the inlet and outlet temperature is going to tell you that.

Do you have the current sensor around a single wire? Clipping it over the whole cable may not work so well.

Arduino has a on-board analog pins able to measure voltage in the range 0-5V all you need to do is ensure the voltage being measured doesnt go outside that range.

An opto-isolator is a way of measuring things without risking blowing up your input see Optocouplers: An introduction to using them with microprocessors- ec1optoiso for a good intro. whether its worth it is up to you- I buy non-OEM arduino boards off ebay for $5 each so if I blow one up it doesnt really bother me too much. (This has never actually happened to me BTW). If you dont have a multimeter you should get one- even the $10 one from your local hardware store is OK for measuring voltage and continuity.