GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Professional
  • EDU
  • Distributor
  • Customer Support
  • Shop
  • Documentation
  • News
  • Today's Deals
  • Community
  • SparkPNT (Position, Navigation & Timing)
  • My Account My Account
  • Featured Products
  • GPS/GNSS
  • Sensors

This view

  • Original page
  • New address

GeezerVison is showing learn.sparkfun.com — Graph Sensor Data with Python and Matplotlib - SparkFun Learn

  • Home
  • Tutorials
  • Graph Sensor Data with Python and Matplotlib

Graph Sensor Data with Python and Matplotlib

≡ Pages
Contributors: Shawn Hymel
Share
Use this URL to share:
Share on Tumblr Submit to reddi
Share on Twitter Share on Facebook Pin It

Introduction

Python is a wonderful high-level programming language that lets us quickly capture data, perform calculations, and even make simple drawings, such as graphs. Several graphical libraries are available for us to use, but we will be focusing on matplotlib in this guide. Matplotlib was created as a plotting tool to rival those found in other software packages, such as MATLAB. Creating 2D graphs to demonstrate mathematical concepts, visualize statistics, or monitor sensor data can be accomplished in just a few lines of code with matplotlib.

Graphing temperature data with Python and matplotlib

The Raspberry Pi is a great platform for connecting sensors (thanks to the exposed GPIO pins), collecting data via Python, and displaying live plots on a monitor.

Notice: This tutorial was written with Raspbian version "June 2018" and Python version 3.5.3. Other versions may affect how some of the steps in this guide are performed.

Required Materials

To work through the activities in this tutorial, you will need a few pieces of hardware:

Note: As an alternative, you could also use the the Qwiic cables and the Qwiic TMP102 to easily connect without needing to solder or connect to the four pins.

SparkFun Digital Temperature Sensor - TMP102 (Qwiic)

SparkFun Digital Temperature Sensor - TMP102 (Qwiic)

SEN-16304

The SparkFun TMP102 Qwiic is an easy-to-use digital temperature sensor equipped with a couple of Qwiic connectors for easy I2…

$8.23
SparkFun Qwiic SHIM for Raspberry Pi & NVIDIA Jetson Orin Nano

SparkFun Qwiic SHIM for Raspberry Pi & NVIDIA Jetson Orin Nano

DEV-15794

The SparkFun Qwiic SHIM for Raspberry Pi is a small, easily removable breakout that easily adds a Qwiic connector to your Ras…

$1.95
Qwiic Cable - Breadboard Jumper (4-pin)

Qwiic Cable - Breadboard Jumper (4-pin)

PRT-14425

This is a jumper adapter cable that comes pre-terminated with a female Qwiic JST connector on one end and a breadboard hookup…

Retired
Qwiic Cable - 200mm

Qwiic Cable - 200mm

PRT-14428

This is a 200mm long 4-conductor cable with 1mm JST termination. It’s designed to connect Qwiic enabled components together…

Retired

Optional Materials

You have several options when it comes to working with the Raspberry Pi. Most commonly, the Pi is used as a standalone computer, which requires a monitor, keyboard, and mouse (listed below). To save on costs, the Pi can also be used as a headless computer (without a monitor, keyboard, and mouse).

Note that for this tutorial, you will need access to the Raspbian (or other Linux) graphical interface (known as the desktop). As a result, the two recommended ways to interact with your Pi is through a monitor, keyboard, and mouse or by using Virtual Network Computing (VNC).

Raspberry Pi LCD - 7" Touchscreen

Raspberry Pi LCD - 7" Touchscreen

LCD-13733

This 7" Raspberry Pi Touchscreen LCD provides you with the ability to create a standalone device that can be utilized as a cu…

$88.30
Multimedia Wireless Keyboard

Multimedia Wireless Keyboard

WIG-14271

With Single-Board Computers (SBCs) on the rise, it is a good idea to have an easy way to interface with them. Operating on a …

$29.95 $19.95
SmartiPi Touch

SmartiPi Touch

PRT-14059

The SmartiPi Touch is a case and stand for the official [Raspberry Pi 7" Touchscreen LCD](https://www.sparkfun.com/products/1…

Retired

At the bare minimum, you need a breadboard and some jumper wires to connect the Pi to the TMP102 sensor. However, the Pi Wedge and some M/M jumper wires may make prototyping easier.

Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

Jumper Wires Standard 7" M/M - 30 AWG (30 Pack)

PRT-11026

If you need to knock up a quick prototype there's nothing like having a pile of jumper wires to speed things up, and let's fa…

$3.50
SparkFun Pi Wedge

SparkFun Pi Wedge

BOB-13717

This is the SparkFun Pi Wedge, a small board that connects to the 40-pin GPIO connector on the Raspberry Pi and breaks the pi…

$13.50

Suggested Reading

If you aren't familiar with the following concepts, we recommend checking out these tutorials before continuing:

Serial Terminal Basics

This tutorial will show you how to communicate with your serial devices using a variety of terminal emulator applications.

Raspberry Pi 3 Starter Kit Hookup Guide

Guide for getting going with the Raspberry Pi 3 Model B and Raspberry Pi 3 Model B+ starter kit.

Getting Started with the Raspberry Pi Zero Wireless

Learn how to setup, configure and use the smallest Raspberry Pi yet, the Raspberry Pi Zero - Wireless.

Python Programming Tutorial: Getting Started with the Raspberry Pi

This guide will show you how to write programs on your Raspberry Pi using Python to control hardware.
Please note: If you have trouble seeing any of the images throughout this tutorial, feel free to click on it to get a better look!
Python Logo
Share
Use this URL to share:
Share on Tumblr Submit to reddi
Share on Twitter Share on Facebook Pin It

View as a single page Next Page →
Prepare Your Pi
Pages Introduction Prepare Your Pi Hardware Assembly Introduction to Matplotlib Plot Sensor Data Update a Graph in Real Time Speeding Up the Plot Animation Resources and Going Further
Comments 1 Single Page Print
  • Tags
    • Data Logging
    • Logging
    • Programming
    • Projects
    • Python
    • Raspberry Pi
    • Skill
  • License
  • Creative Commons tutorials are CC BY-SA 4.0
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.