Software developer here, trying to mess around with hardware (VERY NOVICE) and implement neat things around the house using ESP8266s and Arduinos.
I have a commercial wall plug that is activated when motion is detected, to turn on the light in my home office. I want to use that 24VDC signal to publish an MQTT message via ESP8266.
I connected to the relay inside the motion detector and it reads about 24.4VDC when motion is detected.
I read online about reducing voltage and used a voltage divider to bring the voltage down to a solid 3.26-3.3V.
On an ESP8266, I use the D1 pin, mode set to INPUT, sampled at 5Hz. It is powered via USB, connected to my laptop.
The problem is that when I connect that voltage-divided 3.3V signal to D1 on the ESP8266, instead of steady 1s I get a seemingly random mix of 1s and 0s...
So I measured the voltage between D1 and G on the ESP8266 and it is showing 1.57V.
I measured the voltage between the motion detector's ground and voltage-divided output and it's showing 12.6V instead of the original 3.3V.
As I said, I'm a software guy dabbling in hardware and this is some serious sorcery to me.
Attached is a crude schematic. Green numbers represent measurements AFTER the working 3.3V dashed line is connected to D1 on the ESP8266.
Any ideas would be greatly appreciated. Thank you in advance!