Поиск по этому блогу

суббота, 14 ноября 2015 г.

Weather station: Chibios, stm32f051, bmp180, DHT11 sensor and 1.3 OLED sh1106 display

Although I am an electronic engineer, periodically I want to spend my time constructing some fancy devices for home. Last weekend's project was a Meteorology station - I really need to know the temperature, pressure and humidity in my apartment!

So, the first thing to do - decide what hardware platform fits well. I choose STM32F051 MCU (it's really cheap and powerful enough for my modest needs). The compiler should be arm-none-eabi-gcc, RTOS - Chibios, graphical engine - uGFX.
The other thing to deal with - its sensors! Well, let's forget about analogue sensors. All we need are modern digital devices! I personally hate calibration, because it's too tedious to tune every sensor individually.
BMP180 Sensor

DHT11 Sensor
So, I've selected Bosch Sensortec's bmp180 sensor for temperature and pressure. For the humidity I've selected a cheap Chinese DHT11 sensor. Maybe this was a mistake, because it was not easy to make it work properly.

To show the information it has a 1.3' OLED display. BMP180 is I2C sensor, and the display uses this bus as well. The DHT11 sensor uses it's self-brew protocol, quite tricky for implementation with any RTOS, because you have to use micro-secondary delays to get data.

The schematics are quite simple:
The PCB layout is simple too.

The only mess I had was that I routed the DHT11's data line to the PB2 pin of the MCU. This pin unable to perform a ICU (interval capture unit) feature :( So, I had to implement sensor reading using a conventional the GPIO port function. Here there is an example of how to use this hardware feature with a DHT11, but due to already-produced PCBs I can't use this approach.
So, I grabbed my logic analyzer and ran it with Sigrok. I was happy to find that the latest Sigrok has an embedded decoder for the DHT11 protocol!


Okay, the code has been uploaded to github. Enjoy!




Комментариев нет:

Отправить комментарий