Skip to content

Publishes data to the Google Cloud Pub/Sub using MQTT

Notifications You must be signed in to change notification settings

ingeniadevteam/mqtt_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Cloud IoT Core NodeJS MQTT example

This sample app publishes data to Cloud Pub/Sub using the MQTT bridge provided as part of Google Cloud IoT Core.

Setup

npm install

Create cerificates:

cd scripts
./generate_keys.sh

Create a .env file like this:

MQTT_BRIDGE_HOSTNAME=mqtt.googleapis.com
MQTT_BRIDGE_PORT=8883
MESSAGE_TYPE=events
TOKEN_EXP_MINS=20
GOOGLE_CLOUD_PROJECT=<the_project_id>
GOOGLE_CLOUD_IOT_REGISTRY=<the_registry_id>
GOOGLE_CLOUD_IOT_DEVICE=<the_device_id>
GOOGLE_CLOUD_REGION=europe-west1
ALGORITHM=RS256
SERVER_CERT_FILE=resources/roots.pem
CA_CERT="<full_public_key_using_\n_as_new_line_character>"
PRIVATE_KEY="<full_private_key_using_\n_as_new_line_character>"

Running the sample

Usage: npm start or npm run dev

About

Publishes data to the Google Cloud Pub/Sub using MQTT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published