Arduino & ATtiny Temperature Display [Part - 1: Breadboarding]

Looking to make yourself a Tall-FatFree-TemperatureDisplay? I believe you’ve come to the right place.

This is a walk-through of what was involved in creating a Temperature Display using the TMP36 temperature sensor and the Sparkfun Seven Segment Bubble Display. We first perfect our recipe by flushing out the circuit and code with an Arduino Uno, and then make it fat-free by moving that sketch to a $2.50 ATtiny84 microcontroller. This is a great experiment if you’re relatively new to the world of Arduino or trying out the ATtiny for the first time.

Here is the menu and some pictures of what we’ll be serving today.

Part 1 - Breadboarding: Temperature Display with an Arduino

Part 2 - Perfboard Prototype: of Temperature Display with an ATtiny84 [Coming Soon!]

Part 3 - PCB Design: Making it all Permanent with a PCB [Coming Soon!]


Bill of Materials #

Part 1 of tutorial #


Temperature Sensor with Arduino [Part - 1] #

Step 1: Testing the Bubble Display #

Getting some code up and running #

Sparkfun has a very good tutorial that will help us get started with the Bubble Display. Follow the tutorial until you reach the section Example 1: Counter.

In summary, the following should have been done by now:

A shallow dive into the SevSeg library #

The counter example uses 3 functions of the SevSeg class, this is what they do:

Step 2: Testing the TMP36 sensor #

Now that we have a hang on the Display, it is time to try out the Temperature Sensor and understand how that works.

Note: Don’t pull off the breadboard connections that you just made for the Bubble Display. The TMP36 uses a different pin on the Arduino. Just carry on with the below steps and let the Display and its hookups sit on the board as is.

Adafruit has a very good tutorial on the TMP36. Follow the tutorial, download the sketch and observe the sensor working. In summary:

Step 3: Putting it together #

At this point we have the Bubble Display, Temperature Sensor and the Arduino hooked up the way we want them; all we need to do is modify and combine the above 2 sketches (Bubble Display Counter Sketch & TMP36 sketch) and have the temperature displayed on the Bubble Display.

Here is the sketch that does exactly just that. I’ve removed the counter logic from the Sparkfun Counter Sketch, and refactored the code to move the Adafruit temperature sensing code into a function:

int getTemp(boolean tempType)
{
   //getting the voltage reading from the temperature sensor
   int reading = analogRead(sensorPin);  

   // converting that reading to voltage, for 3.3v arduino use 3.3
   float voltage = reading * 5.0;
   voltage /= 1024.0; 

   // print out the voltage
   Serial.print(voltage); Serial.println(" volts");

   // now print out the temperature
   float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
                                                 //to degrees ((voltage - 500mV) times 100)
   Serial.print(temperatureC); Serial.println(" degrees C");

   // now convert to Fahrenheit
   float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
   Serial.print(temperatureF); Serial.println(" degrees F");
   if(tempType == 0)
   {
      return int(temperatureC);  
   }
   else
   {
     return int(temperatureF);  
   } 
}

The main loop essentially fetches the temperature in Centigrade and Fahrenheit, at certain intervals, and displays them with the SevSeg library’s DisplayString function call:

void loop()                     // run over and over again
{
   // At 500 display Centigrade, at 1000 
   // .. display Faranheit, clear interval
   // .. cnt at 1000
   if(interval == 500)
   {
     temperature = getTemp(0);
     sprintf(tempString, "%1s%3d", "C", temperature);
     interval++;
   }
   else if(interval == 1000)
   {
     temperature = getTemp(1);
     sprintf(tempString, "%1s%3d", "F", temperature);
     interval = 0;
   }
   else
   {
     interval++;
   }

   // Display
   myDisplay.DisplayString(tempString, 0); 
   delay(5); //waiting a second
}

…. And with that we now have a Temperature-Display and we’re at the end of PART - 1.

Download this sketch from #

https://github.com/subbdue/TinyTemperatureBubbleDisplay


…Continue on to Part 2 [Coming Soon!] #


Credits & Acknowledgements

All Sparkfun and Adafruit images have been linked from Source

 
6
Kudos
 
6
Kudos

Now read this

Facebook and The Open Compute Project ~ MakerFaire 2015

Facebook has been doing some fantastic work with the Open Compute Project. They were at the Faire to show-off Yosemite - the second revision of their micro-server system. OCP - The Open Compute Project # Engineering any data-center gear... Continue →