Skip to main content

37. Automatic Water Dispenser using Ultrasonic sensor

Hey friends!
Today, I am going to teach you about making an automatic water dispenser using ultrasonic sensor. I  got this idea when I referred to a university's project, with five members and a duration of five days. I managed to do this project with limited resources within three hours.
If you have any suggestions on how I could improve this project, please don't hesitate to comment them below. In this project, I am using the ultrasonic sensor (HC-SR04) to detect the water bottle within the range of 2-3 cm. Read further on to learn the codes and how I did this project.

Supplies

  • Arduino Uno/ Nano
  • USB Type A/ B cable (for Arduino Uno) or USB Type A to mini B cable (for Arduino Nano)
  • Solderless Breadboard - Mini
  • Ultrasonic sensor (HC-SR04)
  • Relay module - 5V single channel
  • 5V DC mini Water pump - Submersible
  • Container - filled with water
  • Empty Water bottle (optional)
  • Male-to-Male jumper wires (x9) - 10 cm
  • Female-to-Female jumper wires (x7) - 70 cm
  • Cardboard box / 3D printed casing

Setup


Your setup must look somewhat familiar to the one in the images above.

Connections

Ultrasonic sensor (HC - SR04)

  • VCC - 5V
  • Trigger pin - D5
  • Echo pin - D4
  • GND - Ground

Relay Module (5V single channel)

  • S - D6
  • (+) - 5V
  • (-) - Ground (GND)

Coding

 Let me explain you how this project works. The pin of the relay module is set HIGH when the bottle is detected at a range of 2-3 cm away from the ultrasonic sensor. When the bottle is taken out of range, the relay module is automatically switched off. Now, I will explain you the codings.
The ultrasonic sound sensor has an ultrasonic wave transmitter and receiver. A transmitter emits a signal which is reflected off an object - within 2 cm to 400 cm - and received by the receiver. The time taken for the signal to travel from the transmitter to the receiver is divided by two and multiplied by the speed of sound in air to give us the distance between the sensor and the object.
Create global variables for the trigger pin, echo pin and the relay module. You must also create variables for the duration and distance. The type of variable for the duration must be long, and that for the distance must be int.
Within void setup( ), configure whether the pins of both ultrasonic sensor and the relay module are INPUT or OUTPUT. Within void loop( ), set the trigger pin LOW for 5 microseconds before setting it HIGH. Set a delay period of 10 microseconds to emit an ultrasonic pulse before setting the trigger pin LOW. Read the duration of the pulse using pulseIn( ) function and wait for the echo pin to go HIGH.
Calculate the distance by using simple high school mathematics and physics.
  • Distance = Speed of ultrasonic pulse in air x Duration
  • 1 microsecond = 1e-6 seconds
  • Speed of ultrasonic pulse = 3 x 10^8 m/s (3e8 metres per second)
* Note: Before calculating the speed, please don't forget to divide the distance by 2, because the pulse is reflected off by an object. If you still don't understand, please feel free to comment below. I can help you with it.
As I already mentioned, the relay module must only be switched on when the object (in this case: bottle) is kept within 2-3 cm away from the sensor. To do this, you must use the 'if ...else' function. 

**Note: I am sorry for not uploading the image of this project's codes. I am trying to upgrade this project so the codes are still being developed. Once I complete them, I will make sure that I upload the codes.
If any of you have doubts with the codes, please feel free to comment below or send an email to arduinoprojectsbyr@gmail.com.

Final Look

If you have any questions, or suggestions, about this project, please feel free to comment below or send me an email at arduinoprojectsbyr@gmail.com.

Comments

  1. Plz plz will you give me the complete circuit diagram of it

    ReplyDelete
    Replies
    1. Sorry. The diagram will be available after this project is completed.

      Delete

Post a Comment

Popular posts from this blog

51. Buzz wire game using Arduino

Hello everyone! This is my first Arduino project in 2020 and it is going to be a fun and simple project. You would have heard of the Buzz Wire, a steady hand game, and today you will be learning to make one using Arduino. Hardware components used in this project Arduino Nano USB Type A to mini B cable (for Arduino Nano) Solderless Breadboard - Mini and Full-size LEDs (x2) - Green and Red Resistors (x2) - 220 Ω  Active Buzzer module (KY-012) LCD display module with I2C interface - 16x2 Male-to-Male Jumper wires (x4) - 10cm Female-to-Male Jumper wires (x5) - 20 cm Jumpers (x5) - to reduce the usage of wires Copper wire  Tape (or any form of insulation)  Setup Your hardware setup must look somewhat similar to the ones in the images above. The beginning and end of the copper wire maze must be taped to prevent conductivity between the wire loop and maze. Connections LCD display module with I2C interface GND - Ground VCC - 5V SDA -...

71. Buzz Wire Game ( Version 2.0 ) using Arduino

Hey Everyone! I hope that everyone's safe during this pandemic. Today I am going to explain you about the second version of my Buzz wire game. People who are bored of staying indoors can find this game pretty interesting and fun to play.  If you are a beginner, you can start off with my first version of this project :  51. Buzz wire game using Arduino   Hardware components used in this project Arduino Uno Solderless Breadboard (x2) - Full/ Full+ LCD display module with I2C module - 16x2 Potentiometer - B20K Push-buttons (x3) Resistor - 220 Ω Active Buzzer module (KY-012) LED - Red Copper Wire - 19/ 20 gauge thick Male-to-Male Jumper wires - 10cm and 20cm Wire - Long enough to connect the loop of copper wire to ground Other tools required for this project Cutting pliers - To cut the right amount of copper wire Round-nose pliers - To bend the copper wire and make a maze and loop Hardware setup Connections Wire Maze - D2 Wire loop - Ground (GND) B20K Potentiometer S - A0 (+)...

86. RFID Health tag (Arduino and Python)

 Hey everyone, Sorry I have not uploaded in a while. Today, I will be sharing an interesting project with all of you. This RFID Health tag project is useful when it comes to keeping track of vaccinated individuals, their biodata and their health conditions and medications. For this project, you will be needing Arduino and Python. Read on further to see how I did this project. Hardware components used in this project Arduino Uno Solderless Breadboard - Half+ MRFC522 RFID reader RFID key tags (x5) Push-buttons (x2) Male-to-Male Jumper wires (x12) USB Type A/ B cable (for Arduino Uno) Software required Arduino IDE - latest version recommended Python 3.8 Schematic MFRC522 RFID reader SDA/ SS - D10 SCK - D13 MOSI - D11 MISO - D12 IRQ - Not connected GND - Ground RST/ RESET - D9 3.3V - 3.3V Push-buttons Submit button - D4 Retrieve button - D5 Coding Arduino For this project, you will be using the following libraries: MFRC522 by miguelbalboa -  https://github.com/miguelbalboa/rfid SP...