Wouldn’t it be great to store stuff on the cloud without forking out for an expensive IoT system? Well that’s not Pi in the sky (ouch!). Because, just by adding cheap sensors to your Raspberry Pi setup and whizzing the data to a public cloud, you can store and process it for next to nothing.

Having multiple sensors connected to a gateway that processes and transmits data to a cloud platform is a great setup for creating an IoT system.

So we’re going to show you to use a Raspberry Pi v3 B+ (896-8660) as a gateway device – it’s perfect since it offers wired Ethernet, WiFi and Bluetooth connectivity (BLE) with a processor with plenty of oomph.

Plus we’ll cover how to transmit data from ten different environmental sensors using nothing more than our trusty little Pi.

Sound good? Let’s go…

Here’s the hardware needed:

  • Raspberry Pi v3
  • Silicon Labs Thunderboard 2 (TB2)

The Silicon Labs Thunderboard 2 (TB2) sensor board delivers a great mix of environmental sensors plus a Gecko class processor that allows data to be transmitted over Bluetooth to the Pi.

In our rather brilliant design, we can connect to the Google cloud via a wired or wireless Ethernet. And the sensor data is received over BLE before being pre-processed, encrypted and then transmitted to the Google cloud over Ethernet. Just how cool is that?

Normalize your data

The TB2’s sensors can monitor temperature, humidity, barometric pressure, magnetic field strength, gyroscopic orientation in space, CO2 and organic compound air quality. Not to mention ambient and UV light strength. And as if all that ain’t impressive enough, there’s also a microphone which records ambient sound volume.

Each sensor is sampled every six to eight seconds and the data transmitted via BLE to the Pi.

OK, so pinging sensor data across at regular intervals is one thing. Making sense of it is another. So for starters we have to normalise the value of the data to a standard range.

Take temperature. The sensors often output a value using a 16 bit ADC – so a number from 0 to 65,535 is transmitted. But that number might represent two completely different temperature values from a 0° to 70° sensor compared to a -40° to 125° sensor. So the received data point is converted to an actual temperature (choose celsius or fahrenheit) on the gateway before it’s pinged to the cloud.

Convert to JSON

Once everything’s normalised, we turn our data into a JavaScript Object Notation (JSON) format for transmission. JSON is an open standard, human-readable, text-enabled way to transmit data. Not surprisingly, it’s also the most commonly used format for sending sensor data over the Internet.

Don’t let your JSON message read like War and Peace. Brevity is the key here, so keep things snappy by creating a short, unique identifier for each sensor in the system.

On the cloud side, this identifier is expanded into a longer device address that lets you easily select one sensor from thousands by location, type, or other defined parameters.

Connect to the Cloud

We must create a Google instance that’s listening for the specific gateway before we send data to the cloud for the first time. We do this using the unique identifier that’s been cleverly programmed into the gateway at the factory. Simply enter the identifier after the initial login to create the Google data node ready to receive sensor data from that gateway.

Powering up the gateway device causes a boot sequence which establishes an Internet connection, sets the clock on the Raspberry Pi, and then sends certificate information to the Google cloud.

Once a connection is made, sensor data is instantly read over the BLE connection before being normalised, converted to JSON, encrypted, and finally transmitted using Google IoT core (MQTT or HTTPS protocols). Easy!

Cloud services

You’ll discover a pretty standard set of features on the cloud side for displaying and processing your data. Once received, it’s magically converted to an internal cloud message using a Publish/Subscribe (PUB/SUB) scheme. This lets different cloud components listen for messages from specific sources.

All your sensor data is nicely displayed in a customisable dashboard:

With a whole library of design formats to choose from, you can display both real-time and historical data in a way that suits you best.

 

You can also set up alerts. As your data is received on the cloud, it can be compared to pre-set conditions and the system will alert you if those conditions are met.

It’s worth noting that the underlying algorithm is a pattern matching (Rete algorithm) scheme that can compare thousands of messages per second with thousands of possible events.

Events that could trigger an alert include:

  • Data meets a trigger value (say, temperature is above 30°)
  • Multiple data trigger points are met (temperature > x AND humidity > y)
  • Data has not been received for a period of time
  • Data has moved x standard deviations away from the long-term average
  • Data is behaving abnormally (stuck on one value or jumping around)

 

We think that’s pretty cool, and you can programme tons more events or alert conditions into the cloud engine.

And as for the future…tomorrow’s versions of the cloud platform will extend data analytics and action. And there are plans in the pipeline to add exciting stuff like object recognition using AI, machine learning and blockchain capability. Watch this space!

So there you have it. Your Raspberry Pi is your very own gateway to send sensor data to the Google cloud. There’s no maximum limit on how much data can be transmitted by multiple Pis in a single system, either. And it’s good to know cloud side services are securely transmitted and accessible through a browser interface. And all with absolutely no IT infrastructure, staff, or investment. What’s not to like?

Like what you read? Why not show your appreciation by giving some love.

From a quick tap to smashing that love button and show how much you enjoyed this project.

Privacy

Il nostro sito web utilizza cookie e altre tecnologie simili per fornirti un servizio migliore quando effettui una ricerca o fai un ordine, per finalità analitiche e per personalizzare la nostra pubblicità. Puoi modificare le tue impostazioni per i cookie leggendo la nostra politica sui cookie. In caso contrario, supporremo che accetti il nostro utilizzo dei cookie.

Location

Please select an option to see content specific to your location and shop online.

Browse the US site