Temperature-humidity sensor

Temperature & Humidity

Description

This post will outline how I built some temperature-humidity sensors for my home automation setup to use in a couple rooms in my house.  I'll explain some of the options I tried before coming to my final design.  I will also give you links to where you can purchase the parts and to download the 3D printer files for the enclosure.

Introduction

This originally started from an idea I had for my home automation setup to put a temperature and humidity sensor in my main bathroom.  The main reason for this was to help a small problem with occasional small mold spots on my ceiling.  This was most likely due to humidity in the bathroom.  When someone would take a shower, they would turn on the vent fan before showering, and then off shortly after.  The problem is that when the vent fan is shut off, there still may be excess humidity in the room that could eventually cause the mold.

The idea was that I could have a controller on the vent fan for the bathroom that would turn on when the humidity reached a certain level, and then would also turn off when below another level.  The two levels would factor in some hysteresis to the equation to prevent the fan from continually starting and stopping when the humidity is near a certain level.   By doing this, the humidity in the room would be dropped to a safe level before shutting off, thus preventing the mold problem.

The temperature-humidity sensor design ideas

So I needed to figure out everything I would need for the project.  My primary home automation setup revolves around MySensors nodes.  Those nodes talk to my Vera Plus automation controller.  I decided to make the temperature and humidity sensor a MySensors node.  The exhaust fan control, which I have yet to do, will be controlled by a converted Sonoff module.  For this article i'll focus on the Temperature and humidity sensor. 

Below is a list of the things I needed to create the sensor.  The basic list was simple

  • A circuit board for the project.  
  • A micro-controller to control the sensor.
  • A temperature and humidity sensor.
  • Some kind of power source.
  • An enclosure to mount the sensor to the wall.

On to building the prototype

Easy/Newbie PCBFor the circuit board, I had a number of the MySensors Easy/Newbie circuit boards, so I thought that would be a good choice.  For that board I needed an Arduino Pro Mini, and an nRf24L01+ radio.  

Now I needed to choose a temperature-humidity sensor.  I had both some DHT11 and some DHT22 sensors.  The DHT22 is a higher resolution sensor, so I originally decided to try that one.  Through some testing with the DHT22 sensor I found that the power consumption was too high.  HDC1080 thumbnailI did some looking and found the HDC1080 sensor.  This sensor connects to the I2C bus and uses very low power.  It's low power consumption made it ideal for use on a battery operated node.   By removing the regulator and power LED from the Pro Mini I was able to run this sensor for a week with no significant power drain on a set of 2 - AA batteries.

The last piece of the puzzle was an enclosure.  The enclosure had to be vented since I was measuring temperature and humidity.  It also needed to be able to hold a battery  or set of batteries.  I figured that I should find the battery box first, and then design the sensor enclosure around that and the PCB.  I settled on this one.

The enclosure design

I have dealt with temperature sensor enclosures before, so I had some ideas on what the enclosure should look like.  temperature-humidity wall boxI turned to OpenSCAD and came up with a basic design.  The box was vented, it had mounting tabs for the PCB and a place to hold the battery box.  temperature-humidity wall plateI decided to make it easy to remove from the wall if needed and made the wall plate with two tabs that the cover could lock on to. 

Since the creation of the first prototype wall box, I have done a couple revisions to the design.  This is what the final design looks like.temperature-humidity wall box V3
Version 3 of the wall box is highly configurable and can be adapted to other configurations if needed.  All versions of the wall box can be found on my thingiverse page https://www.thingiverse.com/thing:2186286

Related Images:

RS485 communication techniques

RS485

Introduction

RS485 is a physical layer communication standard typically used in automation systems as a way for sensors and other devices to communicate to a central automation computer.  It is also used in computer system peripherals for data communication between devices.  A couple examples of this are the Small Computer Systems Interface, or SCSI-2 and SCSI-3 interfaces for hard disk drives.  Different systems use different protocols as their defined standards outlining the "language" they will use to communicate to each other.   In this short article I will discuss data communication using an RS485 serial bus and the best practices for an error free signal.

What is RS485?

RS485 has sometimes been referred to as a protocol, which it is not.   It is simply a communications interface wiring standard.  Unlike RS232 serial which is used for point to point serial communications, RS485 is a standard used for multi-point serial communications.  RS485 communication is typically done at half duplex using two wires  handling both transmit and receive.  Full duplex operation can be achieved using 4 wires depending on signal and speed needs.  Below is a diagram of an RS485 serial bus showing the master node and slave nodes.
RS485 Bus Diagram
As can be seen in the diagram, there is the two data lines, or differential pair, where the master and slaves connect, and at the end of the differential pair is a series of termination resistors.  Because the wires are a differential pair, the termination resistors are used to prevent reflections of the signal from back-feeding on to the line and causing collisions.  An RS485 network should only have termination resistors at the beginning and end of the transmission line.

The communication

Data transmitted on an RS485 bus can be heard by all nodes connected to that bus.  Because of this, a protocol is used to determine how that communication is managed.   The protocol must define a system for how data is transmitted, how a node knows that the data is meant for that node and how that node responds to the data it receives.  There have been a number of different protocol standards used in RS485 communication, with one of the most notable standards being the Modbus protocol.

RS485 interface types

RS485 USB Interface

There are many different types of RS485 interfaces on the market.  One is a USB type interface as seen on the left. This type will allow you to use a laptop or desktop PC as a master device, or a slave node on the network.  Another type such as the interfaces shown below are typically used to connect to a micro-controller such as an Arduino or a PICAXE, or small credit card size computers like the Raspberry PI or Beaglebone Black.  Interfaces such as the ones below typically come with the termination resistors integrated on to the board and may need to be removed if being used as slave nodes in the network.Microcontroller RS485 interfaces

RS485 bus setup

In an RS485 topology, the network is designed as one single line with multiple drops, or slave nodes.  As mentioned previously, termination resistors are put in place at both ends of the line to prevent signal reflection.  When termination resistors are not used, signal reflection can distort the signal on the line to the point of causing data loss or corruption.  These reflections are more noticeable on longer runs because the length of the pulse is long enough for the full pulse to make it to the far receiving end.  Once it reaches the end, it is then reflected back causing ghost signals that can differ in phase by the time it has ended.  On shorter cable runs, the the delay of the reflected signal is short enough that the distortion may not affect things because the phase difference will be negligible.
RS485 bus termination
Termination resistors should not be used at the slave nodes as this will cause unwanted signal attenuation.  With too much attenuation the signal may get lost completely.  Therefore, on node adapters where termination resistors are in place by default, such as the ones pictured above, you may need to remove them if they are not acting as the end node.

Conclusion

RS485 can be a good way of connecting automation devices where wired connection between devices is critical in preventing drops in signal.  Following these simple rules for connecting the bus, the signal transmission between devices should be quite reliable.

Related Images: