You are on page 1of 4

Entry nr.

AT2942

Circuit Cellar / Atmel AVR 2006 Design Contest


Registration Number: AT2942
AVR microcontroller: ATtiny45
Abstract

Tiny Gas Detector


A simple project to build a smart gas alarm fully controlled by the Atmel ATtiny45 chip

1 Overview
Gas sensors are employed in a wide range of applications in the fields of safety, health, instrumentation
etc... Common examples are domestic/commercial alarms for explosive or toxic gases, or in automotive
application as gas leakage detectors for LPG powered cars and exhausts detectors inside any fuel-
powered truck/car. Such sensors, nowadays, are found also in applications involving air quality control
systems and pollution monitoring.
Today’s sensors, while featuring a high sensitivity to a wide gases variety, are very compact in size and
have significantly reduced their power consumption to better adapt to portable solutions.
Building a system with a gas sensor is not as easy as it could appear. Despite the sensor could be
treated, basically, as a variable resistor (which value depends on gas concentration in air) the practical
implementation in a project should be done considering some design rules, especially if the final circuit
is a device to be used in a field where reliability is strongly required (e.g. safety). As an example the
internal elements of a sensor (heater and gas sensitive resistors) have to be constantly kept under
control to avoid failures leading to a wrong alarm indication; furthermore, if the application needs to
achieve a good measurement accuracy, factors like environment temperature, sensor life etc... have to
be taken into account.
All those features and controls require to introduce in the project a certain amount of external circuitry
(including components like comparators, temperature sensor, spare logic etc...) to carry out functions
such us temperature compensation, sensor heating control, sensor warm-up time, sensor life time check
and so on...
This project aims to show how can a small microcontroller such as the little AVR ATtiny45 can be
employed to replace a lot of external components while adding extra functionalities at a cost
comparable as a simple integrated comparator.
The final circuit results very compact in dimensions, cost effective but at the same time very
flexible in applications and functionalities. In fact, the use of an AVR microcontroller makes easy
the possibility of the project to be modified and adapted to several sensor types and application areas.

In the prototype that I am going to present, the hardware and microprocessor firmware have been
optimized to implement a smart LPG gas alarm (LPG stands for Liquefied Petroleum Gas) for
domestic or automotive use. Main features implemented here are:
• full sensor parameters control for maximum reliability;
• temperature compensation for better measurement accuracy;
• six steps of gas alarm levels with Led and acoustical indicators;
• store of “maintenance” parameters in a non-volatile memory (tiny45 internal eeprom);
• logging of any alarm and failure events (all stored data can be transferred via RS232 serial
interface).
Entry nr. AT2942

Picture 1: the prototype ready to be tested

2 Block diagram

Picture 2: block diagram


Entry nr. AT2942

3 Schematic diagram

Picture 3: Schematic diagram

The circuit is quite simple: the gas sensor, the ATtiny45 chip and a voltage regulator are the main parts;
the board is completed by only few, discrete parts and some passive components. The prototype has
been assembled on a small piece of thru-hole breadboard.
Entry nr. AT2942

4 Software at a glance
Code has been written, compiled and simulated under the AVR Studio 4 environment and using the
WinAVR GNU C compiler (GCC version 3.4.5). Here following is a short sample of the code showing
the sensor initial warm up procedure, before the main program loop execution.

Picture 4: Sample of the C program

You might also like