Skip to content

Create a real-time plot of analog signals using Arduino and pyqtgraph

Notifications You must be signed in to change notification settings

JaFeKl/joystick_real_time_plot_with_pyqtgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Real-time plot of analog joystick readings using pyqtgraph

In this project, the analog signals of a joystick module are plotted in real-time using the Python's pyqtgraph library. The joystick signals are processed using an Arduino Microcontroller.

Table of contents

Arduino set-up

The following image shows the Arduino schmetics to work with a commonly available joystick module. These joysticks basically consist of two potentiometers (for x- and y-axis) as well as a single button (z-direction).

The five pins of the joysticks are connected as follows:

Arduino schematics Pin connections
awd
Pins JoystickPins Arduino
GNDGND
+5V5V
VRxA1
VRyA0
SW11

The corresponding Arduino code simply reads the analog values of the joystick and prints them on the serial port to be accessable by Python. In this example, the analog readings are published with 200 Hz. We can now use Python to access the serial port and plot the streaming data in real-time.

Real-time plotting using pyqtgraph

Although matplolib is the common plotting library for Python and allows creating beautiful graphics, pyqtgraph comes with the possibility to update plots much faster, which allows real-time data plots with high frequencies.
The script real_time_plot.py creates a real-time plot of the analog output (0-1023) for y over x. Note that we are not plotting single signal pairs but arrays of the last 20 points. The gif below shows how the real-time plot might look like.

I also created an explaining youtube video on this project. Just click below.

About

Create a real-time plot of analog signals using Arduino and pyqtgraph

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published