Author Topic: Home Temperature/Humidity monitoring  (Read 509 times)

Home Temperature/Humidity monitoring
« on: January 07, 2019, 04:23:20 pm »
On my long list of things to get around to (which I'm going to try and be better at tackling from now on) is some temperature and humidity monitoring in my flat.

This is a bit of a brain dump as I'm still in the thinking/planning stage.

We have no tumble dryer so we dry clothes inside[1] (usually the spare room which doubles as my office). We need a dehumidifier anyway as the airflow in the flat isn't great (it's a 4 storey house chopped up into flats so any original concepts of airflow are long gone, no air-bricks above the ground floor, etc). This got me thinking about monitoring temperature and humidity.

Anyway, my ideal solution would have (in preference/implementation order):-
* office / spare bedroom (temp, humidity, radiator temp by ziptie-ing a sensor to the copper inlet pipe to allow me to tell how often the heating is on)
* lounge (temperature/humidity)
* main bedroom (temp)
* hall (temp)
* bathroom (temp, humidity)
* kitchen (temp, humidity)
* MiniGB's bedroom (temp)

I have a soldering iron, dangerously minimal knowledge of DS18B20 Dallas 1-wire stuff (and associated 1-wire humidity sensors), raspberry pis and good linux/scripting/DB/web knowledge to hack something together to do this.

Ideally I'd have one/two/three separate 1-wire networks with minimal spurs, but the wiring plan is the main problem.

The office/spare bedroom and lounge are easy as both have computers in, so an extra bit of RPi stuff behind the scenes won't be a problem, but getting stuff to other parts of the house is tricky as I don't want to be drilling through walls or laying my own ugly cabling anywhere (I suppose I could hide some thin cabling along the edge of carpet/skirting board but this would be a considerable faff.

On a run earlier I remembered that there's a load of wiring already in place in the form of an alarm system with passive IR sensors. We've never used the alarm (mainly because we've got good security anyway, and we're a first floor flat so way less likely to be burgled than a ground floor, and for insurance reasons[2]). I've been meaning to get rid of the alarm system for ages (I put it into maintenance mode long ago and so the control panel by the front door has been blinking a spanner at me for years). The siren has been disconnected but the main alarm box is still wired into the mains (with it's own fuse in a white socket-sized box so hopefully easy to isolate). I was hoping to unhook it from the mains and then use the existing wiring (to the passive IR sensors and the outside alarm box) for the 1-wire stuff. I could then minimise the number of RPis I'd need to deploy around the flat.

The office/spare-bedroom and lounge would still be done by the existing computers (or Pi zeros).
The main bedroom has a panic button wired to the alarm that I could hopefully borrow the cable from.
The hall has the main alarm box in a cupboard so that's an easy location for the central RPi.

The bathroom, kitchen and daughter's bedroom would require some cabling as there's nothing going that way (although the kitchen has a phone extension that doesn't seem to work, it's probably connected to the phone socket in the spare bedroom that also doesn't work (I'm pretty sure the previous occupants had a second line put in at some point). I could hopefully borrow the cabling from that phone extension to connect the kitchen to the spare bedroom.

The other useful thing about using the alarm wiring is that I'd be able to stick a temperature sensor and humidity sensor outside in the existing alarm box (where it will be nicely sheltered from the rain) since there will be a cable from the main alarm box inside to the branded alarm box on the wall outside. (And it'd be nice to have outside temperature and humidity, ideally air pressure too.)

