The quest for a Home Monitoring System : Part 3

Sensor Modules for data acquisition

Hardware choices

The initial sensor module was done with an Arduino + DS18B20 sensor and a ENC28J60 ethernet chip. It was pretty fast to build a prototype that would send data via ethernet to a server running a LAMP stack.
However, since I want to have sensors trough out the house (including the exterior), it became a problem since I’m unable to pass an Ethernet cable everywhere I might need a sensor module installed.

The cheapest to add wifi capabilities to an arduino based system would be to add an ESP8622 wifi module :

  • They are low priced  – around 1,7€  a piece on ebay.
  • Answer to AT commands via serial communication (thus an arduino board could simply send AT commands to the module with the data).

But upon more reading,  it was also noted that the ESP8266 could be used as a stand alone module, without the arduino hardware. This helps drive the cost and assembly complexity of each module down further. A major plus was the fact that the arduino IDE can be used with the ESP8266, work with most libraries already included, without changes to software development workflow.

Sensor Module Schematics for version 1.0. Notice the few component count.

And since the ESP8266 supports I2C  and 1 wire data buses, any sensor supporting those protocols can be added to a ESP8266 module.

Sensor module variants

ESP8266 based sensor Modules – PCB version 1 and Breadboard prototypes during code development

A total of 3 variants of the ESP8266 based sensor module, as of 17th February, were built:

  • A module only using a temperature sensor (the DS18B20), with no RTC on board. Exists in breadboard form only and it is currently in use.
  • A module using both a DHT22 humidity and temperature sensor, and also a DS18B20 sensor. Also without RTC support. Module was disassembled and parts used on the PCB version 1.0.
  • A module using a DHT22 humidity and temperature sensor, with a DS1337 RTC, as used on my Nixie Clock. This version was built on a PCB designed in KICAD, and it is currently in use.

PCB Construction

From PCB layout -> positive in acetate sheets -> etched PCB

The PCB was made with the classical Positive transfer onto pre-sensitised PCB, with a 10 minute exposure time. Development was done on a caustic soda solution (0,8g per liter of water) on room temperature.
PCB etching was done on a ferric chloride solution, heated with boiling water.

Exposure of the pre sensitized PCB to the positive containing the PCB traces.

Due to the fact that the PCB would be done by hand, the target was for a single sided PCB layout.

ESP8266 based sensor module, mid assembly


Final PCB layout for the version 1.0


Sensor Module to Elasticsearch data transfer

The sensor modules send a JSON document to the Elastic search.
The ArduinoJson library was used to generate the Json documents to be sent to the server.


The current Json specifies the sensor type, module location, temperature and, if applicable, the relative humidity. At a later date different data types can be added, on a per sensor module basis.
The timestamp, however, must be added to the json.
The current date and time are obtained trough a NTP server, and, if a RTC is present, the RTC is set to the NTP time upon the 1st startup of the sensor module, and the RTC date is used in subsequent measurements.

Sensor Module Programming

However, having 3 different variants lead to 3 different code bases (with different supporting libraries) , did make proper code management problematic during development.

This, however, was fixed with conditional compilation directives, on one unified codebase.

Sample of the unified code for the ESP8266 module.

Sample of the unified code for the ESP8266 module.

The code that makes each module different is encapsulated on #if defined directive. The only thing required is to #define FEATURE_PRESENT prior to compiling the code.

This allows to have 1 codebase for all variants of the sensor module: with or without RTC, and with either sensor type that it is currently supported. It also makes more easy to add more features or different sensor types.


Leave a Reply

Your email address will not be published. Required fields are marked *