Sense AC power is on/present with Photon

@peekay123

If that’s the case, then it seams that I would have to go with the relay option, or could I also run into the same issue with the low draw of the coil in the relay? If so, is there some sort of electrical item that creates a small draw that could be added to get the RAB circuit side to get it to function?

Thank you to everyone for the help!!

I’m going to do some testing with the setups that we discussed and see what works best.

Personally I’d go with a simple mains relay. They’re tough, well isolated, old tech so well understood.
Cheap chargers etc are more likely to fail, and more likely to create issues with common mode voltage - a lot of them actually float at half mains voltage due to the way their EMI filters are built.
Check the motion sensor spec - it may have ‘dry’ contacts that you can use directly. “dry” means not internally connected to anything - you have access to both ends of the switch and can connect it however you want.

At the photon end put about 10uF across the relay contacts - this will provide debounce, and also a burst of wetting current to keep the contacts clean.

@twospoons
Thank you for the suggestion, I’m learning much about the electrical end of this… so I have created a diagram to confirm your suggestion. I will do the following

  1. Connect the light sensor to the coil of the relay
  2. Connect the photon D1 pin to the common side of the relay
  3. Connect the photon ground to the normally open side of the relay
  4. Connect the capacitor with positive to the common side of the relay and the negative to the normally open side of the relay (polarized, across the relay)

That looks right. Make sure you set the PINMODE of your input pin to INPUT_PULLUP, as you have no resistive pullup.
https://docs.particle.io/reference/firmware/photon/#pinmode-

Line 4 of your description does not match what you have drawn - your drawing is the correct way:
Common and cap+ to D1, N.O. and cap- to GND.

1 Like

Another option would be to use a Fairchild MID400 to sense the presence of voltage.

1 Like

@ctmorrison
Thanks for the suggestion! I do not know how to use the Fairchild MID400 with the Photon. Would you be willing to explain it’s use further?

HI @Welder

A quicker way to get ahead is to Google things like this!

It’s an 8-pin device similar to an opto-isolator that has two LEDs inside that can be powered by normal AC line voltage and an output that indicates if the LEDs are on (i.e. line power is available) or off (power is out). You could connect the LED part to your 110V or 220V AC input and the isolated on/off output to a Photon pin.

1 Like

Hi @bko
Thanks for the information!

I did and continue to Google the MID400, but if you haven’t noticed by my posts and questions, I’m not an electrical engineer, and although I do many things in life well, I’m a little light on electrical theory and micro-controllers. I’m particularly cautious when pairing with AC power. I don’t want to burn up $20 Photons, and other shields/parts by making simple (to you) mistakes. So I feel it reasonable to ask others whom are much more knowledgeable about these things to share as much as they are willing. I find that the devil is in the details with this hobby, both in the programming part and the electrical side. Simple things like a capacitor here and a diode or resistor there, make all the difference. I’m not going to get a college electrical education out of a forum but I can certainly learn a lot, and have some fun doing it. So again I appreciate any and all help.

I’m intrigued by the MID400 as a bettor option to mechanical relay. I like the thought of it being both quite, and small. But I’m not sure about the exact wiring of it, including all the potentially additional (resistors, diodes, and capacitors) that may be needed in the correct places. I also am not sure about the fact that I am not going to be having a load on the AC side that I want to detect. Will the MID400 work in that case, and if not, how do I add a load that will not cause a safety/heat issue?

Thanks again for your help with my project!..