+21622886281
ESP32 Project

Simulation of the functioning of railway barriers with ESP32

Objective of this project:

There are barriers between a railroad train and a pedestrian or car crossing.

In this project we will realize a system that simulate the operation of automatic barriers for railways trains.

We will design this system using:

  • ESP32 card
  • two ultrasonic sensors hc-sr04 for the detection of the arrival of the train.

  • two servomotors to lower or raise the barriers

Operation of the barrier controlled by ESP32:

Components required

  • ESP32 card
  • HC-SR04 sensor

  • Servomotor
  • Supply power module

  • LEDs
  • test plate

  • connecting wires

  • toy train

Mounting:

To do the assembly, we connected:

For the first sound sensor HC-SR04:

  • the VCC pin to the 3.3V pin of ESP32

  • the Trig pin to pin D5 of ESP32

  • the ECHO pin to pin D18 of ESP32

  • the GND pin to the GND pin of ESP32

For the second sound sensor HC-SR04:

  • the VCC pin to the 3.3V pin of ESP32

  • the Trig pin to pin D22 of ESP32

  • the ECHO pin to pin D23 of ESP32

  • the GND pin to the GND pin of ESP32

For the first servomotor:

  • red wire: power supply wire to be connected to the 5V terminal of the power supply module

  • brown wire: wire to connect to the GND pin of ESP32

  • Yellow: Positioning signal wire connected to pin D4 of ESP32

For the second servomotor:

  • red wire: power supply wire to be connected to the 5V terminal of the power supply module

  • brown wire: wire to connect to the GND pin of ESP32

  • Yellow: Positioning signal wire connected to pin D21 of ESP32

For LEDs:

  • the terminals (-) of the LEDs to GND of ESP32

  • the (+) terminal of the first red LED to pin D2 of ESP32

  • the (+) terminal of the second red LED to pin D19 of ESP32

Micropython programs

Here are the micropython programs that allow you to:

  • calculate the distance between the HC-SR04 sensor and the detected object

  • raise or lower barriers

  • turn LEDs on or off

esp32-barrieres.py:

 

servo.py

hc-sr04.py:




0 commentaire


Leave a comment

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Scroll to Top