TEMP209

Open-Source Microcontroller Temperature Controller
Version 1.0 Open Source Hardware ATmega8 / 88P / 328

📑 Table of Contents

  1. Project Overview
  2. Design Philosophy
  3. Key Features
  4. MCU Compatibility
  5. Pin Mapping
  6. 7-Segment Display
  7. IR Remote Control (RC5)
  8. Serial Commands
  9. Configuration Menu
  10. Thermal Control Logic
  11. SoifGo Mobile Interface
  12. Fault & Safety
  13. Hardware
  14. Current Sensing with Hall Sensor
  15. 8-Hour Temperature Logger
  16. Debugging
  17. Building & Programming
  18. Downloads & Links
  19. Test Videos
  20. Changelog
  21. About & License

1. Project Overview

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.

TEMP209 overview
Figure 1: TEMP209 overview
Key Specifications:
  • Temperature Range: 0°C to 99°C
  • Sensor: DS18B20 (1-Wire protocol)
  • Display: Multiplexed 2-digit 7-segment
  • Remote Control: RC5 infrared protocol
  • Outputs: Out1 (reserved), Temp_out (thermal control)
  • Safety: Fault input (PORTC.3) — can be disabled or given 1–9 s delay
  • Storage: EEPROM for settings and data logging
  • MCU Support: ATmega8, ATmega88P, ATmega328 — separate firmware for each

2. Design Philosophy

Core question: There are countless temperature controllers on the market. What makes TEMP209 different?

TEMP209 uses a simple thermal controller to demonstrate alternative design choices.

❓ Why no physical buttons?

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:

In the end, this is a matter of need and taste. Don't follow instructions blindly — decide based on your own requirements.

3. Key Features

🌡️ Temperature Measurement

🖥️ Display

🎛️ IR Remote Control

🔌 Outputs

🌡️ Control Modes

🛡️ Safety & Fault

💾 Memory & Logging

📡 Serial Communication

🔋 Stability

4. MCU Compatibility

MCUFlashSRAMEEPROMStatus
ATmega88 KB1 KB512 BSupported
ATmega88P8 KB1 KB512 BCurrent source target
ATmega32832 KB2 KB1 KBSupported
Separate firmware for each MCU: A dedicated HEX file is provided for each of the three microcontrollers. Download the one that matches your chip and program it directly — no modification needed.

5. Pin Mapping

FunctionPinDescription
Seg1PORTB.3Tens digit enable
Seg2PORTB.4Units digit enable
APORTB.17-segment A
BPORTB.27-segment B
CPORTD.77-segment C
DPORTB.77-segment D
EPORTD.57-segment E
FPORTB.57-segment F
GPORTB.67-segment G
DpPORTD.6Decimal point
Out1PORTC.5User relay — reserved
Temp_outPORTC.4Thermal control relay
BuzzerPORTC.0Buzzer
FaultPORTC.3Fault input
RC5 IRPINB.0IR receiver
1-WirePORTD.4DS18B20 data
TXPORTD.1Serial debug output (9600 baud)
RXPORTD.0Serial command input (9600 baud)
Note: Out1 is a reserved, unused output. Wire it up and use it if needed.
TEMP209 pinout
Figure 2: TEMP209 pinout (ATmega8 / 88 / 328 — same DIP-28 layout)

6. 7-Segment Display

Display Type

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:

Why So Flexible?

There are no current-limiting resistors in the connections. Current is controlled purely by switching timing (multiplexing). So you can configure the pins any way you need.

Common Display Driving Methods

Displays are typically driven by:

Why TEMP209 Connects Directly

Instead of using external driver ICs, TEMP209 connects the display directly to the MCU. This provides:

Pin Connections

SegmentMCU PinDigit SelectMCU Pin
APORTB.1Seg1 (tens)PORTB.3
BPORTB.2Seg2 (units)PORTB.4
CPORTD.7Multiplexed
switching
DPORTB.7
EPORTD.5
FPORTB.5
GPORTB.6
DpPORTD.6

Character Map

ValueDisplayMeaning
0–90–9Numeric digits
10PProtection Delay menu
11bBeep menu
12dDelta menu
13FFault Delay menu
14HHeat/Cool menu
15LLight/Brightness menu
2-digit 7-segment display
Figure 3: 2-digit 7-segment display
⚠️ If your display's pins differ: If your display's pin configuration differs from this layout, you must update the pin configuration in the source to match.

7. IR Remote Control (RC5)

TEMP209 uses the RC5 protocol with a 3-slot array structure.

RC5 Array Structure (from firmware):
  • Irtxt(1) = Remote Address — used for filtering (default: 3142)
  • Irtxt(2) = Command 1 — primary command
  • Irtxt(3) = Command 2 — secondary command (optional)

Why Two Commands?

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.

⚠️ Important: Not all remotes use this multi-command format. Verify your remote via serial monitoring.

Default Command Codes (from firmware)

