codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Get and Store Temperature from a Raspberry Pi with Go

Jeremy Morgan
codeburst
Published in
10 min readJun 9, 2020

--

In this tutorial, I’ll show you how to grab temperature from a Raspberry Pi and build an endpoint to store the data, with Go. You will learn:

  • How to retrieve the temperature from a sensor
  • How to send that data in JSON
  • Build an API endpoint to receive it
  • Store the data in SQLite database

And we’ll do it all with Go. I did a live stream of the entire process that you can watch here.

What You’ll Need for This Tutorial

I’m using Pop!_OS to develop on, but you can use anything you’d like.

Why are we doing this?

I’ve previously written a tutorial to grab room temperature from a Raspberry Pi, and it’s very similar, only using Python. This is another “hand-rolled” tutorial. Why are we doing this by hand? Why not use a cloud service?

The purpose of this tutorial is to give you a deep understanding of IoT and how it works. You can easily use a cloud provider such as:

These services are great. They’re awesome. If you’re building a real project or working on IoT professionally, this is the way to go. They provide excellent secure services and handle so many things for you.

That’s great, but if you want to truly learn IoT you need to get down to the nuts and bolts. The cloud services have clients you configure, and you push the data up, and it’s visualized for you. In this tutorial, we’re going to build all that stuff ourselves and understand it.

Let’s Rock and Roll!

Connect the Temperature Sensor

--

--

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Written by Jeremy Morgan

Silicon Forest Hacker / Developer. I talk about: Programming, DevOps, Generative AI, and much more. More stuff at JeremyMorgan.com

No responses yet

Write a response