To control two lamps using the ESP32 board, you will need the following components:
ESP32 Board:
The ESP32 is a microcontroller board that features built-in WiFi and Bluetooth capabilities. It can be programmed and used to control the lamp.
Two Relays Modules:
You'll need a relay module that is compatible with the ESP32 card and can switch the high-voltage lamp. Ensure it's rated for the voltage and current required for your lamp.
Two Lamps (220V):
The two lamps is rated for 220V. Ensure it's in working condition and safe to use.
Power Supply for the Lamp:
You'll need a power source for the lamp, typically a 220V AC power supply.
Wiring:
Various wires and cables for connecting the components in your circuit.
Breadboard:
A breadboard is a prototyping board that allows you to build circuits without soldering. It provides a convenient way to connect the components together.
Jumper Wires:
You'll need jumper wires to make connections between the ESP32 card, lamp, relay, and breadboard. Ensure you have male-to-male jumper wires or a mix of male-to-male and male-to-female wires, depending on your specific needs.
To control two lamps using a ESP32 board, you will need to use two relays modules to safely interface the low-voltage ESP32 card with the high-voltage lamp. Here are the step-by-step instructions to set up the ESP32 with two lamps :
1- Safety First: Ensure the two lamps are disconnected from any power source before proceeding.
2- Connect the first Relay to the ESP32:
- Connect the relay's control pin (S) to pin 23 of ESP32 board.
- Connect the pin (+) of relay to pin 3.3V of ESP32 board.
- Connect the relay's ground pin (-) to the ESP32's GND.
3- Connect the first Lamp and the power supply to the Relay:
- Connect one of the the the power supply wires to the relay's common (COM) terminal.
- Connect the phase wire of the lamp's to the normally open (NO) terminal of the relay.
- Connect the neutral wire of the power supply directly to the neutral wire of the lamp.
4- Connect the second Relay to the ESP32:
- Connect the relay's control pin (S) to pin 22 of ESP32 board.
- Connect the pin (+) of relay to pin 3.3V of ESP32 board.
- Connect the relay's ground pin (-) to the ESP32's GND.
5- Connect the second Lamp and the power supply to the Relay:
- Connect one of the lamp's wires to the relay's common (COM) terminal.
- Connect the phase wire of the power supply to the normally open (NO) terminal of the relay.
- Connect the neutral wire of the power supply directly to the neutral wire of the lamp.
To flash two lamps using an ESP32 board with MicroPython, use the following MicroPython code to blink the lamp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from machine import Pin import time # Configure the GPIO pin to control the relay as an output relay_lamp1 = Pin(23, Pin.OUT) relay_lamp2 = Pin(22, Pin.OUT) while True: relay_lamp1.value(1) # Turn on the first lamp by activating the relay relay_lamp2.value(0) # Turn off the second lamp by deactivating the relay time.sleep(1) # Wait for 1 second relay_lamp1.value(0) # Turn off the lamp by deactivating the relay relay_lamp2.value(1) # Turn on the second lamp by activating the relay time.sleep(1) # Wait for 1 second |
This code will blink the two Lamps by the two relays connected to GPIO 23 and GPIO 22 with a period of 1 second.
Upload the code to the ESP32 board using your MicroPython editor.
Once the code is uploaded and the physical connections are made, the two lamps should start to blink based on the code. Adjust the sleep durations (time.sleep()) to modify the timing of the lamp's on and off states as desired.
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info