Project Design: Complete IoT Temperature Logger for Beginners, Part 1

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Project Design_ Complete IoT Temperature Logger for Beginners, Part 1

I have a confession to make for this project: I love collecting data, storing it, graphing it, and getting as much of it as possible. Altium Upverter® has a lot of users who are relatively new to circuit board design, which is fantastic, so I wanted to create a beginner project to introduce less experienced makers to my love of collecting data. We’re going to build a wireless temperature logger that will store data in a web platform, which we will build ourselves, thus allowing us to graph temperature over time, as well as allowing us to see the current temperature where each sensor is.

Embedded programming can be intimidating, especially when it involves wireless networks and web requests, so we’ll be making use of the excellent .NET nanoFramework to make development and debugging incredibly easy. I’ve wanted to use the .NET nanoFramework in a project since writing the article on high level programming languages in embedded projects on the Altium blog. This is a perfect project to use a high level language for, as it keeps the code very simple, easy to debug, and makes what could be the very complicated task of interfacing with a WiFi network and accessing the internet with it much simpler. Not to mention, using the .NET nanoFramework will make us able to rapidly write and test firmware for the device as we prototype it, and refine that firmware on the circuit boards we design and build without much stress.

If you’ve never built a website before, you might be a little worried about the idea of building a web platform to log the data we collect. Don’t worry, I have set up the guide for that part of the project to be easy to follow, and put two different paths that you can follow depending on your preference, and that will result in the same functionality and appearance: an ASP.NET Core with WebAPI based platform, and a PHP based platform. Both are built on open source technologies, and both will run on Windows, Mac or Linux. We will be using this web platform in a range of IoT projects in the future, so we will be building it to be extensible and operable with multiple sensor types. Everything in this project will be open source, and you will be able to freely use it and modify it for personal or commercial use.

Following along with this project will give you an excellent starting point for future projects that need to collect data, log it to a remote server, and present it to an end user. Whether you’re building an industrial asset tracker or agricultural crop monitor, you’ll be able to use this project as a starting point for your hardware, firmware, and web design.

Specifications

The specifications for this project are broad, but very simple. As I mentioned in my Guide to Starting New Projects, typically for the projects I write about, I state the overall goal of the project, then proceed on to component selection. However, we have a few different segments that make up this project, so we can break down the specifications a little more precisely.

Hardware

The hardware for this project needs to be able to connect to a wireless network, take temperature readings, and send those readings to a website. It would also be very nice to display the temperature reading on a screen as well. The final hardware should also be in an enclosure for protection, which we can 3D print to suit the board we design.

The temperature sensor within the device should be as accurate as possible, and capable of reading from -30°C to +50°C.

Firmware

The firmware for the device will need to store temperature readings locally, but not necessarily in non-volatile storage, so if there are technical difficulties with the network or website, we don’t lose data that was unable to be submitted at the time of recording. 

The firmware should take temperature readings at regular intervals and both display the current temperature on the display and upload the reading to the website.

Web

The website should have a dashboard that is able to display the current reading for each device, as well as a graph of the temperature for the past day. Each device should be able to be viewed individually, showing the full temperature history it has recorded.

Users should be able to register for access to the portal, as well as login. User registration should require email validation to be completed prior to the user being able to login.

An admin user should be able to add new devices to the system as well as edit or remove existing ones. The recorded data types should be configurable through the web interface rather than hard coded, so additional device types can be added in the future. 

Component Selection

Given the relatively simple nature of the device we’re building, there are not very many component decisions we need to make. That being said, this project does need some components so let’s take a look at what we might need.

Microcontroller

As I’ve already made the decision to utilise the .NET nanoFramework for this project, our choices for a microcontroller are limited to those that the community has built support for. For this project, the ESP32 looks to be exactly what we need, it’s very low cost, has integrated WiFi, is supported by .NET nanoFramework, and offers options for a pre-certified module version of the microcontroller. There isn’t much point looking into other options when the ESP32 has so many great features for this project.

We’ll start off with the ESP-WROOM32 based DEVKITC for the ESP32, which should give us everything we need to prototype the device.

Display

There are many different types of displays we could utilize for this project, from the humble 16×2 character display up to a nice touch screen TFT display. However, this is a simple project with simple goals, so I want to use the 1.8inch 128×160 pixel color TFT display based on the ST7735S controller that I’m using in the thermal camera project that you can find on my blog. I haven’t tried using this display with the .NET nanoFramework before, but it is a SPI display so it should be a good choice. 

Temperature Sensor

The key component in this device is of course the temperature sensor. There are many routes we could take for a temperature sensor—on the budget side of things there are thermistors, moving up to analogue temperature sensors with built in compensation. From there, we can start looking at low cost digital temperature sensors which use I2C or SPI to communicate with the microcontroller, and on into the premium grade digital temperature sensors.

I feel given this project is beginner oriented a basic digital I2C sensor is going to do the job nicely. These generally give far more precise readings than an analogue sensor, as the conversion is completed by the sensor itself, along with the algorithm to convert the analog voltage into a temperature measurement.

A sensor such as the very simple TMP102 will do the job very nicely. If you want to take the project to the next level, you can optionally implement a temperature and humidity sensor such as the Si7021 which is very popular. 

Power Supply

Our device is going to need some form of power, as this project is beginner oriented, we’re not going to delve into making this a battery powered IoT device. The component options we’ve selected would definitely support being battery powered, however we just want to keep this project simple. As such, I think a simple micro USB connector will be adequate for powering the wireless sensor. If we need to make it portable, an external battery pack/power bank would suit our requirements.

For prototyping purposes, this means we don’t need to order any extra components, as the microcontroller dev kit is also USB powered, and we can utilise the supply from it to power our sensors.

When we layout the PCB, we will need a 3.3v voltage regulator to drop the 5v from the USB line to a usable level, however there are a myriad of low cost linear voltage regulators that will do the trick.

A linear regulator has no engineering risk as far as I am concerned, as such, it’s not something I would include in my prototyping BOM. If we were designing and building this device for a client or mass production, it would be helpful to include the LDO at this point so that it could be considered from a budgetary point of view.

The High Level BOM

Our major components for the device are now selected, and we’re looking at utilizing:

  • ESP32 wireless microcontroller
  • ST7735S based display
  • TMP102 temperature sensor

I’ll order the dev kit and breakout board for the sensor, and while we wait for those to arrive, we will get started on a web interface to receive the data.

Next Time

In the next article in this series, we’re not jumping into the electronics, as we need to build the web platform first. To test the electronic design, we’ll need to have a web API to call in order to prove the connectivity portion of the design. We will start with the ASP.NET based platform, as the code created for that can be reused in the .NET nanoFramework code we’ll be running on the ESP32 microcontroller. The PHP based IoT portal will follow at a later date, as the project progresses.

After the ASP.NET IoT portal has been created, we will get back to electronics. We will prototype the temperature sensor design on a breadboard to prove out the schematic and firmware prior to designing a PCB in Altium Upverter.

If you’re not interested in building the IoT portal yourself, the complete code will be available on GitHub for you to use if you want to follow along with the hardware development of this project, or use it for any other project you have in mind.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: