Skip to main content

Journey into Google Cloud IoT Core with ESP8266 and Mongoose OS

Google recently take the IoT Core to Public Beta. IoT Core is one of the product lines of Google entry to the IoT arena. It is a device registry for controlling and tracking the IoT devices. On top of this, it provides connectivity to the rest of the Google services. Below is the standard diagram provided by Google for the IoT Core.

As we can see, there are 10 big parts in this entire chain (including the edge devices). Some parts are more complicated than the others. For this article, I will start the journey by exploring the following path.
I will be using an ESP8266 running on the Mongoose OS because Mongoose OS has native support for Cloud IoT Core. This will reduce the work required to perform the authentication between the device and the IoT Core.

ESP 8266 & Mongoose IoT Core setup

Mongoose OS website has a set of setup instructions on configuring the devices to connect to IoTCore. The Mongoose OS example stopped at when the message is successfully delivered to PubSub. The PubSub can be configured to trigger a Cloud Function to perform additional operations such as interpreting the data and send back an MQTT message to light up an LED.

For this post, I will have a simple Cloud Function that received the message from PubSub and logs the result to Stack Logger.

Cloud Functions

Cloud Functions is Google version of "Serverless" web applications. For this setup, I have created a simple cloud function that the PubSub will trigger when a message arrived and logged to Stackdriver (Google Logger). Sample code below:
 * Background Cloud Function to be triggered by Pub/Sub.
 * @param {object} event The Cloud Functions event.
 * @param {function} callback The callback function.
exports.iotPubSub = function (event, callback) {
  const pubsubMessage =;
  const name = Buffer.from(, 'base64').toString();



At every 60s, the ESP8266 will put the device status on the queue. The queue name at the device has to be the following convention:


This is the end result, at Stackdriver Logging, the message will be saved in the log.

Concluding Thoughts

Cloud IoT Core is still in beta but there are many features available but not integrated. I think there maybe some companies that will develop a product/service that make boarding of devices simpler.
Beside IoT Core, Google has another product Android Things. Android Things are used in devices with more computing power e.g Raspberry PI. Are they complimentary or competing products?

Update 1: Integration with Cloud IoTCore using UDOO SBC


Popular posts from this blog

DIY Sonoff RF Bridge

Tasmota recently supported the RF bridge by iTead which allowed for RF 433 remote devices to be controlled/controlling using Sonoff products. e.g A handphone can be used to control a remote RF device or an RF remote control can use to control a WIFI enabled device.

By using Tasmota, I can control the device using MQTT. This idea fits exactly to my smart home plan. Here is the schematic:

I cheated a bit by having ESP01 mounted on a breakout board. This breakout board converts all the external pins to 5v which simplified the wiring and I do not need to use a voltage level shifter. Moreover, the Arduino 3.3v power does not have enough current to power the ESP reliably and I have to power it via the 5V from Arduino Uno. Next, I used an Arduino Uno prototype shield with a tiny breadboard to hold all the components together. For the RF 433 transmitter/receiver, I am using the development kits when I purchased the all-in-one Arduino development kits. An antenna is added for more sensitivity.

Using ESP-Link transparent bridge (ESP-01 and Arduino Pro Mini)

Recently stumbled across an interesting open source project ESP-Link. Its main purpose is to network-enable a non-network microcontroller (MCU) such as Arduino Uno, Pro mini or Nano using ESP8266. The author termed it as "Transparent Bridge". The ESP and MCU  communicate via the serial link and there is a companion Arduino library EL-Client for the MCU to connect up the network using MQTT, REST, TCP and UDP.
Setup I have put together an ESP-01 and an Arduino Pro Mini for this experiment. I have chosen a 3.3 version Pro mini so that I do not need to do any voltage level shifting between the I/O pins. In order to have a stable voltage source, the ESP8266 is powered by Pro Mini and the Pro Mini "RAW" pin is connected to a 5v USB power source. The RAW pin can take voltage up to 12V. The reset pin of Pro Mini is connected to GPIO 0 of ESP-01. This enables the ESP-01 to reset the Pro Mini.

I have linked up an APDS 9960 sensor to it and periodically send the luminosity a…