Temperature monitoring with Dallas DS18B20 sensors and Domoticz

From CommonsLab
Revision as of 15:03, 11 October 2018 by Jann (talk | contribs) (Sensor Pinouts: Add ADC and I2C pins)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


We use the DS18B20 sensors, pre-mounted into a waterproof flange from the BrewPi project. These have RJ11 (6P4C) connectors pre-crimped, which we replace with the more common RJ45 (8P8C) connectors and extend the cable with a standard CAT5e FTP (or STP) cable. The connections are similar to the the common T568B color coding and the follow the 802.3af (Power Over Ethernet / POE) with respect to the DC +/- colors.

Sensor Pinouts

Pin numbers on an 8P8C (RJ54) plug.
Pin number T568B color 10/100 mode B,
DC on spares
RJ45 connector (8p8c) DS18B20
flange-cable color
Pin 1 Pair 2 Tip
White/orange stripe
Rx + NC (I2C SCL)
Pin 2 Pair 2 Ring
Orange solid
Rx − NC (Analog)
Pin 3 Pair 3 Tip
White/green stripe
Tx + DATA (I2C SDA) Wire white.svg
Pin 4 Pair 1 Ring
Blue solid
DC + +3.3V Wire red.svg
Pin 5 Pair 1 Tip
White/blue stripe
DC + +3.3V Wire red.svg
Pin 6 Pair 3 Ring
Green solid
Tx − GND (- for data) Wire black.svg
Pin 7 Pair 4 Tip
White/brown stripe
DC − DC - (for power) Wire black.svg
Pin 8 Pair 4 Ring
Brown solid
DC − DC - (for power) Wire black.svg
Pin number RJ11 connector (6p4c) DS18B20
flange-cable color
Pin 1 empty (no contact)
Pin 2 not connected
Pin 3 Vdd (+3.0V — +5.5V) Wire red.svg Red
Pin 4 GND (-) Wire black.svg Black
Pin 5 DQ (DATA) Wire white.svg White
Pin 6 empty (no contact)

Development Progress

Part 1: Fixed installation - 8 temperature sensors per ESP

In this part, we want to attach as many DS18B20 on one ESP as possible, with the circumstance, that the sensors are up to 40 meters apart from each other.

GPIO pin assignement

The NodeMCU has it's own designation of pins for the ESP8266, just like the Arduino has for the ATmega328.

We use D0 - D7 as digital inputs for the 1-Wire connection to the DS18B20 temperature sensors. D8 can not be used for 1-Wire devices, because the 1-Wire bus needs a pull-up resistor and the D8 is GPIO15 on the ESP8266, which needs to be LOW at power-on or reset, otherwise the controller will not boot.

Cable length testing


The first sensor with 20 meters CAT5e FTP (unshielded) cable and 8p8c (RJ54) connector and socket (for PCB) works, when connected to ESPeasy.


The PCB was produced in the CNC. The parts were hand-soldered and covered with conformal coating (4 layers of acrylic spray). The PCB was installed in an outdoor rain-proof enclosure, together with a 5V/1A USB power supply.

Part 2: Valve control - 4 Sensors and 4 Relays per ESP

In this part, we need to monitor 4 temperatures and control two valves, which are operated with an electric motor. Each motor is operated by 220V and has an internal end-stop switch, which breaks the circuit at the correct motor/valve position, as well as returns the 220V on a feed-back contact to signal successful operation.

220V circuit

Valve controller 220V circuit.png

The electric motors can also be energized by manual override buttons, one to open and one to close each valve. The automatic control is done by one SSR (Solid State Relay), which is used for the state of the motor (ACTIVE/INACTIVE) and one electromechanical relay, which is used for the direction (OPEN/CLOSE).