In this project you will learn how to connect your Pi 4 to OKdo IoT Cloud and send sensor data using Python. The OKdo cloud allows you to view your sensor data from any connected device like a browser or smart phone.
hdmi_force_hotplug=1
On your host computer go to https://www.okdo.com/do-iot/ and sign up for a free account. Once that is complete it will take you to the Playground page where you can setup your devices
• Select Devices and click +Connect A Device
OKdo uses the AllThingsTalk platform who provide a Python Library to make it easier to connect devices to the service.
git clone git://github.com/allthingstalk/python-sdk.git
This will clone AllThingsTalk Python SDK from Github
cd python-sdk/
sudo pip3 install
Everything is now setup to begin coding and sending data
#!/usr/bin/env python
from time import sleep
from sense_hat import SenseHat
sense = SenseHat()
sense.clear()
import allthingstalk as talk
class t(talk.Device):
The Python client has place holders for the DEVICE TOKEN and DEVICE ID that must be replaced with the ones from your OKdo IoT Cloud account.
After a few seconds the asset fields in your console should update every few seconds with your sensor readings
MISSING PICTURE
If the web page doesn’t update, refresh your browser to see the latest data. If all is well it should update every 5 seconds.
If that doesn’t work, try reloading the file into Thonny and running it again.
You should now have your Pi connected to the OKdo IoT Cloud sending sensor readings for temperature, pressure and humidity every few seconds.
Using the principles learnt in this project you should be able to setup many different kinds of sensors connected to the Pi and send their data to the cloud.
Your data is accessible from other devices connected to the internet so you can access it from almost anywhere.
The OKdo service also has the ability to setup rules which can alert you if sensor readings reach a threshold value using web, email or push notifications.
From a quick tap to smashing that love button and show how much you enjoyed this project.