Angle ViewFront ViewSide view

 

ThermometerV2.0 is coming to replace in hardware and software V1.0.

Introduction

I designed this version in the need of a thermometer for my room, built in a small pack and easy to control. The hardware is designed on a way so that the pcb can be wall mounted. At the top side of the device the PCB extents giving space for two keyhole type holes which are able to keep the device mounted on the wall. The LCD display plugs at the front side of the PCB, covering all the electronic components and giving a compact design view. The user can interact with the device using the left side switch button. The design includes a 6-pin header which gives connectivity for UART (RX,TX,GND) and for the external sensor DHT-11 (VCC,GND,DATA). Also there is an ISP-6 pin header which gives the option of on board programming. Finally there is an optional Bluetooth plug on the back side connected with AVRs UART for possible communication to other devices like mobile phones, home automation devices, pc's or whatever you imagine.

The code is written in C and is well performed in a readable way so anybody can read and modify it. For the LCD driving i have used Peter Fleury's library.

Function Modes

Display modes:
 1)Celsius
 2)Fahrenheit

Backlight modes:
 1)Fast mode (press the button, light on, 2 seconds delay, light off)
 2)Light switched off
 3)Light switched on

Hardware description:

The power supply

The power supply is a basic LM7805 power supply using two pair's of decoupling capacitors before and after the regulator. Additionaly can be used the AMS1117 regulator at 3.3V. This regulator is included in the design to give the option of using a Bluetooth module which usually work at 3.3V.

The LCD HD44780 16×2 Char

A 16×2 character LCD display is used to display data to user. The only thing that somebody may not understand here is the use of BC547. BC547 is used as a switch to switch on/off LCD's back light or to pulse it using PWM adjusting the back light lightness and giving nice fading options. R3 is used to limit the current flow to transistors base, and R1 is there to pull down base voltage.

Main Brain Atmega8

The main brain of this device is Atmega8.

Note. A 16Mhz crystal has been used instead of 8Mhz shown on the schematic in order to read DHT data easier.

Peripherals

Above are the peripherals used. From left to right,

  • The Bluetooth module, this module is optional. It is connected to avr's uart so everything in UART can be sent via Bluetooth. For example it can send the sensor reading on a pc, a mobile phone, e web server.
  • The DHT-11 sensor is used for outside humidity and temperature measurement. It has a 5k pull up resistor to Data pin to pull data bus to VCC and a 100nF decoupling capacitor to filter noise
  • Including an ISP header on the design makes it easy to update the software and debug on board.
  • For inside temperature sensing has been used the LM35.
  • A button is used to interact with the user. This button is pulled up with avr's internal pull up resistor and is connected to INT0 interrupt pin.
  • Also there is a UART pin header for optional module installation or for serial connection to PC.

More photos:

The PCB Board:

Pcb Board Front Side Pcb Board Back Side

From Design to reality

PCB Design Pcb Board Front Side Soldered

The back side of the PCB and all the parts nedded for this project.

Pcb Board Back Side All components for this project

While testing the Hardware and the Software on breadboard proto.

The final device view.

 

Sending sensor readings over Bluetooth.

 

The source code can be found here:

DOWNLOAD HERE

 

Related Posts

