Real Time Graph - Ultrasonic Sensor With Raspberry Pi


Introduction: Real Time Graph - Ultrasonic Sensor With Raspberry Pi

Plot Graph for Distance measured by Ultrasonic sensor v/s time using Plotly

Gathering data from sensor is cool. But lot of data can be confusing and it will be difficult to interprete how it varies. So how about streaming it , It is visually more understanding . Plot graph using Plotly! Its fun!

Step 1: Make Circuit

Things needed

1.Raspberry Pi 2

2. 2 resistors (330 ohm and 470 ohm )

3. Jumper wires

4. Ultrasonic sensor

5. wifi module

6. USB cable (to power pi)

7. BreadBoard

So to begin with make a circuit as shown in figure. Connect the GPIO pins as in figure. Make sure its right.

Step 2: SSH Into Your Pi

Once your done with circuit. SSH into your pi. I have used putty.

Login using your credentials.

Step 3: Create Plotly Account

Create plotly account. Its free!! once u create go to settings which appears on top right corner of screen.

Note down your username, api key and streaming key If streaming key doesn't appear click on add new token.

Step 4: Write Python Code

Write the python code for measuring distance from ultrasonic sensor. What the code does is , it gets the distance from ultrasonic sensor and plots it v/s time using plotly.

For code go to -- >

Clone or download the code and use it !

Make sure to mention your api key ,username and streaming token in code. You must change it accordingly.

use python (i.e python in this case )to run the code .

Happy Streaming !! :)



    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Oil Contest

      Oil Contest

    2 Discussions

    Great Raspberry pi project. I am going to try this with a pi zero. That will be a lot cheaper than using an Arduino.

    1 reply