Cloud IoT step-by-step: Connecting Raspberry PI + Python

If you’re not using a Pi that has it installed, just run:sudo apt-get install sense-hatNow your device should be all set (minus code, coming later).Preparing the Google Cloud PlatformIf you’ve never done this before, then go to Google’s Cloud Platform landing page and click through the “Try now” button. It’s the most seamless if you have a gmail address, but you can still do this if you don’t have one. You can go here and create a Google account using any email address.Once the account is all setup, head to the console. First step will be to set up billing. Keep in mind, setting up the Cloud project if it’s the first time you’re doing it, gives you $300 in Cloud credits, and there’s a generous free tier so while you’re trying things out, you’re unlikely to hit any pay walls.First step is to enable Cloud IoT. Number of ways to get there:Search Bar1) Put IoT Core into the search bar in the console2) Select it from the hamburger menu in the upper left. IoT Core is down near the bottom. 3)Click this link.Clicking the enable button will grant the appropriate permissions for the default security rules to allow your user to use IoT Core..If you’re wanting to do it by hand, be sure the user you’re going to use for your IoT work has permission to publish to Pub/Sub..IoT Core bridges the device messages to Pub/Sub for you, which means you need to have permission to write..These permissions are handled in the IAM part of the console..There be dragons..I would only suggest doing that if you’re really comfortable with Google Cloud Platform.Next we’ll create your registries where you want your IoT devices to live..Registries are logical groupings of devices..So if you’re doing like, a smart building infrastructure, each registry might represent a building’s worth of devices.Easiest path is to create a device registry from the IoT Core console page, and as part of that process, in the drop-down where it asks for a Default telemetry topic, you can elect to create a Pub/Sub topic inline..Select the region closest to you, and by default it enables MQTT and HTTP protocols..Easiest to leave that alone unless you know you’ll only be using one vs..the other..The example code in this blog uses MQTT.Now we need to create out device representation in IoT Core.. More details

Leave a Reply