81 thoughts on “Thermometer V2.0

    1. Thank you for your comments!
      1. Yes you can, as your Computer/Mobile can communicate with 6 different wireless modules at the same time. If all of 6 modules work at the same time you have to configure each one to play in different channel in order not to corrupt each other.
      2. The bluetooth footprint i used is for the most used uart to bluetooth modules and you can find them on ebay or in most of the electronic shops. For example a random image of one is http://img.alibaba.com/wsphoto/v0/442789372/Bluetooth-RS232-UART-TTL-Transceiver-Module-wireless-CONVERTER.jpg
      There is also a UART pinout on the PCB so you can connect there a module with a different footprint or just solder some cables and make a hack 😉  Also you can connect it with a PC using RS232 cable and a UART to RS232 converter like MAX232.
      There is no SPI  pinout for the module you posted. You can use any module uses UART. For easier installation choose one with the same footprint as the one on the board.

      1. Great thanks for the quick response! Lets make some! Hope I can get some PCBs from our Chinese friends before their holiday! 🙂

    1. Yes you can. But you have to modify the code. There are two output pins used for USART communication. These can be used for other purpose as well like output pins. In a compination with a homemade board consist of transistors and relays you can control any thermostat or other device you want.

  1. Hi sir/madam 
    can you peasels send me the source code to interface at89s51 with dht 11 sensor please ?

  2. Hi!
    Got all the parts and PCB's today, I soldered one, I have it now connected to my flasher, but all of a sudden I realised I don't know how to set the fuses for this firmware. btw I'm using a Atmega88PA is that a problem?
    Thanks!
     
    Ramon

    1. Hello! Firstly i would like to thank you for your interest about my project. You have to use 16Mhz crystal in order to, the avr can buffer and decode the DHT-11s bits. So the only fuse you have to enable is Ext. Crystal/Resonator High Freq.; Start-up time:258 CK + 4ms; [CKSEL=1110 SUT=00] to support 16Mhz crystal. This is the fuse for Atmega8 check if it is the same for Atmega88. Atmega88 is a new mcu with same footprint as Atmega8 and most functions in common.

      1. Hi thanks, sorry for the noob questions, but could you please specify the fuses in Extended, High and Low, I use AVR Studio. My fuses ar now:
        EXTENDED: 0xF9
        HIGH: 0xDF
        LOW: 0x4E
        Is that correct? 
        Thanks!

  3. Hmm the Atmega88 is a bit different from the Atmega8 I guess, there are no options for a high speed ext. cryst. the thing I think I have to select is:
    Do I need to uncheck the CKDIV8 option you think? it is also new with the Atmega88.. 🙁 I hope the code will work on this chip..

  4. Hmm no luck so far, I have flashed the firmware and set the fuses as you said. But when I plug in the power all I get is the upper row lights up with all white blocks and the backlight stays off. It stays like that until I unplug the power.. 🙁

    1. Well, if you just set the power on the LCD without sending any commands the upper row lights. The backlight lights with pwm which switch’s Q3 BC547 which has a pull down resistor on the base pulling the base voltage low if nothing is sent, so the backlight stays off. In other words your avr may not working. If you can give it a try with Atmega8. I don’t know what exactly are the deference between these two MCU’s. Search for which fuses you have to burn to make Atmega88 work with a 16Mhz crystal.

      1. I have ordered a Atmega8 so I can see if that is the problem, I guess so.. Will let you know when I got another board up and running.

        1. I will be waiting for photos and comments 🙂 But it should also work with atmega88. I think your problem is  the fuses. You haven't burned the correct to make the mcu work at 16Mhz.

        2. I just read Atmega88's datasheet which says:

          For 16Mhz Crystal

          CKSEL3..1 : 111

          12-22pf Capacitors

          So try this:

          Low 0xEE High 0xDF Ext 0xF9

          This also selects start up time 1K CK / 14CK

          1. Thank you for helping out here! I tried it, but no luck! I rechecked all my soldering, changed the crystal to be sure.. but nothing.. Just to be sure, I used a 1.5Kohm resistor instead of 2Kohm for R3 and a 4.7Kohm resistor instead of 5Kohm for R2, for the transistor BC547 I used a BC847 what to my knowledge is the SMD version of the BC547. Do you see any problems here?

          2. Nop.. but i can not imagine what is going wrong. Make sure you have connected the AVR correct not upside down and check the voltages at pins VCC VSS etc to see if voltages are correct. They suppose to be 5V for VCC 0 for VSS or GND.

            The input voltage has to be not less than ~7Volts.

  5. Great! Got my Atmega8 in today, soldered a new PCB and this one works great!! The only thing is the contrast is not so good, I can hardly read the text on the display. I have soldered a bluetooth module on it, and try to read data from it on my MacBook Air, can you tell me what terminal program you use and what speed I need to select for the serial port?
    Thanks!

    1. Yes you have to configure the contrast. What i did, i found the contrast resistor on the LCD and changed it on a value that it had good contrast on 5Volt. This resistor depents on the manufacturer. When i first tested the circuit (before designing the PCB) i used an older order LCD and it worked fine whithout the need of an external resistor to adjust the constrast. After i ordered new LCDs and tested the contrast wasn't good so i changed the resistor as i told.

      For the communication i used the screen program (it is pre installed on Mac OS). First you have to pair your bluetooth device from bluetooth preferences and then you would be able to see the device under /dev. My device name is  /dev/tty.linvor-DevB . So you just write screen /dev/tty.linvor-DevB  and you wait for the thermometer to send the values.

      Screen works under terminal. So open a terminal and write the commands 😉

      When you have it ready post photos on flickr to see your work 🙂

      1. Hmm strange, I'm not very lucky in this project I guess 🙂 I did as you said, the device name is different here, but that's because I changed it. I also changed the baudrate to 115200 maybe that is what's going wrong, but whatever I do I don't see any output. I see the device gets connected when I do the screen command, but then nothing happens.
        Also, can you please tell me what resistor you changed, I have the exact same LCD as you have on your pictures so I think I can change the same resistor, and what value did you change it in to get a good contrast?

        1.  

          You need nothing to change to make it work. Just pair the device and leave the baud rate as it is i think default value is 9600. The thermometer sends the read values every 30 seconds so you have to wait a little. 

          Well i don't know if you are that lucky with the LCD. You have to have the exactly same lcd as mine to change the specific resistor. All modules are the same in a quick look but the circuit is different. Here i posted a photo with the two LCD modules and the resistor you have to change. The resistor marked with red is 0k resistor and must be replaced with a 3k3 resistor or a 332 SMD to work correctly with Vcontrast pin grounded. The second LCD in the photo works properly as it is.

           http://www.flickr.com/photos/developthefuture/6838100149/

           

          1. With the LCD I'm that lucky 🙂 I think we bought from the same ebay seller 🙂 The contrast is great now! as for the bluetooth still no go.. I get data from the UART port wired to the PC, but with bluetooth it is a no go, I think because I have set the bluetooth module to connect on 115200 some time ago, but I can't set it back now because it is soldered on the back of the thermometer 🙂
            Maybe if I set the baudrate in code to 115200 that will work, but where did you compile your sources in? in AVR Studio 4? Because I get all sorts of strange errors..

          2. I compiled on Mac os using avr-gcc. Have you changed the baud rate that bluetooth sends or receives? If you have changed the baud rate the bluetooth sends you can easily change screens baud rate writing screen /dev/tty.linvor-DevB 115200. If you have changed the one that receives change the code.

  6. Hello,

    first I want to thank you for providing this project.

    I have a little question, can I use the sensor SHT25 or SHT75 in this project?
    Many tanks.

      1.  
        Hello,
         
        Ok, I found another sensor to the specs I want (DHT-22) 🙂
         
        Can I use a 9V battery in this circuit? With your experience in this circuit can you tell me how long the battery would last?
         
        Sorry for this noob question, but that's just what I am, I'm learning 🙂
        Many thanks.

        1. Hello,

          Well you can use a battery if you want but i wouldn’t recommend it. The LCD draws enough current to discharge the battery fast. The total current draw is 30mA with the LCD backlight on and about 25mA with the backlight off.

          If you use a 9V 500mah battery you will have 500/25 = 20h ~ a day 😛

          There is no noob question 🙂

          Thank you for your interest. Have you built any of these?

          1. Hello again,
            Yes, I will build an equal but with DHT-22. This week I'll buy the parts and start putting together 🙂
             
            when I have pictures I put here 🙂
             
            Many thanks.

  7. What a great project.

    Its EXACTLY what i have been looking for to get into electronics (I am a mechanical engineer).
    One question i have is do you have your schematic in PDF format? Or what tool did you use to create youre .sch? I ask as Orcad wont open it.
    Cheers!

      1. Strange. Eagle 6.1.0 states its not eagle and i cannot open it.
        If you have a PDF that would be great. If not i will try anotehr route.
        Cheers!

  8. Nice description for using a DHT11 and Atmega8 microcontroller ans also very nice hardware. I like the wall mounted PCB very much. I also have a DHT11 on an uC (Arduino), but in combination with xbee that sends data to another uC that sends it to Pachube. I understand your hardware but not the weather. I mean can you read if it’s rainy/dry/cloudy/sunny? 

  9. Could you tell me the function of the pull up resistor connected to the data pin of DHT11? Why do we need it? What happens if we remove it?

    1. Well if you read DHT-11’s datasheet you can see that DHT communicates with one wire protocol. What does this mean? That only one wire is needed for data transfer. For digital communications the voltage levels are high and low. In our case high is 5V and low is 0Volt. So what it does is, keeps the wire voltage level High (by the pull up resistor) and DHT or the MCU pull’s it Low depending on the data bits it wants to send. If you have the wire voltage level Low and you put it High depending on the data bits, you may receive noise as data bits as also you will need more current to transmit. By this you can transfer data in bigger distances as it says about 20 meters.

      Generally the function of a pull up resistor is to keep (pull) the voltage High.
      Pull down resistor pulls it down to GND.

      I hope i helped you.

      1. Thanks for your response, you helped so much. I want to ask a few questions if you don't mind. I understand that keeping the bus voltage high helps noise prevention and decreases the current required for transmission. But does it interfere the transmission? For example in request stage,
        MCU_BUS_PIN_DIRECTION = OUT;
        MCU_BUS_PIN_OUT=HIGH;
        DHT_BUS_PIN_DIRECTION=IN;
        DHT_BUS_PIN_IN=HIGH; (because it is fed by MCU and Vdd)
        When MCU makes a request:
        MCU_BUS_PIN_OUT=LOW and DHT_BUS_PIN_IN supposed to be LOW. But doesn't the Vdd connected to the pullup resistor still keeps the wire HIGH?
        I dont have a chance to use an oscilloscope and the data transmission is too fast to be observed by a voltmeter.
        By the way I also appreciate your good work and wish you good luck in your education.

        1. Firstly i would like to thank you for your good words. Well i think what is missing from your knowledge is the electronics basics. I'll give it a try to make you understand it easily.

          terminal_1–/\/\/\/–terminal_2

          The basic usage of the resistor is for Current limiting. The current through a resistor is in direct proportion to the voltage across the resistor's terminals. By the Ohm's law I=V/R , if  V= Vterminal_1 – Vterminal_2 =0, then no current is drawn by the resistor.

          If you have terminal_1 to Vcc and the terminal_2 to the bus and the bus doesn't draw any current the voltage at terminal_2 will be = Vcc. If you pull the bus terminal Low the voltage will be Low and current will be drawn through the resistor (by Ohm's law).

          If you replace the resistor with a simple cable and try to pull it Low what will happen is a short circuit. A short circuit is a connection with no Resistance so no current limit, all the available current by the power supply will be drawn, so everything will get burn including the power supply :P(When you pull the bus level Low with the MCU the current passes throught the MCU so if no limiting resistance exists the MCU will get burned and not only)

          That's why we use resistors to pull the voltage high. Because resistors can have different voltage on it's terminals with a small current draw deppending on it's value.

          I hope i helped you

          1. As far as I can understand:
            1 – Data bus should be set high by a voltage source other than provided by MCU or DHT in order to:
             a) Prevent noise,
             b) Enable long distance data transmission,
             c) Reduce required current (which MCU or DHT may not be able supply).
            2 – A Pullup resistor should bu used to prevent short circuit when MCU or DHT pulls the bus low.
            Many thanks.

  10. Hello again,
    Yes, I will build an equal but with DHT-22. This week I'll buy the parts and start putting together 
     
    when I have pictures I put here 
     
    Many thanks.

     
     
    Hello again,
     
    I received the components and assembled everything but unfortunately not yet managed to get it to work. So I do the circuit again with new components, but it always happens the same thing, after I turn on power supply the LCD lights up but nothing else happens: (
     
    I'm using an AVR-PG1B (the stk500v2 have to change to ponyser) to send the main.hex for ATMEGA8, and as you can see here – http://pastebin.com/37bfcshR , it is submitted correctly and everything is ok. (I just run the command make install)
     
    After I upload the HEX file, I disconnect power supply and remove all ISP cables, then I power up again and LCD light up but nothing else happens 🙁
     
    Just a note, I'm not using the bluetooth module and I mount this circuit on breadboards.
     
    Do you have any idea what might be? Or you can tell me some ideas to check/test some parts of circuit?
     
    Just one more thing, if I put the fuse codes in the website you tell in other post, the RC Osc is different that you have in your circuit. This is a problem?
     
    Best Regards

    1. Yes i think that this is the problem. You wrong fuses. Atmega8 from factory i think works with internal 4mhz crystal or 8mhz. My program to work correctly needs to run at 16mhz to have enough time to decode the DHT-11 signals. So burn the fuses correctly to work with 16mhz crystal. 

      1. Hello Haris,
        thanks for quick response.
        I change the fuses in code (FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x0a:m) and upload to ATMEGA8,  unfortunately the problem is this same: Power up, the LCD lights up, but nothing happen (i cant see any message on LCD).
        You have any ideas to check other things?
        Best Regards

        1. When you say that the LCD lights up you mean only the backlight? Or it saws

          IN:   H:%

          OUT:

          etc without numbers?

          1. So your problem is that your avr doesn't works correctly. Check your fuses to be correct you can see more info at oldest comments where we have discussed this. Also make sure you use 16Mhz crystal

  11.  
    Dear Haris,
     
    sorry to be bothering again, but I've tried a few combinations of fuses (l: h 0xFF, 0xC9 and h: l 0xD9: 0xEF) and continued to get no results.
     
    If possible, can perform the following command avrdude -v -c ponyser -p atmega8 -P /dev/ttyS1 (obviously you need to change your settings) in avrdude for me to check the differences between my information and yours.
     
    My information is here: http://pastebin.com/ina46v2z
     
    Best Regards
     

    1. I read the fuses from my thermometer which is working now and are the following. 

       

      -U lfuse:w:0xce:m -U hfuse:w:0xd9:m

      Try them with a 16Mhz crystal connected like the scheme above. 

      Sorry for not checking your values but i don't have that much free time.

       

      If you still have a problem contact me.

       

  12. so i've downloaded all of your source code. how do i put that into the microcontroller?

    1. This is a general question about how to program an AVR and not for the specific project. If you google it i think you can find a bunch of information. Thank you.

  13. hi
    I was wondering if you could use this code to monitor 3 temperature sensors and display them on the LCD. I see you still have some analogue pins left . I dont know anything about coding but i do know how to solder
     
    great Project. I see people are already trying to take it to another level
     
    thanks

  14. Hello
    I am using a 8mhz crystal. So set the fuses accordingly and also defined F_CPU.
    I wrote the code based on your 's to use it in avr studio, as the your code shows errors in avrstudio6. But it doesn't seem to be working. Do I have to use 16MHZ crystal only for it to work?
    And one more thing, I initially reversed the power supply , it got a bit hot then I corrected it. Is there any way to check whether the sensor is working or not?(Because I could have burnt it). Nothing seems to be burnt by the looks.

    1. Hello, i have wrote a note on the article but you may didn't read it "Note. A 16Mhz crystal has been used instead of 8Mhz shown on the schematic in order to read DHT data easier." So if you use an 8Mhz crystal the sampling will be slower and you may lose data from DHT.  The only way to check if the sensor works is to plug it on a psu and connect a logic analyzer or an oscilloscope to see if there is anything on the output.

      1. No I already made the board with 7.328MHZ crystal. But shoudnt declaring F_CPU in AVR studio solve the problem as the delay function will use it decide the time .

  15. Code doesn't work  ;/ I have error when I compiling program:
     
     
    Building file: ../dht.c
    Invoking: AVR Compiler
    avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega8 -DF_CPU=16000000UL -MMD -MP -MF"dht.d" -MT"dht.d" -c -o"dht.o" "../dht.c"
    ../dht.c: In function 'DHT_Read_Data':
    ../dht.c:35: warning: implicit declaration of function 'cli'
    ../dht.c:38: warning: implicit declaration of function 'DDR'
    ../dht.c:38: error: lvalue required as left operand of assignment
    ../dht.c:50: error: lvalue required as left operand of assignment
    ../dht.c:52: warning: implicit declaration of function 'PIN'
    ../dht.c:86: warning: implicit declaration of function 'sei'
    ../dht.c:96: warning: implicit declaration of function 'uart_puts'
    make: *** [dht.o] Error 1
     
     

  16. Strange, because Eclipse Build (compile) whole Project and I have only warnings and errors in dht.c file.

    1. I haven’t used Eclipse before so i don’t know it’s configurations. Makefile is also included check it. I use X code as editor and avr-gcc for compilation 

  17. Not working….I modified the code (dht.c and dht.h) and I think now  it's working properly. In my room now is H:45%. I don't know why your software didn't work before. BTW. Sorry for my english ;p

  18. I had a look at your sourcecode. I doubt that lines in DHT.c containing
    counter>255
    are correct, as counter is byte and anything >255 is automatically <255 due to overrun.

  19. hi , i had your code to interface with atmega32 to display the temperature and humidity in 16×2 lcd,i have run the same code in atmel studio 6 and was error free but i have not got any kinds of output in lcd .i have used atmega32,16Mhz,DHT11 and lcd in my circuit (lcd and dht11 are connected to adc port), please help me with suggestions i 'm new to avr . thank you

     

     

  20. Do you mind if I quote a couple of your articles as long as I provide credit and sources back to
    your blog? My website is in the very same niche as yours and my visitors would certainly benefit from a lot of the information you provide here.

    Please let me know if this ok with you. Thanks!

    1. Hello, thank you for your interest. Yes of course you can share any of my articles providing credit sources back to my blog.

      What is your web site?

      Thank you

  21. Hi, i want to ask how this project communicate with PC? from RS232? use vb6?? Because i cant see the source code you provide to communicate with PC.. thanks. 

  22. Hi, If i want to read the temperature and humidity inside PC wht should i do?? got any program can communicate with that??

    1. Any program that can establish uart-RS232 communication. For example Hyperterminal on windows or Screen on Mac os

  23. can i get the source code for interfacing DHT11 with atmega 16 using codevision avr? doing in avr studios wouldnt work as i am asked to do this using codevision only..this is for my project….thanks in advance 🙂

  24. It would be great if you made a VFD tube thermometer that matched Angelica.

    1. The VFD Tube clock i have designed it can also support onboard temperature measurements itself (including Angelica model) but the ventilation inside the enclosure isn’t enough to get realistic readings from the actual room temp. 

Leave a Reply to alex Cancel reply

Your email address will not be published. Required fields are marked *