Serverless Continuous Integration and OTA update flow for IoT devices using Google Cloud Build and Arduino

How to build your firmware continuously in the cloud and sent to your devices automatically.

Project Architecture
Project Architecture

Getting started with PlatformIO

Installing PlatformIO VSCode Plugin
Image from PlatformIO Quick Start https://docs.platformio.org/en/latest/ide/vscode.html#id2

Setup Cloud Build and Git repositories

# Authenticate with Google Cloud:
gcloud auth login
# Create cloud project — choose your unique project name:
gcloud projects create YOUR_PROJECT_NAME
# Set current project
gcloud config set project YOUR_PROJECT_NAME
Cloud Build file.
git tag -a v1.0.0 -m "First build"
git push -u origin --tags

Deploy Cloud Functions

./deploy-prod.sh

Pushing a new version

Small code to add to our new firmware version.
# Commit the files
git add src/main.cpp platformio.ini
git commit -m "[feat] Add blink feature"
# Tag this commit
git tag -a v1.2.0 -m "Add blink feature"
# Send to the repository with the tags
git push -u origin master --tags
Project building and the device receiving new firmware.

Conclusion

Google Cloud Platform - Community

A collection of technical articles published or curated by Google Cloud Platform Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Alvaro Viebrantz

Written by

Product Engineer @Leverege & Google Developer Expert for IoT. When I'm not cooking, I'm building fun stuff or helping my local dev community. GDG organizer.

Google Cloud Platform - Community

A collection of technical articles published or curated by Google Cloud Platform Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.