top of page
Writer's pictureRamesh G

Water Level Depth Detection and LED control with Bluetooth HC-05


In this article, we’re going to do an Arduino based water level depth sensor and (PWM) LED brightness control and interface with HC-05 Bluetooth module for Graphical representation using android mobile application and LCD display for Sensor dipped in water level data print.

Circuit Diagram


Components Required

Arduino Uno - 1 no

LCD16x2 I²C - 1no

Bluetooth module HC-05 - 1no

water level sensor K-0135- 1no

LED - 1no

Water Level Sensor

Water sensor brick is designed for water detection, which can be widely used in sensing the rainfall, water level, even the liquate leakage. The brick is mainly comprised of three parts: An Electronic brick connector, a 1 MΩ resistor, and several lines of bare conducting wires. This sensor works by having a series of exposed traces connected to ground and interlaced between the grounded traces are the sense traces. The sensor traces have a weak pull-up resistor of 1 MΩ. The resistor will pull the sensor trace value high until a drop of water shorts the sensor trace to the grounded trace. Believe it or not this circuit will work with the digital I/O pins of your Arduino or you can use it with the analog pins to detect the amount of water induced contact between the grounded and sensor traces. This item can judge the water level through with a series of exposed parallel wires stitch to measure the water droplet/water size. This High Sensitivity Water Sensor can easily change the water size to analog signal, and output analog value can directly be used in the program function, then to achieve the function of water level alarm. This item have low power consumption, and high sensitivity, which are the biggest characteristics of this module. The High Sensitivity Water Sensor can be compatible with Arduino UNO, Arduino mega2560,Arduino ADK etc.

However, one commonly known issue with these sensors is their short lifespan when exposed to a moist environment. Having power applied to the probe constantly speeds the rate of corrosion significantly. To overcome this, we recommend that you do not power the sensor constantly, but power it only when you take the readings

The working of the water level sensor is pretty straightforward.

The series of exposed parallel conductors, together acts as a variable resistor (just like a potentiometer) whose resistance varies according to the water level. The change in resistance corresponds to the distance from the top of the sensor to the surface of the water.

The resistance is inversely proportional to the height of the water:

  • The more water the sensor is immersed in, results in better conductivity and will result in a lower resistance.

  • The less water the sensor is immersed in, results in poor conductivity and will result in a higher resistance.

The sensor produces an output voltage according to the resistance, which by measuring we can determine the water level.


Features :

  • Working voltage: DC5V

  • Working Current: <20ma

  • Interface: Analog

  • Width of detection: 40mm×16mm

  • Working Temperature: 10°C~30°C

  • Humidity: 10% -90% non-condensing

  • Arduino compatible interface

  • Low power consumption

  • High sensitivity

  • Output voltage signal: 0~4.2V

Pin definition :

  • "S" stand for signal input

  • "+" stand for power supply

  • "-" stand for GND

Applications :

  • Rainfall detecting

  • Liquid leakage

  • Tank overflow detector

Bluetooth HC-05:

HC-05 is a Bluetooth module which is designed for wireless comunication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth.


It has 6 pins,

1.Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode.

HC-05 module has two modes,

  • Data mode: Exchange of data between devices.

  • Command mode: It uses AT commands which are used to change setting of HC-05. To send these commands to module serial (USART) port is used.

2. VCC: Connect 5 V or 3.3 V to this Pin.

3. GND: Ground Pin of module.

4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin)

5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth module).

6. State: It tells whether module is connected or not.


HC-05 module Information

HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds.

This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator.

As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module.

HC-05 Default Settings

  • Default Bluetooth Name: “HC-05”

  • Default Password: 1234 or 0000

  • Default Communication: Slave

  • Default Mode: Data Mode

  • Data Mode Baud Rate: 9600, 8, N, 1

  • Command Mode Baud Rate: 38400, 8, N, 1

  • Default firmware: LINVOR

Installing the Arduino Library

LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library.

Follow the next steps to install those libraries.


In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.


After installing the required libraries, copy the following code to your Arduino IDE.


Mobile output


Subscribe and Download code.

Download Android application.

Final result:



Arduino Code:

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);


// These constants won't change. They're used to give names to the pins used:

const int analogInPin = A0; // Analog input pin that the potentiometer is attached to

const int analogOutPin = 9; // Analog output pin that the LED is attached to


int sensorValue = 0; // value read from the pot

int outputValue = 0; // value output to the PWM (analog out)

int Level = 0;

void setup() {

// initialize serial communications at 9600 bps:

Serial.begin(9600);

pinMode(analogOutPin, OUTPUT);

lcd.init(); // initialize the lcd

// Print a message to the LCD.

lcd.backlight();

lcd.begin(16, 2); // set up the LCD's number of columns and rows:

}


void loop() {

// read the analog in value:

sensorValue = analogRead(analogInPin);

// map it to the range of the analog out:

outputValue = map(sensorValue, 0, 750, 0, 255);

Level = map(outputValue, 0, 255, 0, 100); // calibrated value

// change the analog out value:

analogWrite(analogOutPin, outputValue);


// print the results to the Serial Monitor:

// Serial.print("sensor = ");

// Serial.print(sensorValue);

// Serial.print("\t output = ");

// Serial.println(outputValue);

Serial.println(Level);

lcd.setCursor(0,0);

lcd.print("LEVEL DETECTION ");

lcd.setCursor(0,1);

lcd.print("Dipped: ");

lcd.print(Level);

lcd.print(" %");

lcd.print(" ");

// lcd.setCursor(0,1);

// lcd.print("PWM: ");

// lcd.print(outputValue);

// lcd.print(" ");

// wait 2 milliseconds before the next loop for the analog-to-digital

// converter to settle after the last reading:

delay(500);

}


MIT Block for mobile application.



Recent Posts

See All

Comments


bottom of page