Skip to content

davidgs/GoogleIoTClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Core IoT Example App

Overview

  • Entirely written in Go
  • Designed to run on a Raspberry Pi
  • Designed to read data from an Adafruit BME280 Temperature/Humidity/Pressure sensor -- though it ignores the pressure portion
  • Uses Go driver for BME280 from davidgs
  • Also uses the SenseAir K30 CO2 sensor with Go driver from davidgs
  • Writes 4 BME readings and 1 K30 reading to Google Core IoT per iteration (~5 seconds)
    • Temperature readings are every ~1 sec
    • CO2 readings are every ~4 seconds

Usage

Build:

$ go build GoogleIoT.go

Run

$ ./GoogleIoT -ca_certs roots.pem -device <device_name> -private_key <key>.pem -project <project> -region <region> -registry <registry> -influx_db <measurement> -format [ line | json ]

Output

Sample output on device without a K30 sensor:

2018/09/15 12:45:58 [main] Humidity: 66.24 Temperature: 22.56
2018/09/15 12:45:59 [main] Humidity: 66.26 Temperature: 22.56
2018/09/15 12:46:01 [main] Humidity: 66.24 Temperature: 22.57
2018/09/15 12:46:02 [main] Humidity: 66.23 Temperature: 22.56
2018/09/15 12:46:04 [main] testingGoogle,sensor=bme_280 temp_c=22.56,humidity=66.24 1537029958025504878
testingGoogle,sensor=bme_280 temp_c=22.56,humidity=66.26 1537029959527147539
testingGoogle,sensor=bme_280 temp_c=22.57,humidity=66.24 1537029961028724629
testingGoogle,sensor=bme_280 temp_c=22.56,humidity=66.23 1537029962530306772

Note that the output is 4 lines of Influx Line Protocol, so 4 temp and humidity points are written with each iteration.

This writes data to the Google Core IoT MQTT broker, which then sends it to the Google Pub/Sub agent, which pushes to Telegraf (using GoogleIoT branch of Telegraf from davidgs)

Acknowledgements

Thanks to article from Daz Wilkins for 90% of the code! Couldn't find it on his Github, so ... good developers copy, great developers paste. :-)

About

A sample Raspberry Pi Client for Google Core IoT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages