The DHT-11 is an environmental sensor converting surrounding temperature and humidity data. It send these data via its digital bi-directional I/O pin. This sensor has only three pins, VCC(+5VDC), Data and GND. Its data pin is an open-drain output that need an external pullup resistor between 4.7kOhm to 10kOhm.
It's very popular due to its low cost and ease of use. Many micro-controller can communicate with this device using its digital I/O pin with software bit-banging for data transmission and reception. Many C compiler including Arduino has a variety libraries for this sensor. CCS PICC also has its driver for communicating with this device using a few line of code. Its new compiler version includes the "dht11.c" driver.
Some good programmers use the Assembly language or even XC compiler to write their own routine communicating with this sensor.
![]() |
| Proteus Simulation #1 |
![]() |
| Proteus Simulation #2 |
Proteus has a model for this sensor that we can easily test our program without wiring all components on breadboard.
- #include <18F4550.h>
- #DEVICE ADC = 10
- #fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
- #use delay(clock=48000000)
- #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
- #define LCD_ENABLE_PIN PIN_D3
- #define LCD_RS_PIN PIN_D2
- #define LCD_DATA4 PIN_D4
- #define LCD_DATA5 PIN_D5
- #define LCD_DATA6 PIN_D6
- #define LCD_DATA7 PIN_D7
- #include "lcd.c"
- #include <dht11.c>
- #define lcd_clear() lcd_putc('\f')
- void main(){
- unsigned int8 relativeHumidity;
- unsigned int8 tempC;
- printf("\n\rPIC18F4550 DIY USB Prototype Board.");
- printf("\n\rWednesday 23 September 2025");
- printf("\n\rDHT-11 Humidity Sensor Example\n\r");
- printf("\r\n\r\dht-11.c - DHT11 example starting\r\n\r\n");
- dht11_init();
- lcd_init();
- lcd_clear();
- printf(LCD_PUTC,"PIC18F4550 LCD\nDHT-11 Example");
- delay_ms(5000);
- lcd_clear();
- while(1){
- dht11_read(&relativeHumidity, &tempC);
- printf("HUMIDITY=%03u%%, TEMPERATURE=%02uC\r\n", relativeHumidity, tempC);
- lcd_gotoxy(1,1);
- printf(LCD_PUTC, "Humidity: %03u%%\nTemperature:%02u%cC",relativeHumidity,tempC,223);
- delay_ms(2000);
- }
- }
PIC18F4450 read, displays the environmental data on LCD and sending it over serial port every two seconds. I use its maximum 48MHz clock frequency to get a precise timing.
![]() |
| Experiment On Bread Board |
This PCB is offered by PCBWay since it's a sponsor project. PCBWay is a long term and well known one-stop service provider including PCB fabrication, PCB assembling (PCBA) etc. Their service and price are reasonable. Beside their standard PCB they offer advanced PCB, flex PCB, CNC parts and 3D printing parts.
Most of PCBs are fabricated within 24 hours with a few days of delivery time. All PCB are checked and verify before sending to fabrication process (pre-production check). Their engineer contact us very soon if their are any problem or doubt.
PCBWay also offer a low cost PCB fabrication of the size 10cmx10cm. We can order it between 5 and 10 units for only 5USD. They are standard double sided PCB with solder mask, silkscreen, circuit testing etc.
For a large scale demand we can order their PCB assembly service at reasonable price for any projects.
Click here to download its source file.