I was also thinking of using the wires between the main alarm box and the keypad by the front door to run USB power there to run a Raspberry Pi that shows the local bus times (https://yacf.co.uk/forum/index.php?topic=71021.msg2077623#msg2077623) as that project has sat doing nothing for two years (and would still be useful).

Eventually I'd like to run an ethernet cable down to where my bike is kept so I can put a RPi/camera/arduino in there and also capture the blinky light on the electricity meter to monitor our usage. Should check again but last time I did it I couldn't get wifi working reliably, too many walls, otherwise this RPi could also get the outside temp/humidity for me.

I'd really like to keep the number of RPis to a minimum (the above plan calls for 4 or even 5 depending on how I do things) and each extra USB wall wart just adds to the fire risk.

[ If/when I ever get the flat rewired I'd get them to put in some proper 3-core cabling everywhere (along with cat 6 networking and aerial coax) so I could do this all properly. ]

Anyway, initial brain dump done, will come back and add to this when I've thought about it some more, would be interesting to hear of anyone else's solutions to this kind of thing.

1. Except for the two weeks in the summer it's nice enough to do this outside, although our patch of garden is a bit of a schlep. In the summer it's just easier to dry clothes inside with the windows open.

2. Home insurance company said declaring the alarm would only take £10 or so off the bill and we'd have to remember to set it every time we went out.
"Yes please" said Squirrel "biscuits are our favourite things."

Kim

  • 2nd in the world
Re: Home Temperature/Humidity monitoring
« Reply #1 on: January 07, 2019, 04:47:32 pm »
Think about how you're positioning the sensors:  By way of illustration, when I got home an hour ago, I turned my lamp on (which has a homebrew current-dimming LED driver, because barakta needs zero-flicker lighting).  Because I like to overengineer things it has several DS18B20s to detect overheats, but at this point it had all spent over 24 hours at ambient temperature...

The temperature sensor on the board, which is in an enclosure at knee height, on top of a tower PC that wasn't switched on read 17.94C
The temperature sensor in the lamp on my desk read 19.50C
The temperature sensor in the lamp on the shelf behind me (maybe 0.75m below ceiling height) read 21.31C

So if you want to be able to meaningfully compare temperatures between rooms, they need to be at similar heights, and away from sources of heat such as radiators, sunlight, Raspberry Pis[1], etc...


Outdoor temperature sensors aren't so much about waterproofing (a decent heat-shrink job should suffice), as getting them away from the wall and shielding them from sunlight.  I have a DS18B20 wired for parasite power[2] on a short cable terminating in a female F-connector connected to one of the down-leads from the satellite dish we aren't using.  The sensor's stuffed into the bracket behind the dish, which by nature of its alignment sticks out from the wall by some distance and serves to shield it from the sun.


If you're doing it properly, don't piss around with 3-core cable, just use cat6 for everything.  1-wire runs just fine on twisted pair, and it means you can do Power-Over-Ethernet to small micros, IP phones, CCTV cameras, or whatever.  I believe the PoE hat[3] for the Raspberry Pi is a bit crap, unfortunately.


If the topography gets challenging, you may get better results from a proper 1-wire driver than a bit-bashed GPIO interface.


RRDTool is your friend.  OWFS saves a lot of reinventing the wheel.


[1] I can't stress enough how much barely-warm-to-the-touch passively cooled electronics will cause temperature sensors to over-read.  If you're connecting one to a Pi or Arduino type board locally, you need it dangling on 20cm of cable, outside any enclosure.
[2] Avoid using parasite power unless you have to for something like this.  It makes things slower and/or glitchy.
[3] I have a Pi in each room, connected to my own board doing Other Stuff, which I've included a PoE module on.  Works well but massive overkill just for temperature/humidity monitoring.
To ride the Windcheetah, first, you must embrace the cantilever...

hulver

  • I am a mole and I live in a hole.
Re: Home Temperature/Humidity monitoring
« Reply #2 on: January 07, 2019, 05:02:09 pm »
I did a bit of fiddling with some ESP8266, some DHT22 and a server running phant.io code.

The code is pretty simple, every 5 minutes it logs the temperature and humidity, then pushes it to my phant server, which logs the room, the temp and humidity. It does this over WiFi. So all I have to do is a box with a power supply, the ESP8266 and the DHT22 in it (the DHT22 bit is external). I can add as many of these as I like, and I even did a low power one that run on batteries for logging the temperatures in the Guinea pig hutch.

I've not actually done much with the data, other than produce some pretty graphs of temperature around the house. But it works quite well. I don't actually have any circuit diagrams, but it's pretty easy. The code is straightforward if you understand that sort of thing already. Yes, it's WiFi, but the server would be easy to run on a Pi, and could all be done locally if you want (no need for any Internet access, just local addresses)

jiberjaber

  • ... Fancy Pants \o/ ...
  • ACME S&M^2
Re: Home Temperature/Humidity monitoring
« Reply #3 on: January 07, 2019, 05:02:52 pm »
I've got something similar running in our house, a bunch of ESP8266 boards scattered round running with SHT30 sensors to provide temperature and humidity.  For the weather station in the garden it's again ESP8266 based with a 1-wire humidity custom board (condensation-resistant) and Davies weather station components connected.

https://taaralabs.eu/1-wire-humidity-temperature-sensor/

There are also some ESP8266 based light and power switched doted round the house for various lights and stuff.

All this goes back over wifi to a mosquetto server using MQTT and is controlled using a node-red server. These could easily run on a pi or virtualised on a router - at the moment I have them on a HP micro-server as it's sat there running other stuff.  I'll probably migrate them to a virtual machine on my router at some point this year I think..

Lights are linked in to Alexa and a web UI plus a random /semi programmed timer for outside and hall lights based on sunrise/sunset etc
Temperature and Humidity are logged and also uploaded to thingspeak
Weather station data is also logged and uploaded to wunderground and tweeted every couple of hours
All data is presented on a desktop touchscreen driven by another ESP8266 listening to the MQTT traffic to then display it.

Only issues I have are
DHT22 style sensors die regularly
ESP8266 eventually die and need replacing (I think this is a eeprom read/write issue)

Yes you will need some wall warts for power - but you could also be cleaver in placement and put them local to existing USB ports (or even swap out some mans socket plates for combined USB & mains ?)

You can get some nice already thought out ESP8266 solutions which just plug together to minimise soldering etc.  I tend to use the WEMOS (and their clones) as there are a lot of ready made shields and 'expander' boards.  https://wiki.wemos.cc/products:d1_mini_shields


I originally started out down the 1-wire route for everything but it's easier to just put it all over wifi :) - there's nothing stopping you from 1-wire to ESP8266 of course :)
Regards,

Jason

Kim

  • 2nd in the world
Re: Home Temperature/Humidity monitoring
« Reply #4 on: January 07, 2019, 05:10:58 pm »
For the weather station in the garden it's again ESP8266 based with a 1-wire humidity custom board (condensation-resistant) and Davies weather station components connected.

https://taaralabs.eu/1-wire-humidity-temperature-sensor/

That looks handy.  One thing I have discovered is that the DS2438 is much less robust at communications than the DS18B20, presumably because it's designed to be used internally to a device for battery monitoring, rather than on the end of a cable.  It likes to be the only thing on the bus, and seems to get disgruntled about long cable runs.  Star topography is probably Asking For It.

For added 'fun', they sometimes like to interpret line noise as a request to turn the current A/D off, and mysteriously start returning the same value.  Not a problem with the standard humidity sensor design, which only uses the voltage input, but I'm using the current channel for a crude ambient light sensor.

I also had one absolutely shit itself after a nearby lightning strike.  All other electronics in the house were unaffected.  Make of that what you will.


I'd probably still use them for a weather station, but if I were building a humidity sensor into a Raspberry Pi based device again (as I have with the deaf alerting system), I'd use some sort of standard I2C A/D converter, rather than using a DS2438 simply to make the software easier.
To ride the Windcheetah, first, you must embrace the cantilever...

jiberjaber

  • ... Fancy Pants \o/ ...
  • ACME S&M^2
Re: Home Temperature/Humidity monitoring
« Reply #5 on: January 07, 2019, 05:36:49 pm »
Yep - it's on a very short leash :D
Regards,

Jason

Re: Home Temperature/Humidity monitoring
« Reply #6 on: January 07, 2019, 05:39:55 pm »
If you're doing it properly, don't piss around with 3-core cable, just use cat6 for everything.  1-wire runs just fine on twisted pair, and it means you can do Power-Over-Ethernet to small micros, IP phones, CCTV cameras, or whatever.  I believe the PoE hat[3] for the Raspberry Pi is a bit crap, unfortunately.

Cat 6 done properly would cost £3500 plus redecoration costs (another £3000 probably, plus we'd be looking to replace three carpets at the same time as the redecoration so a further ~£3000). I'd agree that PoE would be lovely, as would getting rid of my powerline stuff, as would being able to do HDMI over cat6 to get good quality telly in my office.

Using existing cabling borrowed from a decommissioned alarm system would be almost free.

If the topography gets challenging, you may get better results from a proper 1-wire driver than a bit-bashed GPIO interface.

I'd be using the modules from Sheepwalk Electronics that use a DS2482-100 and similar rather than direct connection to the GPIO pins, various are available that can give up to 8 separate 1-wire networks, easily enough.
"Yes please" said Squirrel "biscuits are our favourite things."

Kim

  • 2nd in the world
Re: Home Temperature/Humidity monitoring
« Reply #7 on: January 07, 2019, 05:46:53 pm »
The lack of general purpose 1-wire IO devices (preferably in sensible packages) baffles me.  There are a couple of open-drain GPIO options, but the eminently useful DS2450 is no longer in production.  Grr.
To ride the Windcheetah, first, you must embrace the cantilever...

Kim

  • 2nd in the world
Re: Home Temperature/Humidity monitoring
« Reply #8 on: January 07, 2019, 05:50:41 pm »
If the topography gets challenging, you may get better results from a proper 1-wire driver than a bit-bashed GPIO interface.

I'd be using the modules from Sheepwalk Electronics that use a DS2482-100 and similar rather than direct connection to the GPIO pins, various are available that can give up to 8 separate 1-wire networks, easily enough.

Yeah, that approach works well.

...which leads me to http://www.brain4home.eu/node/1 which is a good response to my above winge.   :thumbsup:
To ride the Windcheetah, first, you must embrace the cantilever...

Re: Home Temperature/Humidity monitoring
« Reply #9 on: January 13, 2019, 09:09:49 am »
Currently have a rook of ESP8266 and a collection of BME280s for temperature and humidity sensing.
For communication and logging of data between the ESP8266 I'm looking at running and MQTT broker on a Pi.
Also on the Pi, I'll run either NodeRed or OpenHab as a means of displaying and acting on the data.

I'll hopefully be spiking this out in the next couple of months.
For now I've got an ESP8266 attached to a DS18B20 and a script running that retrieves the temperature on 10 minute intervals using HTTP.
A Few Apples Short of a Strudel