• How to Connect Water Flow Sensor with Arduino

    06/30/2020 at 09:51 0 comments

    Water management is very important in today’s time to tackle the water crises. Supplying water according to the real requirement is important and thus measuring water is a very essential step in water management systems.  There are many water flow measurement techniques as well as different types of water flow meters used to measure the volume of water flow in pipelines but these all are too costly. Through this guide you will get an ideas for design and development of low-cost with the help of readily-available and low-cost water flow sensors.

    YF-S201 Water Flow Sensor

    Water Flow Sensor, as the name suggests, is a device to measure the flow of water. The Water Flow Sensor used in this project is shown in the image below.

    Accurate flow measurement is an essential step both in the terms of qualitative and economic points of view. Flow meters have proven excellent devices for measuring water flow, and now it is very easy to build a water management system using the renowned water flow sensor YF-S201. This sensor sits in line with the water line and contains a pinwheel sensor to measure how much water has moved through it. There is an integrated magnetic Hall-Effect sensor that outputs an electrical pulse with every revolution. 

    Working of the Water Sensor

    The sensor has 3 wires RED, YELLOW, and BLACK as shown in the figure below. The red wire is used for supply voltage which ranges from 5V to 18V and the black wire is connected to GND. The yellow wire is used for output (pulses), which can be read by an MCU. The water flow sensor consists of a pinwheel sensor that measures the quantity of liquid that has passed through it.

    Basically, the YF-S201 Water Flow Sensor consists of a Flap Wheel (or a Turbine Wheel) that spins when water flows through the sensor. At the centre of this flap wheel, there is magnet fixed. Keeping this in mind, when the water flows through the YF-S201 Water Flow Sensor, the flap wheel spins due to the force of the water and as a result, the magnet attached to it will also spin. As a result, the magnetic field near the Hall-effect sensor switches polarity as the flap wheel spins and the output of the sensor (on the output Pin – Yellow Wire) will be a pulse.

    By keeping track of the number of pulses from the output of the Water Flow Sensor, you can easily calculate the amount of water flowing through the sensor and as a result the Water Flow Rate.    

    Connections

    • Connect the Red and Black wires of the YF-S201 Water Flow Sensor to +5V and GND.
    • Since will be used the Interrupt feature of the Arduino, only Digital I/O Pins 2 and 3 are possible to connect to the Output of the Water Flow Sensor.


    Code

    The code for the Arduino Water Flow Sensor Interface is given below.

    volatile int flow_frequency; // Measures flow sensor pulses
    unsigned int l_hour; // Calculated litres/hour
    unsigned char flowsensor = 2; // Sensor Input
    unsigned long currentTime;
    unsigned long cloopTime;
    void flow () // Interrupt function
    {   flow_frequency++;
    }
    void setup()
    {   pinMode(flowsensor, INPUT);   
         digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up   
         Serial.begin(9600);   
            attachInterrupt(0, flow, RISING); // Setup Interrupt   
         sei(); // Enable interrupts   
        currentTime = millis();   
        cloopTime = currentTime;
    }
    void loop ()
    {   currentTime = millis();   
      // Every second, calculate and print litres/hour   
         if(currentTime >= (cloopTime + 1000))  
     {    
      cloopTime = currentTime; // Updates cloopTime  
        // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.     
       l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour     
       flow_frequency = 0; // Reset Counter      
       Serial.print(l_hour, DEC); // Print litres/hour      
        Serial.println(" L/hour");   }
    }

    The output of the project is to display the quantity of water flowing through the sensor in litres per hour as shown below.

    Since the output of the sensor is a pulse, by calculating the frequency of the pulse, we can...

    Read more »

  • Arduino Based Calculator with Power Boost Module

    06/29/2020 at 12:15 0 comments

    DC-DC converters are widely used in portable electronic devices like mobile phones and laptops and are primarily powered with batteries. These applications consist of many sub-circuits which provide different voltage levels to different modules of the system. Today we will see one of the many projects in which a Boost converter comes in handy.

    Calculators have become very important in todays time. In schools, colleges and even in many offices calculators are regularly used. They can be used to calulate different things and even in different number systems. Isn’t it exciting to have your own calculator? So, do you want to make your own calculator? Well, today you will get an idea on how to build your own basic calculator.

    So let’s get started

    • This project consists of DIY based keypad that works perfectly, an Arduino programmed 328p controller, LCD with I2C module, 3.3v to 5v boost circuit and perf-boards.
    • Let's start with the keypad,
    • Use and solder 8 push buttons which are arranged in such a way that they look like a real Arduino keypad.
    • Use a male Berg connectors that can act as a jumper and also it acts as a conductor.
    • These connector pins are connected to the Atmega 328p microcontroller with the help of L-shaped male headers. As you can see in the above photos that four pins act as rows pins while the other four pins act as columns.
    •    Now, let's discuss the mainboard. The mainboard consists of a micro-controller, a 16Mhz crystal oscillator, two 22pF non-polar capacitors, an I2C connector for LCD and a boost circuit as shown in the circuit below.
    • As for the LCD, the I2C module is directly soldered on the LCD PCB, and there is no gap between them.
    • The mainboard is powered by the 3.3v LiPo battery, the boost circuit converts the low voltage to the high voltage since there is the potentiometer connected on the boost circuit which varies the voltage at the output.
    • So by varying it, the voltage can be changed, this micro-controller only requires about 5V, so the voltage is varied to 5V on the output. This voltage is also supplied on the I2C module this turns on the LCD.

    4.      The I2C module on the LCD consists of four pins which are connected in the following ways:5V -------- 5V (output of boost circuit)

    ·        GND ---- GND (output of the boost circuit)

    ·        SCL ------ A5 (SCL of Atmega 328p) Arduino

    ·        SDA ----- A4 (SDA of Atmega 328p) Arduino

    Code

    Write the code in the Arduino platform and see if the calculator works

    #include <LiquidCrystal_I2C.h>

    #include <Keypad.h>

    LiquidCrystal_I2C lcd (0x27, 16, 2);

    const byte rows = 4;

    const byte cols = 4;

    char hexKeys [rows][cols] = {

      {'1', '2', '3', 'A'},

      {'4', '5', '6', 'B'},

      {'7', '8', '9', 'C'},

      {'*', '0', '#', 'D'}

    };

    byte rowPins[rows] = {4, 5, 6, 7};

    byte colPins[cols] = {0, 1, 2, 3};

    Keypad kpd = Keypad (makeKeymap(hexKeys), rowPins, colPins, rows, cols);

    long number = 0;

    char dynamicKeys;

    String string = "";

    boolean enterkey_state;

    boolean binButton_state;

    boolean hexButton_state;

    boolean octButton_state;

    boolean decButton_state;

    void setup()

    {

      lcd.begin();

      lcd.backlight();

      lcd.clear();

      lcd.setCursor(0, 0);

      lcd.print("Initializing");

      for (int i = 12; i <= 16; i++)

      {

        delay(200);

        lcd.print("*");

      }

      delay(3000);

      lcd.clear();

      lcd.setCursor(0, 0);

      lcd.print("Digital");

      lcd.setCursor(0, 1);

      lcd.print("Calculator");

      delay(3000);

      lcd.clear();

    }

    void loop()

    {

      enterkey_state = false;

      binButton_state = false;

      hexButton_state = false;

      octButton_state = false;

     ...

    Read more »

  • How to make DIY Power Bank 18650 LiPo Charger

    06/27/2020 at 06:37 0 comments

    In recent years, the use of power banks has risen significantly as they provide a very convenient and easy method of charging smartphones and other devices when away from mains power. Wireless charging power banks have also been introduced for those devices that can be charged wirelessly. 

    But have you made a power bank? Well, you can now. With the help of DIY 18650 Lipo charger (refer the image) you can make your own power bank at your home. In this guide you will get to know how to make your own power bank at home with the help of a few electronic products.

    What is a Power Bank?

    Power bank is a battery pack which is used to charge a cellphone outdoors during emergency situations when an AC outlet is unavailable for charging the cellphone.

    Power bank modules have gained significant popularity today due to their portability and ability to charge any cell phone while traveling and during emergency requirements.

    It is basically a battery bank box which is initially fully charged by the user at home, and then carried outdoors while travelling. When the user finds his cellphone or smartphone battery reaching low, he connects the power bank to his cellphone for a quick emergency topping-up of the cellphone.

    Ways of making a Power Bank with 2 Li-Ion Cells

    The first circuit above makes use of a common collector transistor configuration for charging the intended cellphone device, the 1K preset is initially adjusted to enable a precise 4.3V across the emitter of the transistor.

    The second design above uses a 7805 voltage regulator circuit for implementing the power bank charging function.

    The last diagram here depicts a charger design using an LM317 current limiter. This idea looks much impressive than the above two since it takes care of the voltage control and the current control together ensuring a prefect charging of the cellphone.

    The battery is to be connected to the motherboard B + negative-, installed against the necessary burning motherboard.

    Thus you can make your own power bank with the help of Lipo charger Module. This module also has an LED Lamp display power which shows if the circuit is working or not. If the circuit is not working then the Lipo charger automatically shuts down to avoid loss of power. See more of this module and try making your own power bank.

    This guide was written in reference to the blogs published by homemade-circuits.com