Introduction: Arduino Thermostat With Relay for Colour Film Development

Picture of Arduino Thermostat With Relay for Colour Film Development

I did this project to have an help for develop C41 or E6 color films.

What is it:

This is a thermostat connected to a water heater for camping. Using the heater to warm up a bucket of water where bottles and a developing tank are plunged. The idea is to start the device and make the whole things inside the water reaching the working temperature.

Indeed you can use this project as common thermostat connected to a 220V multiplier with a Relay.

Here's what you need:

  • Arduino board (also Nano would do the trick).
  • SainSmart LCD with keypad (Just to keep the connection neat and to avoid huge usage of wires.
  • Sensor DS18B20.
  • Relay board (I got one from SainSmart).
  • Any multiplier

You can see a simple schematic in the picture. When it said Arduino UNO, you should consider it as the SainSmart LCd with keypad.

To keep it safe and simple to build, I did the multiplier's connection in order to have a "two step" connection into the AC circuit. First just a wire with a female connectors and the classic AC connector, then the wire from the very multiplier. One wire goes straight to the AC, the other runs into the NC (Normally closed) port of the Relay and then form the COM port to the AC circuit. Image the relay as a switch, it's connected the same. As I did it, it is connected with the normally closed port, that means that if you connect just the relay and the AC, the multiplier works normally, so be careful if you want to plug a huge heater resistor like the one I used.

NOTE to the SainSmart LCD with keypad:

I really recommend to use it because it's cheap but gives you the functionality of a LCD with 5 buttons all in one board ready to use! The version I got has already pins ready to use on the top. It's like having Arduino with screen.

Step 1: The Code

Here we declare libraries and modules:

First the Temperature Sensor DS18B20:

#include "OneWire.h"
#include "DallasTemperature.h"
#define ONE_WIRE_BUS A2
OneWire ourWire(ONE_WIRE_BUS);
DallasTemperature sensors(&ourWire);
DeviceAddress thermometer;

Then an improved library to read the keypad from the SainSmart module. Here you find it:

#include "LCD_Keypad_Reader.h"
LCD_Keypad_Reader keypad;

LCD Library

#include "LiquidCrystal.h"
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

Relay's PIN

#define RELAY1 A5 //Relay's pin

Here we define variables and are pretty self explanatory:

err -> sensor error: if you haven't calibrate the sensor, just put 0 in that. To calibrate: click here.

tMin and tMax are the minimum and maximum temperature. You won't need the tMax, but I put it there eventually to use it in future sketch.

val and state store the variables to activate relay's board and its status.

int err = -0.5;
float tMin = 37.7;
float tMax = 38.3;
int val = 0;
int state = 0;

Then we go to the setup:

RELAY1 set as output, activate Serial for debugging and thermometer resolution to 11bit

void setup(){
  pinMode(RELAY1, OUTPUT);
/* Serial printing added for debugging */
  Serial.println("Misura la temperatura con sensore DS18B20");
  sensors.setResolution(thermometer, 11);       //Sensor resolution

The loop:

Temperature request and error added then printed on serial.

void loop(){
  sensors.requestTemperatures();                  //Temperature request 
  float tCal = sensors.getTempCByIndex(0) + err;  //Temperature calculation in order to consider errors
  Serial.print("Temperatura = ");
  Serial.println(" gradi C");

Functions: Pressing UP_KAY the sketch will activate the relay and starting the function heater();

Pressing UP_KEY again to deactivate the relay board.

val = keypad.getKey();
  if (val == UP_KEY) {  
    state = 1 - state;  
  if (state == 1) {  
  else {  
    digitalWrite(RELAY1, LOW);            //Relay disconnected -> "OUT"
    lcd.print("Heater is:   OUT");
/** LCD temperature print **/
    lcd.print("Temp.:     ");
    lcd.print(tCal, 1);

Core function of the relay board:

void heater(){
float tCal = sensors.getTempCByIndex(0) + err;  //Request temp. and calculating error
    lcd.print("Heater is:");
    if(tCal < tMin /*&& tCal < tMax */){        //If statament to activate relay when tCal is minor of tMin
      digitalWrite(RELAY1, HIGH);               //Relay ON
      lcd.print("    ON");
    }else {
      digitalWrite(RELAY1, LOW);                //Relay OFF
      lcd.print("   OFF");

Step 2: Some Data

I tried only once so far, and all is working quite well, not short circuit and no electrocution so far :-)

However you might want to considerate that when the working temperature is reached, the heater start warming the water up. In circa 1,5 / 2 minutes the sensor feel the changing od temperature and block the relay but the heater already warmed the water too much (for color developing) and the water reaches easily 1,5°-2°C more than tMin.

Temperature for the process to use is 38°±0,3°C, that means we should stay between 37,7° and 38,3°. The heater should warm up the water for about 0.6°C max.

I will do more experimentation about it and try to make the heater works just for a limited amount of time. I will try with 30" or 1'.

However, now it's matter of software, and here you can use a thermostat for about 25€. You can connect it to any kitchen supply or any other AC device. Free your creativity to use it the way you want.

Step 3: Add Another Sensor to Keep Acids Controlled

If you want to make the thermostat more efficient, put another DS18B20 sensor in order to have:

Temperature of the water T1 on pin A2
Temperature of the acid T2 on pin A2.

Then download the code. Here's how it works (Read also the comments inside!):

Lines 29 - 35
Variables to operate: err1 and err2 are the sensors error. You should calibrate the sensors in order to have an accurate temperature read. You can leave it to 0 if you don't want to calibrate 'em.

Lines 47 - 48
The sensors read the temperature

Lines 54 - 55
Variables T1 and T2 are created on the readings and the errors.

Lines 73 - 85
Here we get the input from the keypad. If UP_KEY is pressed the function heater(); starts. If it's pressed again, the function stops.

Lines 93 - 107
heater(); function.
If T2<38°C AND T1<42°C, the heater starts.
If T1<38°C (and T2 is at least 38°C), the heater starts.
If none of above, heater stops.


DIY Hacks and How Tos (author)2017-12-24

Nice project. You should definitely enter this into the Arduino contest that is currently running.

Sounds fun! How do I do that?

Never mind, I figure it out by myself.

Thanks for the advice!

Keep doing!

About This Instructable




Bio: I'm curious and therefore I can do a lot and nothing at the same time
More by Big.Jack.Jazz:Arduino Thermostat With Relay for Colour Film Development
Add instructable to: