040 - MicroPython TechNotes: Relay

In this article, I will discussed about the RELAY with ESP32 using MicroPython.

  1. G – for the the ground.
  2. V – for the supply voltage.
  3. S – for the control signal pin.
  1. ESP32 development board.
  2. Gorillacell ESP32 shield.
  3. 3-pin F-F Dupont wires.
  4. Gorillacell relay module.
  1. Connect relay G pin to ESP32 GND pin.
  2. Connect relay V pin to ESP32 5V pin.
  3. Connect relay S pin to ESP32 GPIO 23 pin.
  1. Copy example program in the source code section.
  2. Please feel to modify according to your needs.

If you have any question regarding this video, please write your message in the comment section.

You might also like to support me on my Youtube channel by Subscribing. Click this to Subscribe to TechToTinker.

Hope you find it useful. Thank you.

Regards,

– George Bantique | tech.to.tinker@gmail.com

 1# More details can be found in TechToTinker.blogspot.com 
 2# George Bantique | tech.to.tinker@gmail.com
 3
 4from machine import Pin
 5
 6relay = Pin(23, Pin.OUT)
 7
 8
 9# ******************************************************************
10# The following should be explored using the REPL:
11# ******************************************************************
12# # 1. To activate the relay, set signal pin to logic 1
13# relay.value(1)
14
15# # 2. To deactivate the relay, set signal pin to logic 0
16# relay.value(0)
...
py
 1# More details can be found in TechToTinker.blogspot.com 
 2# George Bantique | tech.to.tinker@gmail.com
 3
 4from machine import Pin
 5from time import ticks_ms
 6
 7relay = Pin(23, Pin.OUT)
 8sw = Pin(0, Pin.IN)
 9
10isActive = False
11start = ticks_ms()
12
13while True:
14    if ticks_ms()-start>=300:
15        if sw.value()==0:
16            isActive = not isActive
17            relay.value(isActive)
18        start=ticks_ms()
...
py
  1. Purchase your Gorillacell ESP32 development kit at: https://gorillacell.kr


Posts in this series



GitHub-flavored Markdown & a sane subset of HTML is supported.