Atmega8 measures ambient temperature and relative humidity using HSM-20G sensor. Part 2. Software

Part 1. Schematic


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:

China PCB Prototype and Fabrication Manufacturer

  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.

Atmega8 measures ambient temperature and relative humidity using HSM-20G sensor


Source Code and HEX files of this project - download

You may have to register before you can post comments and get full access to forum.
User Name