Led matrix with HT1632C controller (6)

luca 18/02/2013 4

Some readers wrote me asking more “real” examples using this display… in this post I’ll write a sketch to use it as a thermometer.

The sensor

I chose the DS18B20 sensor from Maxim Integrated to read the room temperature.

The connection to Arduino is very simple: the sensor has 3 pins (VDD, GND e DQ) and I joined DQ to pin 2 of my Arduino:

This sensor provides 2 supply modes:

  • using the VDD pin
  • parasite, through the DQ pin (in this mode, VDD must be grounded)

In both modes, DQ pin requires a 4.7Kohm pull-up resistor.

The library

Miles Burton developed a convenient library to talk with Maxim’s sensor… here’s how to use it:

- include in your sketch both OneWire and DallasTemperature libraries:

#include <OneWire.h>
#include <DallasTemperature.h>

- init the library passing the pin you connected the sensor to:

#define ONE_WIRE_BUS  2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&amp;oneWire);

- read the temperature value (float) – if you connected only a sensor, it will have index 0:

float float_temp = sensors.getTempCByIndex(0);

The display

Use the sprintf function to prepare the complete text to be displayed:

sprintf(display_string, "Temperature: %s", string_temp);

A little problem is that sprintf does not support float type; you have to convert it into a string variable.


The sketch is available on Github, here’s how it works:


  1. Robert 25/09/2013 at 02:23 - Reply

    How would I display scrolling text while the text itself is changing?

    For example, let’s say I want a clock with seconds. How would the transition from, say, 8:39:59 to 8:40:00 work?

  2. Robert 25/09/2013 at 02:28 - Reply

    As for your thermometer example: I see the sign shows the temperature in hundredths of a degree — but by the time the sign scrolls around to show the numbers, won’t they already be wrong?

  3. Thongchai 14/08/2014 at 06:49 - Reply

    If I want to add the date to the code here?

  4. kevin 13/11/2015 at 15:39 - Reply

    Hi Luca,

    I have problem, if the temperature is 20c, and i only want the led to light up when temperature reach 22c, how could I change it?

Leave A Response »

Click here to cancel reply.

This website uses cookies to ensure you get the best experience on our website maggiori informazioni

Questo sito utilizza i cookie per fonire la migliore esperienza di navigazione possibile. Continuando a utilizzare questo sito senza modificare le impostazioni dei cookie o clicchi su "Accetta" permetti al loro utilizzo.