Rebuild System

Reinstall OpenHab: OpenHab
Update Passwords
Install: Mosquitto & Influxdb & Grafana
Change Influxdb to be located on USB stick
Update udev rules to map serial ports
Add permissions in /etc/defaults/
Install zigbee2mqtt zigbee2mqtt
Install bindings (net, mqtt, gpio, onewiregpio, serial), transforms (jsonpath, regex, scale, map),

Temperature and Humidity in Utility

Need to directly connect a BME280 to the Raspberry Pi, so stacked a header below the 1-wire header, and followed instructions here to get drivers working.

Frustratingly needed to update /etc/modules to get i2c-dev to load on boot.

In hindsight probably should have linked the sensor into the Arduino UNO instead.

Water Tank Sensors

The Pi running OpenHab is directly below the hot water tank, so rather than adding another wireless node in the airing cupboard, I can run some wired sensors.

Simplest for this purpose is a bunch of DS18B20 sensors, these use a 1-wire protocol which is capable of going the 3-4metre distance. Also only need a three wire cable to connect all the sensors. Used an old mini-circuits box to connect the three sensor cables together with 5kohm resistor pull up in the airing cupboard.

Follow instructions @ https://community.openhab.org/t/gpio-1-wire-temp-sensors-on-raspberry-pi-with-openhabian/20941

On the Pi added the following to /boot/config.txt

# PS - Enable 1-wire sensors
dtoverlay=w1-gpio,gpiopin=4

Use the onewiregpio binding in openhab to retrieve the temperature info, add the three sensors with manually created 1wire.thing:

Thing onewiregpio:sensor:Water_Temperature_1 "Water Temperature 1" [gpio_bus_file="/sys/bus/w1/devices/28-01143f865eaa/w1_slave",refresh_time=10]
Thing onewiregpio:sensor:Water_Temperature_2 "Water Temperature 2" [gpio_bus_file="/sys/bus/w1/devices/28-01143f8d57aa/w1_slave",refresh_time=10]
Thing onewiregpio:sensor:Water_Temperature_3 "Water Temperature 3" [gpio_bus_file="/sys/bus/w1/devices/28-01143d7bdcaa/w1_slave",refresh_time=10]

1wire.items

Number:Temperature Water_Temperature_1      "Temperature: [%.2f %unit%]" <temperature>  { channel="onewiregpio:sensor:Water_Temperature_1:temperature" }
Number:Temperature Water_Temperature_2      "Temperature: [%.2f %unit%]" <temperature>  { channel="onewiregpio:sensor:Water_Temperature_2:temperature" }
Number:Temperature Water_Temperature_3      "Temperature: [%.2f %unit%]" <temperature>  { channel="onewiregpio:sensor:Water_Temperature_3:temperature" }

Self Build Temperature Sensor

First pass, using NodeMCU and sensor, powered via USB charger. Since a lot of the wireless technology is based on the ESP SOC this would be a good development platform to experiment with, so worth getting one to play with.

Start with a NodeMCU, a simple Temperature Sensor and one of the many USB power bricks lying around the house.

Solder (badly) the BME280 to a four core cable with a couple of two pin header connectors (GND, 3.3V) & (SCL, SDA) on the end. Connect to the pins on the NodeMCU (GND, 3.3V) & (D4, D5).

Install ESPEasy and configure it to have one BME280 device, connected using MQTT ultimately to OpenHAB. In the meantime tested connectivity by installing Mosquitto on my server. Named the ESP in the living room: “Lounge” and the BME280 sensor “Sensor”:

mosquitto_sub -v -t "/Lounge/Sensor/#"
/Lounge/Sensor/status/LWT Connected
/Lounge/Sensor/Temperature 16.24
/Lounge/Sensor/Humidity 54.18
/Lounge/Sensor/Pressure 1021.65

Too easy, but pretty ugly, with a USB charger hanging out of the wall socket.

Build two more using D1 mini boards, soldering the wires direct to the through hole vias. Deploy one as ‘BigShed’ and the other as ‘TopRoom’.

TODO:

Mixed fleet of sensors:

BME280 Based to get Humidity:

  • Utility Room – Attached directly to Pi/Uno
  • Main Bathroom – Attached to NodeMCU
  • Ensuite – Attached to same NodeMCU as Bathroom
  • Kitchen?
  • Shed to get outside humidity & pressure

DS18B20 Based to just get Temperature, all attached to same NodeMCU (possibly split Bedroom 4 & Loft off to a separate Node):

  • Bedroom 1
  • Bedroom 2
  • Bedroom 3
  • Bedroom 4
  • Bedroom 5
  • Loft Room
  • Landing

Water Tank is monitored by a group of DS18B20 encapsulated sensors, attached directly to the Pi.

Downstairs experiment with ZigBee, this distribution would normally provide a good adhoc network, but not sure the sensors support this. So probably need a ZigBee router:

  • Lounge
  • Study
  • Hall

To Support this deployment need to get:

  • 3 ZigBee Sensors
  • 1 Zigbee Router
  • 4 NodeMCUs (already got)
  • 3 (SPI) BME280 Sensors (already got)
  • 2 (I2C) BME280 Sensors
  • 10 DS18B20 Sensors (already got 3 for water tank)

Open HAB

Install a new power socket in the Utility room, with 5V (3.1A) USB output. Run network cable from switch in loft to the Utility room.

Need one Raspberry PI I went for the 3B+, probably could of got away with something lower power. With a suitable SD Card.

Install Open HAB following the instructions on the openHab website.

Radiator Zones

Could control individual radiators using thermal actuators controlled using Sonoff basic wifi switches to turn on and off. Actuators based on heating wax should be silent if a little slow to respond. 3-4 minutes to open or close.

Disadvantages of this system are:

  • need mains power near every radiator that needs to be controlled, typically sockets are not near radiators.
  • Need one on every radiator in a room
  • If the system fails, have to manually switch each basic on, to get any heat to the radiator.

Alternative is to install motorised valves to zone the heating system, again controlled by Sonoff basics (or just cabled to the heating controller). These would typically be hidden under floorboards.

  • Need to know the complete layout of the heating pipes to be able to decide where to insert the values.
  • Likely need to install more plumbing to create zones.
  • As hidden under floorboards, failure of the valves would cut heat to that zone until it is replaced.
  • Need to lift floorboards, ground floor pipes are under concrete so no scope to install.
  • Only useful if areas can be zoned, which rooms to group together?

Energy Monitor

My hardware skills being next to non-existent am relying on bolting some pre-built hardware together. A good starting point is open energy monitor. project. Simplest scheme, using the existing Raspberry Pi that is hosting the Home Server is something based on:

Firmware for the Arduino is here: https://github.com/openenergymonitor/emontx-shield

Connect it all together, a new /dev/ttyXXX device should be created in the Pi, use udev rules to map it to /dev/ttyEnergyMon. Add a bunch of serial items:

Group Power<br>
Number Utility_Power1 "Power Generated"  (Power, Utility) {serial="/dev/ttyEnergyMon@9600,REGEX(s/(-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>)/$1/)"}<br>
Number Utility_Power2 "Power To Grid"  (Power, Utility) {serial="/dev/ttyEnergyMon@9600,REGEX(s/(-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>)/$2/)"}<br>
Number Utility_Power3 "Power N/C 3"  (Power, Utility) {serial="/dev/ttyEnergyMon@9600,REGEX(s/(-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>)/$3/)"}<br>
Number Utility_Power4 "Power N/C 4"  (Power, Utility) {serial="/dev/ttyEnergyMon@9600,REGEX(s/(-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>)/$4/)"}<br>
Number Utility_Power_VRMS "Power VRMS"  (Power, Utility) {serial="/dev/ttyEnergyMon@9600,REGEX(s/(-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>) (-<em>[0-9.]</em>)/$5/)"}<br>
Number Utility_Power5 "Power Usage"  (Power, Utility)<br>
Number Utility_Power6 "Power Exported"  (Power, Utility)<br>
Number Utility_Power7 "Power Imported"  (Power, Utility)

Create some rules to populate the virtual items:

rule "Power Usage"
when
    Item Utility_Power1 received update
