Mid-Senior Engineers: Reinvent your career with Robotics, earning $100k-$200k+ in the next 90 days. Learn More

How to fetch data from dweet.io using Python (Tutorial)

Liz Miller Learn Robotics

About the Author, Liz Miller, Founder/CEO @ Learn Robotics

Liz graduated with a degree in Robotics Engineering from Worcester Polytechnic Institute and researched drones at UPenn's GRASP Lab. Liz is a former Raytheon Engineer, where she managed major $MM automation projects worldwide. Today, she's the driving force behind Learn Robotics, offering the Robotics Career Blueprint for Engineering Professionals and beginner courses through the Online Robotics Class. Liz is a third-generation entrepreneur who is all about the application of innovation in robotics, automation, and AI. Follow Liz on LinkedIn and Facebook.

Disclosure: Some of the links below are affiliate links. This means that, at zero cost to you, Learn Robotics will earn an affiliate commission if you click through the link and finalize a purchase. Learn Robotics is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a way for websites to earn advertising revenues by advertising and linking to Amazon.com.

Join our Private Discord Server, MakeRobots! Sign Up

For this tutorial, I’m going to walk you through the process of fetching data from dweet.io using Python.

Fetch Data from dweet.io using Python

dweet.io is a website that is similar to twitter but for connected devices. You can access sensor readings through a dweet.io URL in a JSON format. We will use this website to fetch data using a Python script.

Before we begin, I recommend that you have some prior knowledge of Python. We’ll be using Python3 for this lesson, but the libraries for this exercise work with previous releases of Python.

If you don’t know Python or aren’t familiar with dictionaries, loops, syntax, or connecting to webpages to retrieve data, then I recommend taking an introductory Python class before trying this tutorial. Feel free to try this tutorial out if you have some experience with Python. Just know that I won’t be covering common syntax or explaining every detail.

I’ve linked to the Python for Everybody webpage. This material is also offered on Coursera as a 5-class specialization. You can also take the Complete Python Bootcamp on Udemy. I highly recommend taking one of these courses if you want a thorough understanding of the fundamentals of Python.

Setup & Configuration

I’ve listed all the things you’ll need to complete this project.

You’ll need to code on a laptop computer (Mac, Windows, or Linux). You won’t be able to complete this project using a tablet or iPad.

Install Python on your computer. (Windows Tutorial | Mac Tutorial)

You’ll also be prompted to install a text editor for Python. Feel free to choose whatever text editor you like. I recommend Atom.io or Sublime Text. This tutorial will be showing you screenshots from Atom.io

Download the dweepy repository from Github. Follow the instructions in the README to setup dweepy.

Getting started with dweet.io

The dweet.io website gives you the option to have public (unlocked) or private (locked) devices. All of the unlocked devices are listed on the Discover page. We will be using a random unlocked device for this tutorial. You have the option when you’re developing your own devices to lock or unlock them. Locks are $1.99/mo and will keep your sensor data private.

Since we are just fetching data, we won’t need any actual hardware configured. You can learn how to send data to dweet.io with a Wemos D1 Mini (ESP8266) in this tutorial.

Navigate to the Discover Page on dweet.io

Your list of devices will vary from the screenshot below. Select one that has a few streams. I’m going to choose the “theBHVbooktemper2017” thing and capture Temperature & Humidity data.

fetch data from dweet.io using Python

Next, click on the name of the thing. It will open up a webpage and show you recent data.

fetch data from dweet.io using Python

Create the retrieve.py script to fetch data from dweet.io

Navigate to the folder where you installed the dweepy repository. Open up the dweepy folder and create a new Python script. Your Python file must be located inside the dweepy Github folder or you’ll receive an error when you run the script. I’ve called mine “retrieve.py”

We’re going to use the features of the dweepy repository to connect to theBHVbooktemper2017 and fetch these readings.

The script will work by prompting the user for a thing name. Next, we will use the dweepy repository to connect to the URL on dweet.io to obtain readings as a JSON file.

We can then parse the JSON using key-value pairs (from dictionaries) in Python. Lastly, we’ll print these readings in Terminal for the user to see. Here’s what you get once it’s all setup!

fetch data from dweet.io using Python

Code walk-through video

Since this code is simple enough to replicate, I’ve compiled a code walk-through video. Use this to gather inspiration for your solution! You can also download a copy of the example code below!

Here’s your download! Download retrieve.py example file

If you like these types of videos, be sure to subscribe to the Learn Robotics YouTube Channel

Next Steps

In the next tutorial, I’m going to show you how to log data from dweet.io into a local database.

If you liked this article, be sure to share it with a friend! And as always, if you have any questions, drop them below!

Experienced Engineer (Mechanical, Electrical, Computer, Software): If I offered to help you upgrade your engineering career to robotics, earning $100k-$200k+ in the next 90 days, would you take me up on that offer? Click here for details.
Liz Miller Learn Robotics

🚀 Pre-Launch: Become a "MakeR" with MakeRobots!

Hey Reader, 👋

Liz Miller, Founder/CEO, here with some Exciting News!

Learn Robotics just acquired MakeRobots™, an Online Robotics Community, and are prepping its Official Learn Robotics Debut in Late 2023.

MakeRobots™ is your one-stop-shop for learning, gaining coding, electronics, and robotics skills, connecting, and building robots for one low monthly membership!

Join MakeRobots™ at our Special Pre-launch Rate!
🤖 Access our Private Community & Robotics Courses
💬 Network, Collaborate, Connect with Other Makers
🔓 Only $5.99/month – locked in for life
⏱️ Pre-launch deal is Limited to the first 1,000 subscribers

This is a perfect opportunity for you to get into the fastest growing robotics community on the internet, at our ground-level, pre-launch membership rates.

👇 Click the button below to Claim your Pre-launch Membership and become a MakeR in the MakeRobots Community, today!

Learn Robotics Botly Favicon

MORE LEARN ROBOTICS ARTICLES