I am interested in weather sensing - weather stations, thermometers, hygrometers.
Couple years ago I made thermometer with circuit ICL 7107 and with simple diode 1N4148 as a sensor. It works more than ten years without problems. The only negative was, that this circuit needs to be calibrated.
Now after some time I made new thermometer, with Arduino and digital outdoor sensor.
Step 1: Specification
- digital sensor 18B20 (for outdoor temperature)
- analog sensor LM35 (for indoor temperature - only for test)
- measured temperature in °C shown on 7-segment display
- evaluation of temperature level and display it on a bar graph
- evaluation of ambient light and set brightness level of displays (2 levels - the day / the night)
- change of brightness level of displays for the day and for the night
- count uptime
Step 2: The Design
Front panel is very clear - only four digit 7-segment LED display (red color) and multicolor 10-segment bar graph display.
Rear panel contains:
- connector for DC input
- connector for digital temperature sensor (4-pin, but only 3-pins are used)
- LDR sensor for ambient light
- analog temperature sensor LM35
- button for change brightness level of displays
- button for change of sensor (analog LM35 / digital 18B20)
- button for info about device and current mode
Outdoor digital sensor is 18B20 - outside of the window. Through the window is connected with flat ribbon cable and from the window to the thermometer is connected with shielded cable.
Step 3: Inside
Why two Arduino ?
Driving 7-segment LED display and reading temperature form digital sensor 18B20 via OneWire at the same time is not so easy. In my trials of connection in breadboard, I met the problem of flickering LED display at regular intervals. This was caused by reading values from the digital sensor.
Then I split part of reading temperature from digital sensor to one Arduino Nano. And all other tasks to second (main) Arduino Nano. Communication between them is thru I2C bus (Arduino with sensor is master, "main" Arduino is slave).
Limited number of pins ?
Because of Arduino Nano has limited number of pins I used 74HC595 shift register. One for 7-segment display, second for bar graph display.
Why didn't connect LDR directly to analog pin ?
I met with insufficient sensitivity when I connect LDR directly to analog pin. I need only 2 levels - the day / the night. So I add comparator LM393 with adjustable trimmer to set switching level.
Note: Attached PCB Kicad files are for first version (without LDR sensor, without LM393, without BC547 (Q5) for bargraph - these were added later).
Step 4: The Code
As mentioned in the previous step, the code is divided into two arduinos.
First Arduino (I2C Master) reads the temperature from digital sensor 18B20 and sends the value to "main" Arduino.
Interval for reading temperatures is 800 ms.The resolution of 18B20 is set to 12-bit (increments of 0,0625°C).
Used libraries are Wire; I2C_Anything; OneWire; DallasTemperature.
My code sends data from one digital temperature sensor (it could be connected more than one sensor on the same OneWire bus).
Second "main" Arduino (I2C Slave) process all others tasks.
Measured temperature in °C is shown on 7-segment display. Temperature level is shown on bar graph. According to ambient light is set brightness level of displays. Main Arduino also process reactions to button press.
Used libraries are EEPROM; Wire; I2C_Anything
Step 5: How It Works
After power up the thermometer begin with initialization (show INIT, turn on all segments, show brightnes mode (the day/the night, show brightness level (for example 500), show type of active sensor). Then go to the run mode and show measured temperature.
If isn't connected connected sensor then is shown error.
Short press of brightness button show current value for brightness (separately for the day mode and for the night mode). Long press of brightness button change level of brightness.
At the night the brightness level of displays is lower (simulation by covering the LDR sensor).
Info button show similar screens as initialization phase, but show also cumulative uptime (turn on all segments, show brightnes mode ("JAS" = brightness, "den" = the day), show brightness level (for example 500), show uptime, 0 days ("dni" = days), 0 hours ("hodi" = hours), 1 minute, 0 rollover, show type of active sensor (18b20), show number of restart of digital sensor at error ("rest"). Then go to the run mode and show measured temperature.
Bar graph show level of the temperature. Blue - temperature around 0°C, Green color - good temperature, orange color - bad temperature, red color - the worst temperature.
Thanks for watching.