then
    var Generated = Utility_Power1.state as Number
    var Exported = Utility_Power2.state as Number
    var Usage = Generated - Exported
    var Power_In = 0
    var Power_Out = 0
    Utility_Power5.postUpdate(Usage)
    if (Exported > 0) {
        Power_Out = Exported
    } else {
        Power_In = -Exported
    }
    Utility_Power7.postUpdate(Power_In)
    Utility_Power6.postUpdate(Power_Out)
end

Push all items to influxdb using persistence service:

Strategies {
    Every30s       : "*/30 * * * * ?"
    EveryMinute    : "0 * * * * ?"
    Every10Minutes : "0 */10 * * * ?"
    EveryHour      : "0 0 * * * ?"
    EveryDay       : "0 0 0 * * ?"

    default = everyChange
}

Items {
    Utility_Power1, Utility_Power2, Utility_Power5, Utility_Power6, Utility_Power7, Utility_Power_VRMS : strategy=everyChange,Every30s
}

ZigBee Bridge

To add ZigBee sensors to the network we need a bridge, the one that keeps popping up is zigbee2mqtt. This is a USB based solution that is plugged into an existing PC or Raspberry Pi. Which is probably okay for my scenario as the Pi is at one end of the house and the server is centrally located, so will probably give enough coverage.

There is also the option of making it into a ‘router’ – a standalone repeater, or can be connected to an ESP8266 to form a serial socket over WiFi to the Home Server.

The development kit consists of:

Temperature and Humidity Sensors

Adding inexpensive sensors to all rooms, is the first step in enabling a much more responsive and efficient heating system.

Thermostatic valves on radiators are okay, but they never seem to work as well as one would hope. Radiators in ‘cool’ rooms (toilets/hall) getting red hot whilst radiators in ‘warm’ rooms (lounge/snug) getting starved of heat. Having the thermostat connected to the thing providing the heat is always going to be a compromise.

Inexpensive, simple battery powered temperature sensors that connect using zigbee or zwave devices are available that can be slowly added to key rooms as required.

Having historical temperature data for all the rooms in the house, will help to identify rooms that are cooling down or warming up too quickly. So even with a manual heating system will allow me to make improvements. For example replacing a radiators or rebalancing the system. Identifying rooms that are loosing too much heat through drafts or voids in the insulation.

Sensors

Two obvious candidates are very low power battery based devices that periodically transmit the temperature and humidity, using Zigbee or similar low power RF. Or 5V powered WiFi devices, e.g. based on the ESP8266 or similar plus a sensor board.

Off the Shelf ZigBee Sensor

  • Does not need programming, works out of the box
  • Cable free, can be placed anywhere in the room
  • Inexpensive (£10 per sensor)
  • Batteries will run down (every 3 months?)
  • Low update rate means slow to react to local changes, fine for monitoring
  • Needs a gateway to connect to the Home Server
  • Short range, might need two or more gateways

Self Built WiFI Device

  • Long Range
  • Connects to existing WiFi network
  • Very responsive, can send updates on change rather than (just) periodically
  • Mains powered so no batteries to exhaust
  • Flexible, can repurpose the ESP to do other tasks
  • Requires flashing
  • Is Wired, need to be near a socket
  • Ugly cables
  • Inexpensive (£10 per sensor)
  • Needs a power brick / 5v

Conclusion

To start with get both types of sensor, to evaluate the range and battery life of the ZigBee sensors. The ESP based device is a useful development platform for other smart bits and bobs so worth building a development kit and environment.

Initially only get one of each, and use them to do week long surveys of each room in the house to see what the warming/cooling profile is like.

Assuming build up a whole house network, will need around 13 sensors:

  • Lounge * 2
  • Kitchen
  • Study
  • Bed 1
  • Bed 2
  • Bed 3
  • Bed 4
  • Top Room
  • Henry’s Den
  • Ensuite
  • Bathroom
  • Outdoors

Rooms / Areas that are not monitored:

  • Porch
  • Hall
  • Downstairs Loo
  • Landing
  • Utility Room

Although unlikely to need to control the temperature in the bathrooms (these are ‘always on’ rooms) in the future may want to monitor humidity and control the ventilation level.

If using Zigbee sensors then also need to add a gateway device, assuming I add a Zigbee gateway to the Home Server