Introduction: Automatic Gel Alcohol Dispenser With Esp32

About: Hello, my name is Carlos. I have a YouTube channel where I share my projects in

In tutorial we will see how to make a complete prototype, to assemble an automatic gel alcohol dispenser with esp32, it will include step-by-step assembly, electronic circuit and also the source code explained all step by step.

Step 1: Circuit

The circuit of this project is composed, of the ky-033 module, which has a reflective optical sensor, which is the TCRT5000L, an esp32-t module, although we can also use an Arduino, in any of its views, with some minimal modifications to the source code, an MG995 servo motor, in its 360-degree version, so that we can take a complete turn with a high torque , inside it is built with metal gears, and of course a printed circuit, which I will leave the gerber file below so that they can download for free.

Step 2: Features of the ESP32-T Module


The ESP32 module has all the wiFi variants:

  • 802.11 b/g/n/e/i/n
  • Wi-Fi Direct (P2P), P2P Discovery, P2P Group Owner mode and P2P Power Management

This new version includes low-power Bluethoot connectivity

  • Bluetooth v4.2 BR/EDR and BLEBLE Beacon
  • In addition, you can communicate using SPI, I2C, UART, MAC Ethernet, Host SD protocols

Microcontroller features

The CPU consists of a Tensilica LX6 Model SoC with the following features and memory

  • Dual 32-bit core with 160MHz speed
  • 448 kBytes ROM
  • 520kByteS SRAM

Have 48 Pins

  • 18 12-bit ADC
  • 2 8-bit DAC
  • 10 pin contact sensors
  • 16 PWM
  • 20 Digital inputs/outputs

Power and consumption modes

For proper operation of the ESP32 it is necessary to supply a voltage between 2.8V and 3.6V. The energy you consume depends on the mode of operation. It contains a mode, the Ultra Low Power Solution (ULP),in which basic tasks (ADC, PSTN…) continue to be performed in Sleep mode

Step 3: Servo MG995 360-degree Version

The mg995 – 360o, is a continuous rotation servo (360o) is a variant of normal servos, in which the signal we send to the servo controls the rotationspeed, rather than the angular position as happens in conventional servos.

This continuous rotation servo is an easy way to get a motor with speed control, without having to add additional devices such as controllers or encoders as in the case of DC motors or step by step, since the control is integrated into the servo itself.


  • Gear material: Metal
  • Turning Range: 360
  • Operating voltage: 3 V to 7.2 V
  • Operating speed without load : 0.17 seconds / 60 degrees (4.8V); 0.13 seconds / 60 degrees (6.0V)
  • Torque: 15 kg / cm
  • Working temperature: -30oC to 60oC
  • Cable length: 310 mm
  • Weight: 55g
  • Dimensions: 40.7 mm x 19.7 mm x 42.9 mm


  • 1 Servomotor Tower Pro Mg995 continuous rotation.
  • 3 Screws for assembly
  • .3 Coples (horns).

Step 4: Ky-033 Line Detector/Follower Sensor Module


KY-033 LINE DETECTOR/FOLLOWER SENSOR MODULE This module is specially designed for easy, fast and accurate line detection, making it easy for you to assemble line tracker robots. This module is compatible with Arduino as well as any Microcontroller that has a 5V pin. Operating voltage: 3.3 – 5 VDC Working current: 20mA Detection distance: 2-40mm Output signal: TTL level (low level there is an obstacle, High level with obstacle) Sensitivity setting: potentiometer.IC Comparator: LM393 IR Sensor: TCRT5000L Operating Temperature: -10 to +50oC Dimensions: 42x11x11mm Effective Angle: 35o

Step 5: Source Code

#include Servo myservo;

const int sensorPin = 12;//Pin del sensor infrarrojo optico refectivo

int value = 0;

void setup() {

myservo.attach(23);//Pin para el servo motor MG995 de 360 grados

pinMode(sensorPin, INPUT); //definir pin como entrada


void loop() {

value = digitalRead(sensorPin ); //lectura digital de pin del sensor infrarrojo

if (value == LOW) {//Si detecta un objeto cerca se cumple esta función

actuador();//LLama a la función actuador



void actuador(){

myservo.write(180);//Baja el actuador lineal


myservo.write(90);//Detiene al servo motor


myservo.write(0);//Sube el actuador lineal


myservo.write(90);//Detiene al servo motor

delay(2000);//Esperamos 2 segundos para que no se vuelva a ctivar el servomotor inmediatamente


Step 6:

This code can be used with any Arduino, but we should be careful to modify the use of pin 23 (with arduino mega no problem) by any Arduino pin from 2 to 13 (minus 12 because it is used for the reflective optical sensor), since for example in Arduino one or nano pin 23 does not exist.

The servo to use for this project is 360 degrees, so it rotates complements by putting a value of 180o, in a direction -myservo.write(180)-, we stop it with -myservo.write(90)- and we do turn it in the opposite direction with -myservo.write(90)-, that is why it is very important to wait a short time with delay for the linear actuator, to move to the desired position.

Step 7: Files

ST files

Or you can download them from the original car, but the file above includes a modification to one STL files that look at the video.

Gerber file

Step 8: Servo Library Compatible With Esp32

To control the motor, you can simply use the PWM capabilities of the ESP32 by sending a 50Hz signal with the appropriate pulse width. Or you can use a library to make this task much simpler.

Step 9: The End

As you can see, this is a very simple project to assemble, but they will have to have a 3D printer or make printing parts in order to assemble it. The subtraction of the components can be obtained in electronics stores, and they can even assemble everything in a protoboard, without having to do the PCB.