Giandomenico's page
home

Tempgas: a temperature, humidity, gas sensor beacon project


About:


This project is for a temperature, humidity and gas BLE beacon. The beacon form is useful to broadcast the sensor values without any need to a direct connession. So more clients can receive data: smartphone, desktop, notebook.
The core circuit is a very simple PCB using a Microchip Pimicro 16F88 microcontroller, using internal oscillator. So it has very few external components, although the PCB has terminals to attach external oscillator, if required. The microcontroller is connected by wire to a MQ-2 methane/CO2/smoke gas sensor, a DHT22 temperature/humidity sensor, and an HM10 Bluetooth low energy (BLE) module, to act as a BLE beacon.
An optional serial LCD could be attached to display locally the sensor data. Why a Pic 16F88? Because it's small but powerful, and includes many peripherals, about them a ADC converter needed for MQ-2. It can be programmed using a serial bootloader. The firmware is written in very good Mikroelectronica MikroPascal. The circuit and PCB is designed by very good circuit designer program Kicad.

Short description:


The 16F88 read sensors in a cycle of about 5,5 seconds.
In every cycle, first it read MQ-2 sensor using the ADC converter. Then read the DHT22 sensor. It's a bit tricky, because the DHT22 use a proprietary one wire protocol, and the 16F88 internal clock of 8mhz is not very fast, compared to the speed of protocol signals. The gas value, read from MQ-2, and temperature and humidity, read from DHT22, are then packed in the major/minor field of HM10 board (HM10 has to be separately prepared as a beacon). The temperature value is written to minor field. The gas value is rounded and stored in most significant byte (MSB) of major field; humidity is rounded and stored in less significant byte (LSB) of major. The HM10 major/minor fields are written using the 16F88 hardware serial interface. Optionally the data could be written to a locally wire connected LCD, by a lightweight software serial library using a general I/O pin.
The 16F88 can be programmed directly, or using a bootloader. I used successfully Tiny Multi Bootloader+

Tempgas circuit


Tempgas pcb
The PCB is designed as a general purpose board for 16F88. So there are: external connectors for all micro pins; four connectors to power external devices; a serial connector with power, especially for HM10; a connector to attach an external oscillator, if required; a reset button; a power switch.
The board is powered by an external 5v source by a micro USB 2 connector; today it's standard for many power banks and USB power supplies.

In next photo the entire circuit is assembled inside a standard electrical box. An external serial LCD is connected by wire.


Tempgas 1


Tempgas 3



 

Mail contact