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) |
A0 | PORTA - 0 |
D0 | PORTC - 0 |
GND | Gnd |
VCC | Vcc |
connection for UART module are as follows:
Pins (UART module) | Pins (controller) |
Tx | PORTD-1 |
Rx | PORTD-0 |
Vcc | VCC |
Gnd | GND |
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");
}
}