timstephens

Distributed Temperature Sensor Network

I built a network of distributed temperature sensors reporting back to a server over WiFi using the MQTT protocol. Each sensor is based on the Expressif ESP8266 chip in the ESP-01 format that’s fitted to a small PCB to provide the peripherals and power.

The unit reads the temperature of the sensor every 5-10 seconds, and then posts that on the /temperature/Device-ID topic. The Device-ID is formed from a root (in this case, TempSensor), followed by the MAC address of the ESP chip which should mean that a large number of sensors can be connected to the same network without name collisions.

Hardware

The circuit itself is very simple. It includes a small regulator, a Maxim DS18b20 temperature sensor, and a couple of tactile pushbuttons to ease programming and allow some extra functionality. I laid out the circuit in KiCad, and had the boards made at OSH Park.

The design is a mix of surface-mount parts and through-hole, since I already had some tacile switches, connectors, and the temperature sensor in this format. The regulator is a Microship MC1700 LDO 3v3 regulator that’s able to deliver 250mA in a SOT23 package, which I chose for both its low cost, and compact size.

Software

The software running on the board is made using the ESP port of the Arduino environemnt. I used the standard onewire library to talk to the DS18b20, and the knolleary MQTT library for the MQTT connection to the server. The code is all available on GitHub for download, along with the PCB layout and design.

Backend

The MQTT broker is connected to a NodeRed instance that handles the logic that decides what to do with the various temperature reports. This could be something like logging the data to a file, posting to an online data record service (e.g. Thingspeak or equivalent), or controlling the heating…