Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gcp-iot

Google Cloud IoT Projects

Quantified Desk

Uses arduino mkr1000 and supersonic sensor to measure standing desk height, sending information on sitting and standing durations to Google Cloud IoT Core and visualizing it on a real-time Dashboard (Python application backend and Python/Javascript frontend using Pusher API).

It also detects state changes (sitting -> standing and standing -> sitting) and logs them in a table displayed on the webpage.

Sample visualization

Arduino project setup is available in this link:

https://www.hackster.io/vmehmeri/quantified-desk-iot-6647bf

(The project above mentions Azure IoT Hub, but the Arduino setup is the same)

Requirements

As a pre-requisite, a Google Cloud IoT Core must be setup with a Cloud Pub/Sub Topic and Subscription for the device's telemetry data streaming. Your Arduino device will also require SSL certificates for connecting to IoT core's MQTT endpoint.

This project was developed using Python 3.7.

Create a virtual environment with version 3.7 and install the packages below.

Backend:

  • google-cloud-pubsub
  • pusher

Frontend:

  • pusher
  • flask

All can be installed with pip

Arduino Libraries:

  • Ultrasonic
  • WiFi101
  • RTCZero
  • WiFiUdp
  • MQTT
  • CloudIoTCore
  • CloudIoTCoreMqtt
  • jwt

All those libraries are already available in Arduino Web Editor. The latest code can also be accessed as a Web Editor sketch through the link below:

Arduino Web Sketch

Usage

First edit config.py and configure your connection details and secret keys. You will need to create an account in Pusher and an application (it's free)

config.py (replace values):

from pusher import Pusher

pusher = Pusher(
    app_id='APP_ID',
    key = "KEY",
    secret = "SECRET",
    cluster = "CLUSTER",
    ssl=True
)

## GCP Config
project_id = "PROJECT_ID"
topic_name = "projects/PROJECT_ID/topics/TOPIC"
subscription_name = "SUBSCRIPTION_NAME"

Start frontend

    python app.py

On a separate terminal, start backend

    python device_broker.py

Next open a browser pointing to localhost:5000 and you should see your dashboard.

About

Google Cloud Platform (GCP) Internet-of-Things projects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages