So i have wanting to do some IOT stuff with the pi-top and starting out with using an IOT cloud before i go all out and turn the pi-top into an IOT server with a custom WEB interface
So to start out with i had to look at platforms to send the data too, I thought about Arduino IOT Cloud but they are very restrictive for free accounts, only 5 variables. so after searching around i decided to go with ThingSpeak, it’s still quite restrictive but can send 3 million messages a day at a minimum of every 15 seconds
ThingSpeak is based on matlab and is more geared towards statistical data like sensor data, not entirely what i have in mind for use with the robotics kit but its better than nothing for a Proof of Concept
to begin with i started with using the pi-top[4] with an Adafruit BME280
Required Software/Hardware
- Python 3 - no need to install
- Adafruit’s Blinka
- Adafruit BME280 Press/Humid/Temp Sensor
- ThingSpeak Python Library -
sudo pip3 install thingspeak
Wiring
ThingSpeak Channel
First you have to create an account, which is free and make a channel and setup the fields, in the case for the BME, just 3 fields are required.
What you will need is 2 things from the channel in order to send the data messages, that is the Channel ID and Write API Key
The Code
import thingspeak
import time
import board
import adafruit_bme280
channel_id = 1396034 # PUT CHANNEL ID HERE
write_key = '' # PUT YOUR WRITE KEY HERE
i2c = board.I2C()
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
def measure(channel):
try:
temperature = "%0.1f" % bme280.temperature
humidity = "%0.1f" % bme280.relative_humidity
pressure = "%0.1f" % bme280.pressure
# write
response = channel.update({'field1': temperature, 'field2': humidity, 'field3': pressure})
# read - can comment this out if needed
read = channel.get({})
print("Read:", read)
except:
print("connection failed")
if __name__ == "__main__":
channel = thingspeak.Channel(id=channel_id, api_key=write_key)
while True:
measure(channel)
# free account has an api limit of 15sec
time.sleep(15)
When you run it, it will submit the data to ThingSpeak, to your own created channel (private by default) and start creating graphs of the data
Web UI
so by default the channel dashboard will look like this
Eagle eyes will notice that this is a public view, i used this to show you the default layout. You can have different views and layouts for private and public view and can even hid your channel entirely. you can customize the graphs etc to what you want to show, but i wish there was more to it
You can do some customizations but really not much but here is what i have done
Conclusion
its very interesting turning the pi-top into an IOT device and submit data to the cloud. 1 issue i have is that it can get expensive for cloud IOT plans and some are extremely basic, some don’t let you delete devices without contacting support etc. So what i want to eventually do is create an IOT server on the pi-top[4] to allow the user to have total control of the data, customizability, integrations, etc.
I do plan on expanding on this PoC with the robotics kit so stay tuned