AddressCommand 1Action
3142735Toggle Power
31422759Toggle Out1
31423137Report Temperature Log
3142264Toggle Menu
314222Setpoint +1°C
3142227Setpoint −1°C

Menu navigation (when Menu = 1):

Command 1Action
2958Menu Up
1738Menu Down
1825Increment parameter
285Decrement parameter

Any RC5 Remote Works

Worried you can't find the example remote? Don't be. Most remotes are RC5, and any remote can be defined. Simply:

  1. Note the address and command in the Bluetooth terminal
  2. Replace the values in the code
  3. Compile and program

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.

Pairing Procedure

Step 1: Capture Codes

Connect TX to serial terminal at 9600 baud and press a button. You'll see:

Address=3142
command1=735
command2=22
Step 2: Update Firmware

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()
Sample RC5 remote
Sample RC5 remote

8. Serial Commands

9600 baud, 8N1 — the standard default for common Bluetooth modules.

CommandFunction
set_temp+Increase setpoint by 1°C
set_temp-Decrease setpoint by 1°C
powerToggle power state
reportStream temperature log from EEPROM
out1Toggle Out1 relay
menuToggle menu mode
upMenu up
downMenu down
incrIncrement menu parameter
decrDecrement menu parameter
Serial Output Example:
Temp209
relay=1
temp=25
Address=3142
command1=735
command2=22
setpoint=26
Fault
Temperature Log Output (from 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.

9. Configuration Menu

Navigate using IR or serial commands. Parameters are stored in EEPROM.

🎮 Access & Navigation

ActionIR / SoifGoSerial
Enter menuCenter button / ◉menu
Up▲up
Down▼down
Increase value▶incr
Decrease value◀decr
Exit◉ again—
Auto-exitAfter 8 seconds—

⚙️ Parameters

P
Protection Delay
Protects compressor from rapid cycling

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

Smart behavior: If power doesn't drop and the compressor stops due to temperature control, TEMP209 still counts the delay so the next start isn't delayed unnecessarily. Protection is always active.
L
Display Light
Brightness control

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

d
Delta Temperature
Hysteresis / temperature gap

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

  • Heating: relay ON below 25, OFF above 27
  • Cooling: relay ON above 27, OFF below 25

Range: 0-9°C

F
Fault Delay
Reaction delay to fault input

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 disabled
  • 1-9 = delay in seconds before reacting to the fault signal

Visual indication: When a fault occurs, the display shows "FF" blinking (eye-catching alert).

H
Heat / Cool Mode
Heater or cooler behavior

Range: 1 = Heating (behaves like a heater) · 0 = Cooling (fridge, AC, ventilation fan)

b
Beep / Buzzer
Alert volume

What: Buzzer volume for key feedback and sensor-failure alarm.

Range: 0 = off · 1-9 = increasing volume

10. Thermal Control Logic

The Heat_cool() subroutine manages automatic temperature regulation:

11. SoifGo Mobile Interface

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.

SoifGo main screen
Figure 5: SoifGo main screen

🔌 Bluetooth Connection

Pair your phone with the controller's Bluetooth module and connect. The module communicates at the standard default 9600 baud.

📺 Live Display (Top)

🖥️ Terminal Panel

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.

Terminal showing remote codes
Figure 6: Terminal showing remote codes

📊 Report Button & Temperature Graph

  1. Press the Report button
  2. The command is sent to the controller
  3. The controller streams the latest log
  4. Wait ~4 seconds
  5. The 8-hour temperature graph appears

Graph features:

8-hour temperature graph
Figure 7: 8-hour temperature graph

🎮 Bottom Buttons (Mimic Remote)

ButtonFunction
Out1Toggle reserved output
PowerToggle device power
+1Increase setpoint
-1Decrease setpoint
ReportRequest temperature log

◉ Center D-Pad (5 Buttons)

Menu D-Pad
Figure 8: Menu D-Pad
SoifGo = virtual remote + code-discovery tool + graph viewer.

12. Fault & Safety

When the fault input on PORTC.3 receives a HIGH signal (2.7V–5V), and after the configured Fault Delay has passed:

Fault clears when the signal returns LOW or the device is reset.

Fault Delay (F Parameter)

This is useful for motors with high inrush current that may briefly trigger the fault input on startup, preventing false trips.

Hall Sensor Interface

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.

⚠️ Critical Safety Warning:
  • Do NOT rely solely on the F (Fault) protection
  • Always add a proper miniature circuit breaker (MCB) to the load side
  • Add an inline glass fuse for the MCU power supply
  • These are your primary protection; the Fault input is a secondary safety net

13. Hardware

Two-Board Design

TEMP209 is designed as two separate boards:

Mounting Options

🛡️ Safety Clearance

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.

⚠️ Fusing Recommendation:
  • Load side: Miniature circuit breaker (MCB) matched to your load
  • MCU supply: Inline glass fuse (e.g., 500 mA)
  • Never operate without fuses
Board 1 — controller
Figure 9: Board 1 — controller
Board 2 — power/relay
Figure 10: Board 2 — power/relay
PCB layout
Figure 11: PCB layout
Schematic diagram
Figure 12: Schematic diagram

14. Current Sensing with Hall Sensor

The Challenge

Reading AC/DC current to detect over-current and trigger emergency shutdown.

Candidate Methods

MethodProsCons
Rectification + capacitorSimpleLoses useful signal, complex circuit
ADC samplingAccurateHeavy MCU load, large code
Comparator op-amp ⭐Cheap, reliable, compactNeeds initial calibration

🏆 Selected Method: Comparator Op-Amp

Hardware Setup

How It Works

Hall sensor with wound wire
Figure 13: Hall sensor with wound wire

Calculations

Calibration Procedure:
  1. Apply the expected maximum normal current (e.g., 4 A).
  2. At 4 A, the Hall output reaches 2.80 V; the op-amp begins oscillation and the MCU Fault input is triggered.
  3. The fault LED indicator should be OFF under normal current (e.g., 4 A) — turn the potentiometer until the LED turns off.
  4. When an over-current occurs (e.g., above 4 A), the fault LED turns ON, the 7-segment display shows blinking "FF", and the relay cuts off.
  5. The 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.

Comparator op-amp circuit
Figure 14: Comparator op-amp circuit
⚠️ Educational Note

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.

15. 8-Hour Temperature Logger

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.

How It Works

Circular buffer + position marker (CCTV-style):
  • Each minute, the current temperature is written to the next slot, and 253 is written right after it.
  • The previous 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.

Viewing the Report

MethodHow
Serial commandSend report via Bluetooth or cable
IR remotePress the button coded 3137

The full report is sent to the SoifGo app, where you can see the temperature graph on your phone. 📊

Report Format

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).

