Environmental sensor: first prototype, first problems

Environmental sensor: first prototype, first problems

Sensors are a big part of the components that make up “JarvisSuite”. These include basic types of sensors, like for presence detection and temperature measuring, as well as a few more special types.

Currently, these were built in varying levels of prototype states:

  • Presence detection sensor (via PIR, or passive IR)
  • Temperature sensor
  • Door sensor
  • Window sensor
  • Passage sensor (via light barriers)
  • Bed occupancy sensor

Since it makes sense to have both presence detection and temperature measurement possibilities in every room, one could combine those as one “environmental sensor” component. As a bonus, we can throw in a humidity sensor as well to complement the temperature measuring.


During the development of my touch-enabled light switch (blog post planned), I designed and built a custom case for it. This case was made by cutting acrylic glass (made possible with the laser cutter of a local maker lab) and glue them together with special acrylic glass glue. The front of this case design was partially see-through to have a visible “touch area” and allow a LED to shine through. I’ll expand more on this in a later blog post.

This case design can be easily modified to have an opaque front (since we have no use for touching and LEDs) with an exact cutout of the dimensions for the PIR module. The PIR module is named HC-SR501 and is the go-to type for cheap and readily available PIR components.

Summed up, this means we’ll have 4 main components:

  • ESP8266 for logic and connectivity
  • PIR sensor: HC-SR501
  • Temperature sensor: DS18B20
  • Humidity sensor: BME280

Unfortunately, I ordered the wrong component for the humidity sensor, thanks to ordering deep into the night and a really unfortunate or misleading eBay article label. I received the BMP280 instead of the needed BME280, which can only measure pressure, not humidity. Thus, we’ll just leave humidity measuring out of the prototype.

The circuit board is rather simple and straightforward, as it only consists of paths to connect the voltage and ground ports as well as data lines from the sensor components to the ESP8266’s GPIO pins. I am a developer, not an engineer, who furthermore isn’t considered to be especially handy, so please keep that in mind when looking at the picture of the circuit board. I just learned to solder, so I’d imagine my soldering skills are just enough to get the job done.


Put together, the case and the circuit board make up the complete environmental sensor module:


Unfortunately, after building the first complete environmental sensor prototype based on the aforementioned design, a problem occurred that was not present in earlier breadboard-based prototypes: Having the HC-SR501 and the ESP8266 this close to each other seems to result in a lot of false positive measurements by the PIR module. The reason for this, as I understand it based on quite a lot of forum posts I’ve found, seems to be radio frequencies from the ESP8266’s antennas which interfere with the seemingly sensitive HC-SR501.

I found the following tips to mitigate and/or fix this interference:

  1. Move those two components away from each other
  2. Shield the HC-SR501 from the ESP8266 with the help of aluminum foil
  3. Add a resistor between the HC-SR501’s Data Out and the ESP8266’s pin input
  4. Add a ceramic capacitor

As of yet, I only had time to try out tip nr. 2, which didn’t seem to have any effect. Since this is a rather complicated side project, I don’t have a lot of time I can invest in it, so this may take some time to resolve this issue, but I’ll report on my progress in a follow-up post as soon as I have more details.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.