039 - MicroPython TechNotes: Electromagnet

In this article, we will tackle about on how to control an electromagnet module with ESP32 using MicroPython. Electromagnet is an artificial kind of magnet that activates and or deactivates by the use of electricity.

A logic 1 enables the electromagnet module meaning it can attract metallic objects while a logic 0 disables the electromagnet module.

  1. ESP32 development board.
  2. Gorillacell ESP32 shield.
  3. 3-pin F-F dupont wires.
  4. Gorillacell electromagnet module.
  1. G – for the ground.
  2. V – for the supply voltage of the electromagnet.
  3. S – for the control signal pin for the electromagnet.

For this lesson, I choose GPIO 23 to serve as the control signal pin for the electromagnet module.

  1. Attach the ESP32 development board on top of the Gorillacell ESP32 shield and make sure that both USB port are on the same side.
  2. Attach a dupont wires to the electromagnet module according to color coding that is black for the ground, red for the VCC, and yellow for the control signal pin.
  3. Attach the other end of the dupont wires to the ESP32 shield by matching the colors of the wires to the colors of the pin headers such that black is to black, red is to red, and yellow is to yellow pin headers.
  4. Power the ESP32 shield with an external power supply with a type-C USB connector and make sure that the power switch is set to ON state.
  5. Connect the ESP32 to the computer with a micro USB cable.

If you have any concern regarding this lesson, please write your message in the comment box provided.

If you found this article helpful, please consider supporting my journey on Youtube by Subscribing on my channel. Click this to Subscribe to TechToTinker.

Have a good days ahead everyone.

Thanks,

 1# More details can be found in TechToTinker.blogspot.com 
 2# George Bantique | tech.to.tinker@gmail.com
 3
 4from machine import Pin
 5
 6electromagnet = Pin(23, Pin.OUT)
 7
 8
 9# ******************************************************************
10# The following should be explored using the REPL:
11# ******************************************************************
12# # 1. To activate the electromagnet, set signal pin to logic 1
13# electromagnet.value(1)
14
15# # 2. To deactivate the electromagnet, set signal pin to logic 0
16# electromagnet.value(0)
...
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.