MainRegistrationLogin Electro-Hobby Friday, 03.05.2024, 16:44
  Circuits Welcome Guest | RSS

Search

Statistics

Total online: 1
Guests: 1
Users: 0

 
 Home » Tests and Measurement » Atmega8 measures ambient temperature and relative humidity using HSM-20G sensor
21:54
Atmega8 measures ambient temperature and relative humidity using HSM-20G sensor    



Simple device, for measuring temperature and humidity.








The circuit diagram is pretty simple. The two ADC channels (ADC0 and ADC1) of Atmega8 are used to measure the sensor output voltages that correspond to the ambient temperature and relative humidity. The two resistors and a capacitor connected to the output lines of the HSM-20G sensor are recommended in its datasheet. The results are displayed in a 4×20 character LCD.




Software

The firmware for this project is developed with MikroC Pro for AVR 5.00 compiler. The program is very simple and straight. There are six function other than the main function. These are described below briefly:

1. void setup_MCU() This function setups the micros peripherals for optimum operation by setting up individual buil-in peripheral registers and library function of the MikroC for AVR compiler. In this case the ADC and LCD libraries are used.

2. void display_common() This function simply displays the texts "Temperature” and "Relative Humidity” along with their units. Since there is only one screen, it’s called only once.

3. float read_voltage(unsigned short channel) This function read the ADC channel specified to it and takes the average of 64 ADC samples. This helps to reduce noisy A/D inputs and enhance precision. The result after doing all the maths is returned to the calling function.

4. float read_humidity() and float read_temperature() These compute relative humidity and temperature data using their equations and ADC data, and prepare for display.

5. void display_data(unsigned char x, unsigned char y, float value) This function specifies the location of the display and what to show from the acquired data.

Category: Tests and Measurement | Views: 1854 |
 
 
Advertising

 

Copyright MyCorp © 2024
Free web hostinguCoz