Example 4


Make a thermometer with an LCD text display, and a connection to a Processing graphing application.

Learning Goals:

  • Use an LCD for untethered text display
  • Serial output to a host computer
  • Real-time data visualization with Processing

This is just an example, not an exercise.

The idea is to have a temperature sensor on the Arduino so that it can be a thermometer. The Arduino determines the temperature by reading the sensor and displays the result on a text LCD display. This means that the application can function when the Arduino is disconnected from the host computer.

Simultaneously, if the Arduino is connected to the host computer, it transmits the temperature data to an application on the host, which can then display that data graphically, or otherwise process it.

While this application is not that exciting nor innovative, it serves as an example for how real-time data collection and visualization can be performed with an Arduino. In this case, I have written a small processing application to display the temperature graphically.

Below are some images that describe this system. On the left is the circuit description for connecting the temperature sensor and the LCD, with the backpack kit interface from Adafruit. In the center is a view of what the LCD should look like when the Arduino program is running. And on the right is a screen shot of a Processing application that displays the temperature data in real-time on the host computer.


click to view larger

click to view larger

click to view larger

The temperature sensor gets connected like the trim pot from Exercise 2: there are three pins to connect with wires. The middle one is the data pin, on which you read the analog value. The outer ones go to +5V and GND. It doesn’t matter which one is which.

For the LCD, this version uses a “backpack,” which is an extra circuit board on the the back that allows you to connect it to the Arduino with just two pins (plus two for GND and 5V). Without this backpack, the LCD requires 6 pins (plus power and ground). This example uses the I2C protocol. All of this is documented on the Adafruit website for this backpack kit.

Finally, the Processing application displays the simple bar graph of the temperature value and uses the same serial interface over USB that you use to connect the IDE to the Arduino for uploading your sketch code.

For the Arduino code, copy and paste from here: Thermometer.

For the Processing code, copy and paste from here: ThermoGrapher.