ESP8266 and Relay

Hi,

I'm planning to make a circuit to identify the status of a home alarm and send the information via wireless to IFTTT.

But the connections from the alarm (to a enable/disable signal and the siren signal) are 12v. So, I'm planning to use a relay to make this connection to a digital INPUT pin into arduino. But I don't know exactly which pins to connect to make this possible. I need to use a 3.3v or 5v into a relay pin to close the digital pin?

Also, I'm stuck in ESP8266 code, I was only able to connect into my Wireless network, but I can't make the code to access URL for IFTTT. Anyone have an example code to allow this? I need to access a URL for each state (3x) of the alarm, which I already created into IFTTT (alarm enable, alarm disable and siren active).

I appreciate any help on this.

Regards,
Fernando

If you are wanting to communicate a 12 V signal to an input of an Arduino or ESP8266, you do not use a relay, you use an optocoupler.

Connect the optocoupler output between an I/O pin and ground, using INPUT_PULLUP mode.

Size the series resistor on the optocoupler input for about 5 mA.

Hi Paul,

Thank you for the clarification, do you have the schematic needed for the optocoupler?

Can I use the +/- from 12v to optocoupler inputs?

Thanks

OK, here's the best image I could conjure up!


The "signal input" and "signal gnd" on the left are plus and minus from your 12 V circuit while the connections to the right are the Arduino or ESP8266.

If as I explained, you use INPUT_PULLUP, you do not need the 10k resistor from the I/O pin to VCC and the resistor on the left for 12 V would be 2.7k.

Paul__B:
OK, here's the best image I could conjure up!


The "signal input" and "signal gnd" on the left are plus and minus from your 12 V circuit while the connections to the right are the Arduino or ESP8266.

If as I explained, you use INPUT_PULLUP, you do not need the 10k resistor from the I/O pin to VCC and the resistor on the left for 12 V would be 2.7k.

Thank you so much Paul! I will find out some of it tomorrow and do this.
I will post the results after do it.
Thanks!