IoT Temperature Sensor in 10 lines (and four years)


Pozetron doesn’t have a birthday, or if it did its parents have probably forgotten it. It would be about four or five years old now if anyone bothered counting. Which brings me to the (sub)title of this blog post. Today I’m going to show you how to make an Internet connected temperature sensor in 10 lines of code which could take you four (or five) years to make, like it did for me, or maybe it will take you five minutes.

Hi I’m Neil (👋) and I’m the founder and CEO of Pozetron. I created Pozetron to make projects exactly like the one I’m showing you today. Not exactly per se but close enough for our purposes. You see as a hobbyist making an Internet connected device used to be hard. You would decide on which chip to use (ES8266) and a board (Adafruit Feather or SparkFun Thing) and then a programming environment (Arduino or MicroPython). Then you would write your program, compile your flash image, flash it onto your device and then install it wherever it went. Any time you found a bug in your code (if you found teh bug in your code) you had to remove the device from wherever it was, plug it back into your computer, recompile your flash image and then flash it back continuing the vicious cycle. So slamming my fist into the table I yelled “There must be a better way!”

Fast forward 4 (maybe 5) years and this is how you, dear hobbyist, make an Internet connected device. You select a chip (ESP8266 or ESP32) and a board (Adafruit Feather, SparkFun Thing or TinyPICO) and a programming environment (MicroPython). You write your code, drag and drop it onto a page on then remotely restart your device. Done

Now as you can imagine a few things needed to change in between to make this a reality. First we needed to secure a million dollars in seed capital from a prominent Silicon Valley Venture Capital (VC) firm, hire 50 rockstar engineers, and build a best in class cloud platform, but we didn’t. Really Pozetron was built by a small handful of people1 over the years with a maximum of one working part time at any given point. We even make this poor “Executive” person work nights and weekends!

The reason this happens is simple. Pozetron is the platform that I need.

When my wife wanted to know what temperature it was in our garage at night for our new chickens I had the idea for a project. In one hour I had thought it up, wired together the hardware, wrote the software and mounted the whole thing.

Fritzing Feather ESP32 DHT22

import sys
from time import sleep
from machine import Pin
from dht import DHT22
from pozetron import datapoint

d = DHT22(Pin(21))
main = sys.modules[__name__]

def main_loop():
    celsius = main.d.temperature()
    datapoint(celsius, 'feather-celsius')

That’s 12 lines of code. I’ll leave getting it down to 10 as an exercise for the reader.

The next day I wanted to track the humidity as well so I added the following two lines and hit restart in the app.

humidity = main.d.humidity()
datapoint(humidity, 'feather-humidity')


To see the temperature or the humidity I just go to the Default Dashboard and select the dataseries, either 'feather-celsius' or 'feather-humidity'. Then you are greeted with a screen that looks like


From there you can explore the data live or even export charts that look like:


After all of this was done, of course my wife asked for just one more feature. She wanted to be able to know if it got too cold for the chickens in the middle of the night so she could wake up and move them. Using a soon to be released feature of Pozetron and the following two lines, I made sure she would get an automated phone call to wake her up - just like she wanted.

if celsius < 1:


Mission Accomplished


  1. Pozetron couldn’t exist without the efforts of the open source community upon whose tall shoulders we stand

Free Registration

No credit card required. Limited time only.

Register Free