USB LCD thermometer uses microcontroller ATmega32u2 (TQFP32). ATmega16u2 can also be used, it is recommended using microcontroller ATmega32u2 which has 32k Flash memory. USB (USB 2.0 Full-Speed) periphery is also used to programming, since the microcontroller is pre-loaded with DFU bootloader. It can be programmed with the FLIP. This means that AVR programmer is not needed for programming . Microcontroller already has built USB peripherals, so does is does not need a USB-UART bridge integrated circuits (FTDI, etc.). It uses two digital temperature sensors DS18B20, for indoor and outdoor temperature sensing. On PCB there is also a voltage regulator LM1117-5V 800mA, which serves as external power supply (Max: 15V). The circuit operates with 16MHz clock (using an external crystal), microcontroller which requires to operate the USB communication. At the USB connection there must be 22ohm resistors values (+ / – 5%), to reduce interference. For proper operation of the USB communication we must not forget the Ucap 1μF ceramic capacitor (+ / – 10%) and electrolytic capacitor 22μF. The circuit has four buttons, HWB, the Reset button to start and stop the brightness of the LCD display and the button to turn on and off USB to Serial connection. To display the measurement is used 16×2 LCD display.
Temperature measurement with sensor DS18B20:
To read the temperature is used sensor DS18B20 by company Dallas Semiconductors. Measurement of the temperature can be in the range from -55°C to +125°C with an accuracy of +/- 0.5°C (from -10°C to +85°C). Power supply is DC 3.0V – 5.5V. Communication with the sensor is “1-wire”, which means that sending data on one line (bus) with ground, in both directions, according to a certain protocol with one line or bus (and ground). Communication is asynchronous and a two-way. On line can be connect one or more devices at the same time. Line must be in the high logical state, so we use a resistor value of 4.7kOhm, which is connected to supply voltage VCC (pull-up). The sensor has a 64-bit serial number, which serves to be on the same line connect multiple sensors at the same time and then we know from which comes the data. Thermometer resolution is user selectable from 9 to 12 Bits. It also has an alarm function, which is activated (sensor sends its serial number) when the temperature gets outside predetermined limits. The sensor converts the temperature in the 12-bit digital word, every 750ms. We need to convert a word with a certain algorithm into a desired shape.
Available in 8-Pin SO (150 mils), 8-Pin µSOP, and 3-Pin TO-92 Packages:
Bill of materials:
|Ime||Oznaka||Oznaka v shemi||Opis||Število|
|LCD 16×2||LCD 16×2||LCD||LCD 16×2||1|
|DC-Connector||PWR2.5||J1||Power DC Connector||1|
|USB B-Connector||440247-2||J2||USB 2.0, Class B||1|
|HDR1x3||DS18b20||P1,P2||Header, 3 -pin||2|
|SOT-23A||BC817, 500mA||Q1||NPN Transistor||1|
|SMD Trimmer||10k||R8||Trimmer potentiometer||1|
|Tactile Switch 90°||HWB||S1||Micro switch 6×6 90°||1|
|Tactile Switch 90°||Reset||S2||Micro switch 6×6 90°||1|
|Tactile Switch 90°||Tipka2||S3||Micro switch 6×6 90°||1|
|Tactile Switch 90°||Tipka1||S4||Micro switch 6×6 90°||1|
|SOT223||LM1117-5.0||U1||800mA Linear regulator||1|
Printed circuit board:
The PCB is a double side and is the same size as LCD panel (37x80mm). It features all the elements involved with LCD display, buttons and connectors. The elements are arranged on the inner side of the circuit board covered with the USB and the power supply connector. The interior of the circuit is readily accessible, since unscrew 4 screws and recording LCD display.
Domestic production of printed circuit board is not anything special and is feasible. Vias is very little and is easy to solder.
The PCB is made in the Altium Designer 10.
First of all soldered smaller SMD components, resistors, capacitors, microcontroller and a voltage regulator. Only then tackle the major elements of soldering, USB connector, power connector, buttons and sticks. When soldering the microcontroller attention should be paid to the proper orientation, and that no short circuits. Care is also needed on the polarity of electrolytic capacitors.
Caution: a housing of the USB connector is conductive and has on it the mass (GND). Connector is required to affix insulating film, so it will not short-circuit the USB connector and the LCD display.
How to connect to a microcontroller (DFU mode)?
First connect the circuit (microcontroller) to the USB, we need to switch to programming mode via USB (DFU mode). This is done by pressing the HWB and briefly press the RESET button yet. Then HWB button down. The computer will recognize the microcontroller and install the drivers. Drivers for microcontroller can be downloaded below.
By clicking Run pass the program a microcontroller. If the microcontroller is programmed correctly they shall appear green circle hooks.
That the program is started pressing and releasing the RESET button.
Backlight ON / OFF function:
On the circuit NPN transistor BC817 in SOT-23 chassis which controlled power supply for LCD backlight.
The button backlight turns on and switch off the LCD backlight.
USB to Serial ON / OFF function:
The PCB has the ability to stop and start the USB to Serial connection with USB switch.
Display on the screen:
The program for the microcontroller is written in the C programming language, the Programme for programming AVR Studio 4 The system is built from the main program, which is carried out in an endless loop display of the measured internal and external temperatures.
USBtoSerial and program:
When we programmed the microcontroller circuit connect to USB. The computer will automatically detect the USB device FlashElectronics necessary to install the driver FlashElectronics_DRIVER.inf. Once successfully installed you will vDevice Manager (Device Manager) showed the device FlashElectronics USB (COMx). Now just run the program and FlashElectronics.exe selected port.
The program works on Windows 7, Vista and XP. In the COMx port is selected and click the Open button to refresh the ports click the button R. The program shows the internal and external temperature, time and date, and the status of the LCD backlight. The program also stores the temperature in the folder temperatures, the program creates a folder itself. Temperatures begin to save when you click the Open button. To conclude store must click the Close button. Stores in 10 seconds. The recorded temperature with time every 10 seconds. The program is made in Visual Studio (vb.net).
The final product / Images:
Article in magazine “Svet Elektronike”:
Article in book “Elektronik.si”:
Article can be found on http://elektronik.si
- Atmega32u2 datasheet: http://atmel.com/dyn/resources/prod_documents/doc7799.pdf
- DS18B20 datasheet: http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf
Schematics + PCB
USB LCD Thermometer Luka Penger Article SE