Hackers – Temperature Control, Part 1


In Hackers, we started work on a short project for a temperature-controlled soldering station. As shown on the whiteboard above, the basic idea is:

  • A temperature sensor is connected to an Arduino (analog input)
  • A soldering iron, with its tip located near the sensor, is wired to the mains via a relay switch
  • The Arduino can control the relay switch to turn the soldering iron on/off
  • This is the basis for a simple bang-bang controller: we have a target temperature (e.g. 200 degrees) and a tolerance (e.g. ±10 degrees), then you turn it on if the temperature is below 190 degrees and turn it off if above 210 degrees.

We noted that since there will be space between the soldering iron tip and the temperature sensor, the temperature it will read will be lower than the tip temperature.

As the whiteboard shows, this project also involved discussion of: wiring for the thermocouple; how breadboards are wired; normally-open vs normally-closed relay switches.

One group used a LM35 temperature sensor – here are its specs, and the group found it interesting to see how detailed and useful these data sheets are: http://www.ti.com/product/LM35

The other group used a potentiometer to simulate temperature, so they could test it working over its full range, as shown here:


Below is the code for reading and displaying the temperature. Next steps will be to integrate it with the relay.

// Michael Madden, CoderDojo Athenry
// Reading a temperature sensor.

// The temperature sensor is an LM35 - here are its specs: http://www.ti.com/product/LM35 
// THe temperature range is -55 to 150 degrees celcius.
// Its output voltage pin is connected to an analog input on the Arduino (A1),
// from which we read a value in the range 0-1023, so we convert them.

void setup() {
  // Just needed for print statements to work

void loop() {
  // Read the temperature sensor: get a value in range 0-1023
  int val = analogRead(A1);

  // From the analog input, we get a value in the range 0-1023
  // and we need to convert it to a temperature in the range -55 to 150 degrees.
  // The two lines below achieve this in differnet ways and give the same result.
  int temp1 = (val/1023.0)*205 - 55;
  int temp2 = map(val, 0, 1023, -55, 150);

  // Print out the raw value and converted temperature
  Serial.print("Sensor value = ");
  Serial.print("\tTemperature 1 = "); 
  Serial.print("\tTemperature 2 = ");

  // Wait 100 milliseconds before reading the sensor again


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s