16. Debugging

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

Common Issues

SymptomPossible Cause
Display shows "--"Sensor disconnected or faulty
Display shows blinking "FF"Fault input triggered (after Fault Delay)
No serial outputWrong baud rate, TX not connected
IR not respondingWrong remote codes — verify via terminal
Relay chattersDelta too small — increase it
False fault trips on motor startIncrease Fault Delay (F parameter) to 1-9 seconds

17. Building & Programming

🔌 On-Board Programmer Socket

The board includes a programmer socket for easy development and in-circuit programming. You can use any standard AVR programmer, such as USBasp.

Note: Due to space and layout constraints, the on-board socket is a single-row 6-pin header, while the USBasp programmer uses a 2×3 (two-row, 6-pin) connector. To bridge the difference, use male-to-female jumper wires, or build your own socket adapter.

💾 Ready-to-Flash HEX Files

A dedicated HEX file is provided for each of the three supported microcontrollers (ATmega8, ATmega88P, ATmega328). Download the one that matches your chip and program it directly — no modification needed.

🔧 Not Familiar with BASCOM?

Don't worry. If you don't know BASCOM-AVR, simply paste the source code into an AI assistant and ask it to translate the code into a language you're familiar with (C, Arduino, MicroPython, etc.).

Recommended Workflow

  1. Pick the HEX file that matches your MCU
  2. Connect USBasp to the programmer socket (use jumper wires if needed)
  3. Flash the MCU
  4. Verify via serial terminal at 9600 baud

Advanced users who want to modify the source can open the BASCOM project, adjust remote codes or parameters, recompile, and program the resulting HEX.

On-board programmer socket
Figure 15: On-board programmer socket

18. Downloads & Links

PCB and Schematic Files Atmega 328P

📦 Download All File (MEGA)

🔗 External Links

📱
SoifGo App
Mobile interface for TEMP209
Note: The ZIP package includes BASCOM source, HEX firmware for all three MCUs, PCB Gerbers, and schematic PDF.

19. Test Videos

Watch TEMP209 in action. These videos demonstrate real-world testing, programming, remote setup, logging, and fault protection.

🎬 Video 1: Programming & Flashing

Video 1: Programming & Flashing

🎬 Video 2: Setting Up a Different RC5 Remote (Example)

Video 2: Setting Up a Different RC5 Remote (Example)

🎬 Video 3: Temperature Logging & SoifGo Connection

Video 3: Temperature Logging & SoifGo Connection

🎬 Video 4: Fault Potentiometer Calibration (Example)

Video 4: Fault Potentiometer Calibration (Example)
📹 Videos are hosted on MEGA and streamed directly via embed player. If a video does not load, check your internet connection or open the MEGA link directly in your browser.

20. Changelog

v1.0 — Initial Release

Note: This is the first public release. Future versions will be listed here.

21. About & License

TEMP209 is an open-source educational project by Saeid Moghadam.

License

Open Source — Educational Purpose.

Credits

Contributions welcome! Fork, improve, and share back.

For contact and more tutorials, see the main SoifGo page.


⬅ Back to Home