Using the analog pin to control a relay?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
digicosmos
Posts: 3
Joined: Fri Mar 16, 2018 2:02 pm

Using the analog pin to control a relay?

Post by digicosmos » Fri Mar 16, 2018 2:08 pm

Hi everyone!

In my ESP8266 project, I have used all available GPIO pins. Is it possible to use the analog pin A0 to control a relay? I have read somewhere that this pin supports digitalWrite. Is it possible to do that in MicroPython?

Thank you!

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: Using the analog pin to control a relay?

Post by deshipu » Fri Mar 16, 2018 6:48 pm

It doesn't and it's not possible.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Using the analog pin to control a relay?

Post by Roberthh » Fri Mar 16, 2018 9:51 pm

But you can use it as a slow input, polled by software, like for a switch.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Using the analog pin to control a relay?

Post by pythoncoder » Sat Mar 17, 2018 6:20 am

@Roberthh I think you may have misunderstood the original post. @digicosmos wants to re-purpose the pin as a digital output. I believe @deshipu is correct in his comment and that it's a limitation of the hardware rather than of MicroPython.
Peter Hinch
Index to my micropython libraries.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Using the analog pin to control a relay?

Post by Roberthh » Sat Mar 17, 2018 6:24 am

No, I did not misunderstand. My comment was, that if the poster has another digital pin, used as slow input, he/she could swap that with the analog pin. I did that once when I ran out of pins on a ESP8266. I used is for a "operation mode" switch.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Using the analog pin to control a relay?

Post by pythoncoder » Sat Mar 17, 2018 6:30 am

Fair point, although a pair of resistors should be used to limit the digital signal to the 0-1V that the ADC can accept.
Peter Hinch
Index to my micropython libraries.

digicosmos
Posts: 3
Joined: Fri Mar 16, 2018 2:02 pm

Re: Using the analog pin to control a relay?

Post by digicosmos » Mon Mar 19, 2018 3:43 am

Thank you too you all!

Post Reply