Humidity and temperature sensor demo board

Humidity and temperature sensor demo board
Humidity and temperature sensor demo boardHumidity and temperature sensor electronic board
5 5 5 Product


Here, we present a SHT21-based humidity and temperature sensor demo board. This project started when the Author was trying to build an electronic thermostat and hydrostat for controlling temperature and relative humidity inside the enclosure of a homemade Egg-Incubator machine.  

The SHT21 IC from Sensirion, is a superior digital humidity and temperature sensor. SHT21 communicates with I2C protocol and Sensirion provides an exemplary sample code on its home page for interfacing SHT21 on an NEC V850/SG3 (uPD70F3740) controller. In our project, we use a PIC18F2620 microcontroller. So, we ported the example code to run on a PIC. Following the instructions provided from Sensirion, porting was quite easy.

Author: G. Adamidis

Creative Commons License
Humidity and temperature sensor demo board by George Adamidis is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.


Humidity and temperature sensor demo board hardware

Our board could be considered as a PIC based demo board for SHT21 humidity and temperature sensor. Temperature and relative humidity are displayed on a 2x16 character LCD and we have included a common RS-232 serial port in our hardware, in case anyone needs to export data to a PC. We have also included a 4-buttons keyboard and a 4-bit IO port, in case anyone wishes to add user-interface or control a relay, an alarm etc. The complete electronic schematics and PCB details are provided in the download section.

The board has a 7805, 5V linear regulator and can be powered from 9-15V DC. The PIC microcontroller is powered directly from the 5V linear regulator. However, the supply voltage of the SHT21 must be in the range of 2.1–3.6V (recommended supply voltage is 3.0V). So, we use some silicon diodes to drop down the voltage from 5V to the 2.1–3.6V range. Additionally, in order to ensure voltage compatibility between PIC and the SHT-sensor I2C interface we use some pull-up resistors and a special interface – implementation strategy (which is using pull-down for zeros and floating for 1s).   

Special effort has been made to mount SHT21 in a way that prevents heat transfers from other electronic components in the same PCB. To achieve that, we tried to reduce copper between the sensor and the rest of the PCB and we have reserve some space for milling a slit into the PCB around the sensor. 


Humidity and temperature sensor demo code

We provide demo code and firmware for a demo humidity and temperature sensor application. The code is written for an easy understanding and is neither optimized for speed nor size. We keep measurement frequency low to prevent self-heating effects of the sensor.

There are demo routines in our code for displaying temperature and humidity and also for keyboard control (for just sending some demo messages in the LCD, at every time any key is being pressed),; however, we do not provide any routines for the RS-232 interface. You must write your own code if you wish to add any data exporting capabilities using the serial port.

Due to compatibility reasons (voltage compatibility and portability) we use the recommended strategy from Sensirion in our code, which is the implementation of the I2C interface as “bit-banging” on normal I/O. 


Suggestions for improvements

Everyone interested in PIC programming and embedded systems should find some value in this project, and an effort has been made to provide a demo board and sample code for humidity and temperature sensing applications. There is always much room for improvements and new ideas regarding this project and we welcome anyone who wishes to post any new code, hardware ideas or just wishes to send feedback. Suggestions for improvements will be gratefully received by the Author as well as our readers and members. ? Please,  send your suggestions via e-mail or submit an article.


Electronic schematics, PCB artwork, firmware and source code

Here, we provide the complete electronic schematics,  PCB details, firmware and source code for the humidity and temperature sensor demo board.

Electronic Schematic - Main circuit
Electronic Schematic - RS232 interface

Excluding the SHT21, we use only through hole components.
All components must be placed on the top-side of the board except for the SHT21 which must be soldered on the bottom layer. All resistors are of 1/4W -5% type. We use a double-sided printed circuit board with metal-plated holes. However, you could build the PCB without using any plating. In that case, you should solder some components on both sides.  

Click to download the complete PCB Artwork (paid download).
Composite drawing - Assembly instructions

You will need a PIC programmer in order to program the PIC18F2620 microcontroller. In our project, we have used the MPLAB ICD 3 In-Circuit Debugger - programmer from Microchip.

Source code in C and .hex file

List of the comments:
No comments have been posted yet.
You must be registered in order to post a comment