rain sensor HL-83 HL-01

Published Jun 19, 2024
 1 hours to build
 Beginner

This project tests the rain sensor commonly available in market known as HC-01 or HC-83

display image

Components Used

Atmega32
Atmega32
1
Connecting Wire Jumper Wires
Connecting Wire Breadboard wires
1
CP2103 USB TO UART BRIDGE
CP2103 is single chip USB to UART Bridge. It supports USB 2.0 protocol.
1
Rain Sensor
1
Description

Rain sensor with ATMEGA32a.

 

Rain sensor comes with a driver, specifically providing Analog as well as Digital output pin.

The values of analog pin varies in accordance with the Vcc voltage.

Make sure to turn off Pullup resistors for digital pin. The digital output is active low i.e. it will go low, as soon as rain will be detected. 

In our project we specifically read analog values and displayed it on serial monitor using usart (Arduino serial monitor (9-bit mode)).

The controller in play is Atmega32a, which is again programmed in Atmel studio. Also a seperate usart module is used for communication.

The pins are connected as follows: 

Pins (module)Pins (Controller)
A0PORTA - 0
D0PORTC - 0
GNDGnd
VCCVcc

connection for UART module are as follows:

Pins (UART module)Pins (controller)
TxPORTD-1
RxPORTD-0
VccVCC
GndGND

 

The code of the program is as follows:

#include <avr/io.h>
#include "libs/uartlib/uartlib.h"
#include "libs/adclib/adclib.h"

int main(void)
{
	adc_init(2);
	UART_init(9600);
	
    while (1) 
    {
		char tmp[20];
		//char tmp2[20];
		
		dtostrf(adc_read(0),0,0,tmp);
		UART_SendString("rain range : ");
		UART_SendString(tmp);
		UART_SendString("\n");
    }
}

Codes
Comments
Ad