Temperature Monitoring System Using Arduino and Python Live Data Plotting

In this article, you will learn how to use a Temperature Monitoring System Using Arduino and Python Live Data Plotting. Creating this project will let you do serial communication from Arduino to Python. This is very useful if you are gathering data live or constantly monitoring temperatures.

Watch the video here to see the Temperature Monitoring Device Using Arduino and Python Live Data Plotting

Temperature Monitoring System Using Arduino and Python Live Data Plotting: Creating the Device

Here are the steps in interfacing the sound module in Arduino.

  1. Gathering the Components

    The first thing to do is to collect the hardware components for the Arduino device.
    Arduino Uno
    DHT22 Digital Humidity and Temperature Module

  2. Connecting the Components

    Connect the components to the Arduino Uno. Please refer to the wiring diagram below.

  3. Coding the Arduino

    Third step is about coding the Arduino device.

  4. Upload the Sketch

    After coding the Arduino, upload the sketch.

  5. Coding with Python

    Next is to create a project in Python and write codes that will read the serial monitor of the Arduino, save it in a CSV file, and plot it on a graph.

To start this project, you need the following:

Temperature Monitoring System Using Arduino and Python Live Data Plotting: Detailed Explanation

QtyComponent
1Arduino UNO
1DHT22 Humidity and Temperature Module

Arduino UNO

Arduino Uno
Arduino Uno

We will be using an Arduino Uno microprocessor board. Arduino Uno is suitable for any projects and is the cheapest and widely used microprocessor board in the Arduino family. This is great for all kinds of IoT projects.

Digital Humidity and Temperature Module

DHT22 Humidity and Temperature Module
DHT22 Humidity and Temperature Module

This project uses a DHT22 sensor. You can also use the DHT11 sensor module which is cheaper. Take note that the latter is less accurate. DHT22 will read every 2 seconds for it to detect temperatures accurately. Be careful with the timing in the code.

Wiring Diagram

For the wiring, you just need to connect the Signal to Digital Pin 2, the Vcc to 5V and the GND to the Ground pin of the Arduino. If you are using a standalone temperature sensor, it has an extra GND pin that you can leave unconnected.

DHT22 Arduino Wiring
DHT22 Arduino Wiring

Temperature Monitoring System Using Arduino and Python Live Data Plotting

For the code, you just need to allow the sensor to read every second and display it on the serial monitor. No texts or labels – just the value. Upload this to the Arduino board.

Python Code

Now that our device is ready, you can now create live data plotting. First is to install pyserial and matplotlib. Pyserial is the package that lets you communicate with the Arduino while the matplotlib creates the data plotting.

To do this, open PyCharm 2021 and go to View>Tool Windows, Python Packages.

packages window
packages window

A window will appear below. search for pyserial and matplotlib. Click install and wait for it to finish. after that you are good to go.

install packages
Search and install packages

Now create a new project in PyCharm and paste the code below.

Output

Now, run the program. The sensor reads the temperature and the Python program plots it. The temperature is at the Y-axis and the time is on the X-axis.

Line plot decreases as temperature decreases
Line plot decreases as temperature decreases

Summary

And that’s it! You have successfully created an Temperature Monitoring System Using Arduino and Python Live Data Plotting! All you need to do is code the sensor and assemble. Then, create a project in Python and install Pyserial and Matplotlib packages, check the code above and run the program! This project is versatile and can be combined with other projects.

Download

Inquiries

Feel free to write your questions about the Temperature Monitoring System Using Arduino and Python Live Data Plotting at the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.