039 - MicroPython TechNotes: Electromagnet
Introduction
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.
Bill Of Materials
- ESP32 development board.
- Gorillacell ESP32 shield.
- 3-pin F-F dupont wires.
- Gorillacell electromagnet module.
Pinout
- G – for the ground.
- V – for the supply voltage of the electromagnet.
- S – for the control signal pin for the electromagnet.
Pin Assignment
For this lesson, I choose GPIO 23 to serve as the control signal pin for the electromagnet module.
Hardware Instruction
- Attach the ESP32 development board on top of the Gorillacell ESP32 shield and make sure that both USB port are on the same side.
- 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.
- 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.
- 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.
- Connect the ESP32 to the computer with a micro USB cable.
Video Demonstration
Call To Action
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,
Source Code
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)
References And Credits
- Purchase your Gorillacell ESP32 development kit at: https://gorillacell.kr
Posts in this series
- 049 - MicroPython TechNotes: MP3 Player
- 048 - MicroPython TechNotes: Analog Touch Sensor
- 047 - MicroPython TechNotes: E108 GPS
- 046 - MicroPython TechNotes: RF433 Transceivers
- 045 - MicroPython TechNotes: Infrared Transmitter
- 044 - MicroPython TechNotes: Infrared Receiver
- 043 - MicroPython TechNotes: ESP12E WiFi | External WiFi module
- 042 - MicroPython TechNotes: JDY-32 | Bluetooth Low Energy BLE
- 041 - MicroPython TechNotes: Bluetooth HC-06
- 040 - MicroPython TechNotes: Relay
- 038 - MicroPython TechNotes: Buzzer
- 037 - MicroPython TechNotes: Servo Motor
- 036 - MicroPython TechNotes: Stepper Motor
- 035 - MicroPython TechNotes: Dual Motor Driver
- 034 - MicroPython TechNotes: DC Motors | Gear Motor and Fan Motor
- 033 - MicroPython TechNotes: TCS34725 RGB Color Sensor
- 032 - MicroPython TechNotes: BMP280 Sensor
- 031 - MicroPython TechNotes: TOF Distance Sensor
- 030 - MicroPython TechNotes: DS3231 RTC
- 029 - MicroPython TechNotes: HC-SR04 Ultrasonic Sensor
- 028 - MicroPython TechNotes: DHT11 Temperature and Humidity Sensor
- 027 - MicroPython TechNotes: Rotary Encoder
- 026 - MicroPython TechNotes: Light Dependent Resistor (LDR)
- 025 - MicroPython TechNotes: Joystick
- 024 - MicroPython TechNotes: Slider Switch
- 023 - MicroPython TechNotes: Continuous Rotation Potentiometer
- 022 - MicroPython TechNotes: Potentiometer | Reading an Analog Input
- 021 - MicroPython TechNotes: Color Touch Sensor
- 020 - MicroPython TechNotes: Touch Sensor
- 019 - MicroPython TechNotes: Switch Module
- 018 - MicroPython TechNotes: Button | Reading an Input
- 017 - MicroPython TechNotes: LASER Module
- 016 - MicroPython TechNotes: RGB LED Matrix
- 015 - MicroPython TechNotes: Neopixel 16
- 014 - MicroPython TechNotes: 8x8 Dot Matrix Display (I2C)
- 013 - MicroPython TechNotes: 8x16 Dot Matrix Display (SPI)
- 012 - MicroPython TechNotes: 8x8 Dot Matrix Display (SPI)
- 011 - MicroPython TechNotes: 1.3 OLED Display
- 010 - MicroPython TechNotes: 0.96 OLED Display
- 009 - MicroPython TechNotes: 7 Segment Display
- 008 - MicroPython TechNotes: 16x2 LCD
- 007 - MicroPython TechNotes: RGB LED
- 006 - MicroPython TechNotes: Traffic Light LED Module
- 005 - MicroPython TechNotes: Gorilla Cell LED | MicroPython Hello World
- 004 - MicroPython TechNotes: Gorilla Cell I/O Devices
- 003 - MicroPython TechNotes: Gorillacell ESP32 Shield
- 002 - MicroPython TechNotes: Introduction for Gorillacell ESP32 Dev Kit
- 001 - MicroPython TechNotes: Get Started with MicroPython
- 000 - MicroPython TechNotes: Unboxing Gorillacell ESP32 Development Kit
No comments yet!