TEMP209 is a compact, open-source digital temperature controller designed for the ATmega microcontroller family (ATmega8 / 88P / 328). It reads temperature from a DS18B20 sensor, displays it on a multiplexed 2-digit 7-segment display, and manages thermal and user-defined outputs.
The project is written in BASCOM-AVR and released for educational and open-source purposes.
Out1 (reserved), Temp_out (thermal control)TEMP209 uses a simple thermal controller to demonstrate alternative design choices.
On ATmega8 and ATmega88P, the 8 KB flash is fully used — there is no room left for button-handling code, and there aren't enough free pins either.
On ATmega328, physical buttons can be added using ADC (analog keypad on a single pin).
In this design, however, the preference is toward remote + Bluetooth control — not because buttons are impossible, but because it avoids the difficulty of button placement, wiring, and mechanical design. A ready-made, elegant, optimized IR remote offers clean remote control with zero mechanical complexity:
Fault on serialreport or IR command| MCU | Flash | SRAM | EEPROM | Status |
|---|---|---|---|---|
| ATmega8 | 8 KB | 1 KB | 512 B | Supported |
| ATmega88P | 8 KB | 1 KB | 512 B | Current source target |
| ATmega328 | 32 KB | 2 KB | 1 KB | Supported |
| Function | Pin | Description |
|---|---|---|
| Seg1 | PORTB.3 | Tens digit enable |
| Seg2 | PORTB.4 | Units digit enable |
| A | PORTB.1 | 7-segment A |
| B | PORTB.2 | 7-segment B |
| C | PORTD.7 | 7-segment C |
| D | PORTB.7 | 7-segment D |
| E | PORTD.5 | 7-segment E |
| F | PORTB.5 | 7-segment F |
| G | PORTB.6 | 7-segment G |
| Dp | PORTD.6 | Decimal point |
| Out1 | PORTC.5 | User relay — reserved |
| Temp_out | PORTC.4 | Thermal control relay |
| Buzzer | PORTC.0 | Buzzer |
| Fault | PORTC.3 | Fault input |
| RC5 IR | PINB.0 | IR receiver |
| 1-Wire | PORTD.4 | DS18B20 data |
| TX | PORTD.1 | Serial debug output (9600 baud) |
| RX | PORTD.0 | Serial command input (9600 baud) |
Out1 is a reserved, unused output. Wire it up and use it if needed.
TEMP209 uses a 2-digit 7-segment display as listed in the BOM. But don't worry if you don't have this exact part — any type works:
Displays are typically driven by:
Instead of using external driver ICs, TEMP209 connects the display directly to the MCU. This provides:
| Segment | MCU Pin | Digit Select | MCU Pin |
|---|---|---|---|
| A | PORTB.1 | Seg1 (tens) | PORTB.3 |
| B | PORTB.2 | Seg2 (units) | PORTB.4 |
| C | PORTD.7 | Multiplexed switching | |
| D | PORTB.7 | ||
| E | PORTD.5 | ||
| F | PORTB.5 | ||
| G | PORTB.6 | ||
| Dp | PORTD.6 | ||
| Value | Display | Meaning |
|---|---|---|
| 0–9 | 0–9 | Numeric digits |
| 10 | P | Protection Delay menu |
| 11 | b | Beep menu |
| 12 | d | Delta menu |
| 13 | F | Fault Delay menu |
| 14 | H | Heat/Cool menu |
| 15 | L | Light/Brightness menu |
TEMP209 uses the RC5 protocol with a 3-slot array structure.
Irtxt(1) = Remote Address — used for filtering (default: 3142)Irtxt(2) = Command 1 — primary commandIrtxt(3) = Command 2 — secondary command (optional)Some RC5 remotes (especially HVAC/AC controls) transmit multiple parameters in a single keypress (e.g., temperature and fan speed). The 3-slot array captures and processes all transmitted data.
| Address | Command 1 | Action |
|---|---|---|
| 3142 | 735 | Toggle Power |
| 3142 | 2759 | Toggle Out1 |
| 3142 | 3137 | Report Temperature Log |
| 3142 | 264 | Toggle Menu |
| 3142 | 22 | Setpoint +1°C |
| 3142 | 227 | Setpoint −1°C |
Menu navigation (when Menu = 1):
| Command 1 | Action |
|---|---|
| 2958 | Menu Up |
| 1738 | Menu Down |
| 1825 | Increment parameter |
| 285 | Decrement parameter |
Worried you can't find the example remote? Don't be. Most remotes are RC5, and any remote can be defined. Simply:
You likely have a few spare remotes lying around at home. In the market, especially cheap Bluetooth audio module remotes (like the one used in this project) cost almost nothing.
Connect TX to serial terminal at 9600 baud and press a button. You'll see:
Address=3142
command1=735
command2=22
Replace values in the Ir_down subroutine:
If Irtxt(1) = "your_address" Then
If Irtxt(2) = "your_command1" Then Call YourFunction()
If Irtxt(3) = "your_command2" Then Call YourSecondaryFunction()
9600 baud, 8N1 — the standard default for common Bluetooth modules.
| Command | Function |
|---|---|
set_temp+ | Increase setpoint by 1°C |
set_temp- | Decrease setpoint by 1°C |
power | Toggle power state |
report | Stream temperature log from EEPROM |
out1 | Toggle Out1 relay |
menu | Toggle menu mode |
up | Menu up |
down | Menu down |
incr | Increment menu parameter |
decr | Decrement menu parameter |
Temp209
relay=1
temp=25
Address=3142
command1=735
command2=22
setpoint=26
Fault
report command):
The log starts with live=N — a reference index that points to the position of the newest sample — followed by raw temperature values (0–255), and ends with end.
live=240
25
26
253
24
27
25
...
end
The value 253 is a position marker (not the end of the log). There can be more than one 253 in the stream — the one closest to live is the valid marker. 255 means an empty/erased EEPROM cell and is shown like any other value.
Navigate using IR or serial commands. Parameters are stored in EEPROM.
| Action | IR / SoifGo | Serial |
|---|---|---|
| Enter menu | Center button / ◉ | menu |
| Up | ▲ | up |
| Down | ▼ | down |
| Increase value | ▶ | incr |
| Decrease value | ◀ | decr |
| Exit | ◉ again | — |
| Auto-exit | After 8 seconds | — |
What: Mandatory delay between turning the relay off and back on.
Why: Prevents shock from fast power cycling. Compressors in ACs and fridges (especially low-back-pressure types) may be under pressure and fail to start if switched rapidly — leading to motor stall and damage without protection.
Range: 0 = disabled · 1-9 = minutes
What: Adjusts brightness of the 2-digit display.
Why: Optimize power consumption, or increase brightness in well-lit environments for better visibility.
Range: 0 = lowest · 9 = highest
What: Temperature gap between relay ON and OFF.
Why: Sometimes you need to store a bit of heat or cold, or avoid constant switching from rapid temperature changes. Delta lets the controller run a bit warmer or cooler than the setpoint.
Example: Setpoint = 25, Delta = 2
Range: 0-9°C
What: Controls how the controller reacts to the fault input (PORTC.3).
Why: Motors with high inrush current may briefly trigger the fault input on startup. A small delay prevents false trips while still providing protection.
Range:
0 = fault monitoring disabled1-9 = delay in seconds before reacting to the fault signalVisual indication: When a fault occurs, the display shows "FF" blinking (eye-catching alert).
Range: 1 = Heating (behaves like a heater) · 0 = Cooling (fridge, AC, ventilation fan)
What: Buzzer volume for key feedback and sensor-failure alarm.
Range: 0 = off · 1-9 = increasing volume
The Heat_cool() subroutine manages automatic temperature regulation:
Temp_out = 1 when Currenttemp < SettempTemp_out = 1 when Currenttemp > Settemp + DeltatempSensorerr = 1, the relay is forced OFF for safetyTemp_out = 0 and display shows blinking "FF"SoifGo is a mobile app that connects to TEMP209 via Bluetooth, giving you full control from your phone. The UI is customizable — you can modify or extend it as you wish.
Pair your phone with the controller's Bluetooth module and connect. The module communicates at the standard default 9600 baud.
The most educational feature! When connected, pressing any remote button shows its address and command in the terminal:
Address=3142
command1=735
command2=22
Use this to discover codes for any remote, then replace them in your source, compile, and program.
Graph features:
| Button | Function |
|---|---|
| Out1 | Toggle reserved output |
| Power | Toggle device power |
| +1 | Increase setpoint |
| -1 | Decrease setpoint |
| Report | Request temperature log |
When the fault input on PORTC.3 receives a HIGH signal (2.7V–5V), and after the configured Fault Delay has passed:
Temp_out = 0Faultstatus = 1Fault on serialFault clears when the signal returns LOW or the device is reset.
0 = fault monitoring disabled (no fault reaction)1-9 = delay in seconds before reacting to the fault signalThis is useful for motors with high inrush current that may briefly trigger the fault input on startup, preventing false trips.
The Fault input is typically driven by the Hall-sensor current comparator (see Section 14). Any over-current triggers a fault, cutting the relay for protection.
The choice of detection method is yours. You can either:
Recommendation: The ACS series is the better choice — compact, high accuracy, and stable output.
TEMP209 is designed as two separate boards:
On the relay board, sufficient physical spacing is provided between the mains AC section and the low-voltage MCU power section. Be careful when handling the board, and always observe electrical safety practices.
Reading AC/DC current to detect over-current and trigger emergency shutdown.
| Method | Pros | Cons |
|---|---|---|
| Rectification + capacitor | Simple | Loses useful signal, complex circuit |
| ADC sampling | Accurate | Heavy MCU load, large code |
| Comparator op-amp ⭐ | Cheap, reliable, compact | Needs initial calibration |
Fault message is also announced on the serial output.Depending on the op-amp and circuit, fine-tuning may be needed — but one-time calibration is enough.
This method (UGN503 + metal washer + wire coil) is educational and may introduce some design error.
Recommended: Use an ACS-series current sensor instead — cleaner and more reliable.
Both methods produce the same type of output (analog voltage proportional to current) — only the scaling values differ.
Main drawback of the UGN503 method: A UGN503 with a core and wire coil is more sensitive to nearby magnetic fields compared to an ACS sensor.
TEMP209 automatically logs one temperature sample every minute to EEPROM. The buffer works like a CCTV recorder — a 480-sample circular buffer that always holds the last 8 hours. The newest sample is always available, even after power loss.
253 is written right after the newest sample and travels with it253 is written right after it.253 is overwritten by the new temperature sample — so the marker always sits right after the newest temperature.253 is a position marker (not the end of the log). It tells the reader where the newest sample is located in the circular buffer.255 = empty / erased EEPROM cell (all bits = 1). It is displayed in the graph like any other value, so blank areas remain visible.| Method | How |
|---|---|
| Serial command | Send report via Bluetooth or cable |
| IR remote | Press the button coded 3137 |
The full report is sent to the SoifGo app, where you can see the temperature graph on your phone. 📊
The stream starts with live=N — the reference index of the newest sample — followed by raw temperature values (0–255), and ends with end.
live=240
25
26
253
24
27
25
...
end
253 is a position marker, not the end of the log. If more than one 253 appears in the stream, the reader uses live to pick the correct one (closest to live).
Monitor serial output at 9600 baud, 8N1 — the standard default for common Bluetooth modules:
Temp209 - Startup message
relay=1 - Current relay state
temp=25 - Current temperature
Address=3142 - Remote address
command1=735 - Primary command
command2=22 - Secondary command
setpoint=26 - Setpoint changed
power=1 - Power state changed
Fault - Fault condition detected
live=240 - Report start (reference index of newest sample)
25 - Temperature sample
26 - Temperature sample
253 - Position marker
24 - Temperature sample
end - End of report stream
| Symptom | Possible Cause |
|---|---|
| Display shows "--" | Sensor disconnected or faulty |
| Display shows blinking "FF" | Fault input triggered (after Fault Delay) |
| No serial output | Wrong baud rate, TX not connected |
| IR not responding | Wrong remote codes — verify via terminal |
| Relay chatters | Delta too small — increase it |
| False fault trips on motor start | Increase Fault Delay (F parameter) to 1-9 seconds |
The board includes a programmer socket for easy development and in-circuit programming. You can use any standard AVR programmer, such as USBasp.
Advanced users who want to modify the source can open the BASCOM project, adjust remote codes or parameters, recompile, and program the resulting HEX.
Watch TEMP209 in action. These videos demonstrate real-world testing, programming, remote setup, logging, and fault protection.
253) sits right after the newest temperature samplelive=N (start) and end (terminator)255 = empty EEPROM cellF=0 disables monitoring, F=1..9 adds 1–9 second reaction delayTEMP209 is an open-source educational project by Saeid Moghadam.
Open Source — Educational Purpose.
For contact and more tutorials, see the main SoifGo page.