I would be very interested in this, even if the original poster is not.
I'll need to recall exactly how I did this. I may need to take some detailed photos of the board I built to see the exact values of the components and the wiring specifics. I know I used a H11AA1 chip, some resistors, and a capacitor to essentially detect the presence of AC power and send the signal into an ESP8266 NodeMCU board. I usually create a Fritzing diagram so I can recall the exact design, but it seems I did not do this for this project.
Also as an FYI, if you Google Arduino 120v detection or Arduino mains detection you will find many circuit designs that have been published on the Arduino forums.
I was looking at this yesterday for another application I have.
In general they all involve an opto isolator (H11AA1 or other - there are many that could work), sometimes coupled with zener diodes and sometimes not.
I still think an interposing relay is easier - although probably not cheaper.
Another concern with adding a relay is the potential current draw from the signal wiring that you're trying to monitor. HVAC systems, which was my target, aren't known for beefy 24VAC power supplies. I wanted to impact the circuit as little as possible, to prevent having the house temperature control compromised, resulting in my WAF dropping into negative territory!
I found my circuit design... working on a Fritzing project now to share it with others, as well as to document it for myself.
Here is the circuit that I am using. As @JasonJoel mentioned, I found this as well in searching the Arduino forums a few years ago. I sourced the H11AA1 chips from Amazon. I chose the resistance to limit the current seen by the H11AA1 to 10ma. This is within the chip's specifications, and still provides enough current to activate the opto-isolator LED within the H11AA1. The 25V/10uF capacitor on the output was what I had handy from another project. This ensures that the Arduino/ESP8266's digital input never sees the "zero crossings" which would cause the input to change state while AC power is on. I simply wanted the input to be either off or on, depending on whether or not 24VAC is applied.
Hope this helps!
Thanks immensely. I have not worked with Arduino before, so I have some learning to do to implement this. But learning is a good thing.
I have all of the Arduino software done that you would need. Check out my HubDuino thread for more details. Let me know if you need any assistance.
I'll take you up on assistance getting started with HubDuino. I'm afraid I got stuck on something pretty basic, which makes me a little embarrassed to have to ask. I am an experienced C programmer but totally new to Arduino and its development environment. I haven't figured out how to get your libraries downloaded from GitHub and loaded into the Arduino IDE so that sketches can access them.
Downloading from GitHub is simple... just go to the ST_Anything GitHub repository, and download the whole thing using the zip file option.
The ReadMe pretty much explains the remaining steps, regarding simply copying the contents of the libraries and sketches folders in the zip file to your corresponding folders.
Thanks. I must not have had something in the correct directory before. Now I got as far as test compiling one of your sample sketches which is further than I got before. I'll start attempting the next steps when I have more mental energy.
After a few struggles, I got Hubduino working to the point that I can control an LED on the Arduino from a Hubitat dashboard. I can also send info the other way with a physical button on the Arduino working as a contact sensor in Hubitat. Then, it got late and I needed sleep so I could function today in the job that I actually get paid to do. I am looking forward to building the Arduino circuit you provided and testing that. It feels like I am close to accomplishing my original goal. (I've felt that way before and found more barriers.)
I showed my wife how I could light the LED from a Hubitat dashboard. She was not nearly as impressed as I thought she should be.
I completely understand what you're saying... I get the same reaction from my family. If they only knew how much work it took to get a little LED light to turn on...
I have a couple follow-up questions:
Which driver should I be using? I'm thinking contact sensor, but would like to confirm.
How much AC current is needed? Your post above says:
Your picture shows 24.2 kOhms with 24VAC. Wouldn't that yield 1 ma instead of 10 ma?
I haven't made this work yet, but I don't know whether or not my issue is with this part of the circuit. My push button, which was previously working as a contact sensor, is no longer working either. I changed the power supply to the NodeMCU from a USB cable to a 9V battery via the power supply circuit that came with an Arduino kit. That appears to work, but it is a suspect since it is something that changed between the time it worked and the time that it doesn't. Is Hubduino pretty good about re-connecting to Hubitat after the Arduino has been unpowered for a few days?
Yes. I believe I was just trying to keep the current seen by the H11AA1 to under 10ma, which is what it is rated for. The 1 ma seems to work fine to trigger the H11AA1.
Yes, it should connect and just start working immediately.
Is there a reason to power the NodeMCU board with a 9v battery?
The 9V battery lets me carry it from the table where I work on it to the furnace room to test it. In the location I intend to use the circuit once it is working, it is not convenient to power it with a USB. My preference would be to power it with the 24VAC that is right there.
Any ideas why my Hubduino circuit doesn't recover after power is turned off for a few minutes and then turned back on?
Is the whole home losing power? Or just unplugging the HubDuino Microcontroller?
I have an Arduino MEGA 2560 + W5500 Ethernet shield that have been running for years through many power blips. I also have a NodeMCU ESP8266 board that also always recovers itself after a power blip.
I just unplugged in for about a minute. The cord was dangling, so I needed to re-arrange it so the plug wasn't supporting weight. It was working properly before I unplugged it, but didn't resume working when I plugged it back in. I tried pressing the reset button, but that didn't solve it.
These might be on/off with PWM - although I'm not sure as I don't have an underfloor system. It will become quickly apparent though...