Heating control system for biogas fermentors

Heating bath temperature controller.

Similar projects worth following
This project is basically a heating controller for heating bath temperature that is used in the biogas lab in my university. It can be used to control the heating of anything else.

The main goal was to design heating bath temperature controller with as minimal overshoot as possible and good temperature control stability.

I made practically the same thing using a RaspberryPi and UniPi expansion board but it was a bit too complex and expensive. This solution might be a lot cheaper.


  • Temperature resolution of 0.1°C
  • Temperature range 20-70°C
  • Maximum overshoot < 0.5°C
  • Temperature stability of +-0.1°C
  • To fit the regulator in fuse box two positions at max
  • Simple control with display

It is basicaly a Sous vide for sh*t :))

Main hardware components

  • ATTiny1634 - mainly because of 16 kB flash and price
  • LM35DZ temperature sensor
  • 128x64 px SSD1306 OLED display
  • 600 W heater in ca 100 l water tank
  • SSR to drive and control the heater


Everything is based on the PID algorithm with little tweak to avoid overshoot for different required temperatures (for different step sizes). This means that the classic control loop is used. Temperature is measured by LM35DZ sensor that gives 10 mV/°C.

To control heater power the duty cycle control is used. That means the heater is switched ON and OFF for certain amount of time from a fixed period. The result is possibility to set heater power from 0-100%. This can be achieved because of the high thermal capacity of water. (the process is "slow")

Control algorithm was simulated in Matlab/Simulink. It is all about Integration gain changing for different step sizes (step from actual to needed value).

To design PI(D) control I had to do 3 things:

  1. Measure and identify the system
  2. simulate the system in Matlab/Simulink and find the right setting for the controller
  3. write some code to transfer it to the ATTiny

1. Identification

System identification was done using the heater at full power and measuring the response of the system (temperature rise). Measured data were approximated using 1st order lag function.

system identification

2. Simulation

There is a basic control loop on the next picture with some blocks added to make the model behave more like a real system.

Simulink model

The idea behind the control algorithm i have used is to use PI control with a little tweak. If you want to use the PI control you need to tune the constants (P, I, D) of the regulator. The problem is one setting is good only for one situation (step size). So I change the setting of the regulator according to a situation (step size). I believe it is called gain shifting.

todo rest...

3. SW and control algorithm

control algorithm looks like this

The main loop lasts 10 s. Each 10 s the setpoint and the temperature is measured and the controller output is calculated. If there is a setpoint change the algorithm computes new Ki constant and re-inits the controller. If the actual temperature is 0.1 °C below the setpoint It calculates new Ki constant because it makes the controller bit more "aggresive" and it can react to overshoot better.


TODO and problems

  • PT100/PT1000 interface maybe?
  • different settings for different heaters and/or water volumes
  • Adding LM4040 2.5 V reference and opamp on mcu input to scale the sensor output and increase the accuracy.



I have used Arduino core from SpenceKonde

SoftI2CMaster library

Arduino PID library

Arduino Timer library

todo rest....

  • 1 × ATTiny1634 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × LM35DZ - waterproof Sensors / Temperature, Thermal
  • 1 × 78L05 voltage regulator SOI8 Power Management ICs / Linear Voltage Regulators and LDOs
  • 1 × SSD1306 OLED I2C display 128x64 pixels that one from china that can be bought on ebay :)))
  • 1 × PCB - OSHpark Electronic Components / Misc. Electronic Components

View all 19 components

  • debugging

    Robert12/30/2016 at 18:26 0 comments

    I've been testing the controller for some time and there is a bug. Unfortunately it looks like it is random. After some time the output of PID algorithm starts to be 0 no matter what. So I'm now debugging it. I made some changes in the code but it is shooting in the dark. :-/

  • assembly...

    Robert10/13/2016 at 19:14 0 comments

    I finally got to assemble the boards today. I have some PCBs from OSHpark and some from DirtyPCBs. Both great.


    I also make my own temperature sensors from LM35 because the ones from ebay that should be waterproof are not. But you can buy the metal ends (ebay) and use some gooping resin to waterproof it.

    Temperature sensors

    Final board without OLED display look like this.

    I will continue soon to finish it.

  • fuse box

    Robert09/22/2016 at 10:41 0 comments

    This is what it should look like in the fuse box. On the right the former thermostat that will be replaced by the controller on the left. Print is ugly it was a first test to try out the dimensions.

  • testing...

    Robert09/04/2016 at 20:12 0 comments

    I have been testing the only prototype I currently have for about 6 weeks and it runs without any problems.

    I have also calibrated the temperature sensor and it looks like there is constant error of -0.6 °C from the actual temperature (in range from 20 to 60 °C) when reading from LM35DZ with the internal voltage reference. That is actually quite nice. I don't need to use the external voltage reference.

    I have also drawn the front panel and my friend 3D printed it for me.

  • Almost done...

    Robert08/23/2016 at 22:03 0 comments

    Writing logs is not fun....

    I made a big progress since the start. I have learned a lot. The controller is almost finished now. Some of major problems were

    • Minimal voltage on AREF is 2.0 V so I cannot use LM4041 for better accuracy.
    • There was a problem using analogReference(INTERNAL) that was repaired in newer Arduino core build. (I think because it works now)
    • I have learned that I2C communication has some impact on ADC reads (noise) so it is better to read from sensor between LCD refreshes. Reading from ADC several times and averaging the value also helps.
    • When you order something from China it is possible that the product will have different pin out. I had to redo the pcb because of the LCD...

    Current version of PCB is v2.1.

  • Prototyping on breadboard done

    Robert04/09/2016 at 18:31 0 comments

    Prototyping on breadboard has been done. I'm using USBasp to program the ATTiny1634 using the Arduino software. So far the simplest way how to get the results.

    • ADC values jump so this needs some tweaking and filtering
    • I don't know why but the Arduino core works bit strange using internal 1V1 reference. The ADC input then works in 8b resolution that overflows to higher byte when the input is high enough. It looks like the analogRead() method is badly implemented.
    • I'm using softI2Cmaster library to get the OLED display working. So far works great

View all 6 project logs

Enjoy this project?



nodemcu12ecanada wrote 12/03/2020 at 16:54 point

DS18B20 sensors come in a waterproof design. A NodeMCU controller can host a free web page for monitoring and control instead of hardware. It can send the date to a cloud spreadsheet if you want.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates