Temperature Control Embedded System Implemented In C


This project implements a PID temperature controller using the Romeo microcontroller board and the Temperature Control Board (TCB), both available on Curios Circuits website. The code is available on GitHub.

The program functions by controlling the voltage supplied to a 12V bulb using a PWM signal which in turn regulates the temperature read by a thermocouple present right next to the bulb. The PD controller on the microcontroller is tuned  to reach a target temperature that can be altered using the buttons on the Romeo board. The initial target temperature is set to 35 °C. Below is a short clip illustrating how the system works.


The Romeo board behaves similar to an Arduino Leonardo using the ATmega32u4 chip. Rather than programming the chip using an Arduino IDE it was programmed using C and GNU C complier available from WinAVR toolchain.

A generic square placeholder image with rounded corners in a figure.

The board is wired as below.
Vcc (TCB) -> 5V (Romeo)
S (TCB) -> Analog 0 (Romeo)
GND (TCB) -> GND (Romeo)
Bulb (TCB) -> M2 (Romeo)

The wires for the bulb are connected to the Motor pins of the Romeo board which provide a PWM signal to power the bulb. The max voltage to the bulb is 12V. The thermocouple is set right next to the bulb for accurate temperature reading. The polarity of how the bulb is wired to M2 pins does not matter in this case. Once the bulb was up and running the next step was to tune the PD controller used in this project.

In order to tune the Kp and Kd I wrote a MATLAB script that plotted the temperature values vs. time. This allowed me to compare the affect of the Kp and Kd on different output parameters like rise time, overshoot, steady state error and steady state oscillations.