Smart Liquid Dispenser Using Arduino
The full build video for this dispenser — the steps below follow it in the same order.
What you need before starting
- Microcontroller: Arduino Board
- RFID Reader: RC522 RFID Module with RFID cards/tags
- Display & Control: OLED Display and 2x Tactile Push Buttons (Scroll & Select)
- Fluid System: 5V Waterproof Mini Submersible Pump, Water Flow Sensor, and Silicone Tubing
- Power & Switching: 5V Relay Module, 2S 18650 Lithium Battery Pack (with holder), and On/Off Toggle Switch
- Miscellaneous: Jumper Wires, Water Container/Reservoir, and Enclosure Box
The full build video for this dispenser — the steps below follow it in the same order.
Wire the RFID reader, OLED, and buttons
Connect the RC522 RFID module to the Arduino using SPI pins (SDA to D10, SCK to D13, MOSI to D11, MISO to D12, GND to GND, 3.3V to 3.3V). Connect the OLED display to the I2C pins (A4 for SDA, A5 for SCL, VCC to 5V, GND to GND). Wire two push buttons to digital pins with pull-up resistors for the Scroll and Select user inputs.
Connect the water flow sensor
Attach the water flow sensor to the Arduino by connecting its red wire to 5V, black wire to GND, and yellow signal wire to digital pin 2 (an interrupt pin). This allows the Arduino to count pulses and measure liquid volume in real time.
Wire the relay and separate power source
Connect the 5V relay module input pin to Arduino digital pin 7, with VCC and GND to the Arduino power pins. Power the pump using a dedicated 2S 18650 lithium battery pack rather than the Arduino to handle high startup currents. Pass the positive wire of the battery through the relay's COM and NO terminals before connecting to the pump, and join the battery ground to the Arduino ground for a common reference.
Assemble the fluid lines and pump
Submerge the 5V mini submersible pump inside the water reservoir. Connect a section of silicone tubing from the pump output directly to the inlet of the water flow sensor, and attach another tube from the flow sensor outlet leading to the dispensing nozzle.
Load the control software
In the Arduino IDE, write or upload the code handling the menu interface, RFID card UID validation, interrupt-based flow sensor calculations, and relay triggering. Ensure libraries for the OLED display (e.g., Adafruit SSD1306) and RC522 RFID reader are installed, select your board and COM port, and upload the sketch.
Register an RFID card
Power on the unit and use the Scroll button to navigate to the Register option on the OLED menu. Press Select, then scan an unregistered RFID card over the RC522 module to store its unique ID in the system memory until the display confirms the card is saved.
Test liquid dispensing
Navigate to Dispense on the screen, scan the registered card to get access granted, and choose your target volume (such as 300 mL or 500 mL). Place your container under the nozzle, press Select/OK, and verify that the pump activates, the OLED shows dispensing progress, and the relay automatically cuts power once the exact volume flows through the sensor.
If something does not work
Pump never runs: Check that the relay clicks when dispensing starts and that the battery switch is turned ON. If the relay clicks but the pump stays dead, check the battery pack voltage and the wiring on the relay's load terminals (COM and NO).
Arduino resets when the pump starts: The pump is drawing too much current from the microcontroller power rail. Ensure the pump is powered directly from the external 18650 lithium battery pack and that the battery ground is connected to the Arduino ground.
Card shows Access Denied: The scanned RFID card is not registered in the system memory. Use the Scroll button to select the Register option on the main menu, scan the card, and wait for the "Card Saved" confirmation before trying again.
Dispensed volume is inaccurate or pump overfills: Check the water flow sensor calibration factor in your sketch. If the tube has air bubbles or kinks, liquid velocity changes and causes inaccurate pulse counts, so ensure the silicone line runs smoothly without tight bends.
Display stays blank or flickers: Verify the OLED display connections to power and the I2C pins (A4/A5). Ensure the display address in your code (usually 0x3C) matches your hardware module.
