Den Automation – API

With the very sad news that Den Automation is having financial troubles, I decided it was time to revisit my investigation into the protocol that Den uses.

I had read on their website that they used both a cloud based and local network approach. In fact, this was one of the things that appealed to me most. Offering local control is an important aspect in any smart home as it insulates you from internet outages.

I had looked into their protocol a few weeks after setting up my Den hub, but it turned up a dead end for me.

Based on what I’d learned my own adventures in IoT, I started working under the assumption that the local protocol would be HTTP based and use probably use mDNS. Using Charles, the populate iOS proxy, I was able to capture some of the traffic from my phone whilst using the Den app.

Unfortunately, all the requests were targeted at Den’s cloud. I was able to see the details of my deployment, the various switches and sockets, but I wasn’t too interested in taking this approach, since I had Google Home and Alexa integrations already setup.

I fired up WireShark and used Apple’s guide on how to intercept all traffic from my iPhone – https://developer.apple.com/documentation/network/recording_a_packet_trace

I immediately spotted a HTTP request, which was a protocol switch request. More digging and some Google-fu and I leaned that this was just MQTT over websockets on port 1884

I loaded up MQTT Explorer and fed in the details (IP address of my hub and Port 1884) but got a 401 (Authentication failed). This was progress as I knew some thing was listening.

Fast forward a few hours and I’d extracted this packet. Thanks to this protocol document ( http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/MQTT_V3.1_Protocol_Specific.pdf ) I was able to determine this was a connect request (0001), which contained a username and password.

The request to login, with a client name of MQTT and the username and password

Armed with some credentials, I fired up MQTT Explorer and was connected.

After a few minutes, I started to get information over the connection! MQTT Explorer includes the # and $SYS/# subscriptions, so it basically gets everything published by the hub.

I knew that the device was one of the double sockets (the TV was on) and it was sending measurements!

{“43de2329-8808-57bc-af5b-ea01bd6a6d11”:{“online”:true},”c8de59a4-29e5-52ad-84b5-2574f005544b”:{“software”:[{“type”:”USER_1″,”version”:”1.3.0″}],”battery_level”:29,”online”:false,”status”:{“0”:{“last_state_changed”:”2019-08-09T15:46:24Z”},”1″:{“last_state_changed”:”2019-08-09T15:46:24Z”}}},”7039ee52-d25a-59c5-b957-844ff067233f”:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:false,”status”:{“0”:{“state”:0,”shutter”:1,”nfc_tag”:{“uid”:”04:cd:be:d2:35:5e:80″,”atqa”:”0x44″,”sak”:”0x00″,”version”:0,”name”:””,”type”:”APPLIANCE”,”keep_on”:false,”timeout”:{“enabled”:false,”duration”:0}},”last_state_changed”:”2019-10-09T11:18:17Z”},”1″:{“state”:0,”shutter”:1,”nfc_tag”:{“uid”:”04:f2:97:ca:35:5e:80″,”atqa”:”0x44″,”sak”:”0x00″,”version”:0,”name”:””,”type”:”APPLIANCE”,”keep_on”:false,”timeout”:{“enabled”:false,”duration”:0}},”last_state_changed”:”2019-10-09T10:59:42Z”}}},”1cef1fcd-3aa7-5a49-80b4-ea98b85c5827″:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:true,”status”:{“0”:{“state”:1,”shutter”:1,”nfc_tag”:{“uid”:”04:61:8a:7a:33:5e:80″,”atqa”:”0x44″,”sak”:”0x00″,”version”:0,”name”:””,”type”:”APPLIANCE”,”keep_on”:false,”timeout”:{“enabled”:false,”duration”:0}},”last_state_changed”:”2019-10-09T18:04:06Z”},”1″:{“state”:1,”shutter”:1,”nfc_tag”:{“uid”:”04:5a:b2:d2:35:5e:81″,”atqa”:”0x44″,”sak”:”0x00″,”version”:0,”name”:””,”type”:”APPLIANCE”,”keep_on”:false,”timeout”:{“enabled”:false,”duration”:0}},”last_state_changed”:”2019-10-09T18:04:08Z”}}},”c0713ae1-1913-5ab7-944b-d94ea4b5477d”:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:false,”status”:{“0”:{“state”:0,”is_ready”:true,”last_state_changed”:”2019-10-09T17:30:34Z”}}},”4f832cb2-824f-58dc-87ad-5a89e121b653″:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:true,”status”:{“0”:{“state”:0,”is_ready”:true,”last_state_changed”:”2019-10-07T17:23:55Z”}}},”59607912-dda1-5e97-9e3d-6b065b9288db”:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:false,”status”:{“0”:{“state”:0,”is_ready”:true,”last_state_changed”:”2019-10-08T18:59:02Z”}}},”5a008677-5c2e-5405-a6b8-357a7e64642a”:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:true,”status”:{“0”:{“state”:0,”is_ready”:true,”last_state_changed”:”2019-10-08T21:19:37Z”}}},”8016c79f-8502-5b5c-b480-bb6361af1398″:{“software”:[{“type”:”USER_1″,”version”:”1.4.0″}],”online”:true,”status”:{“0”:{“state”:0,”shutter”:0,”nfc_tag”:null,”last_state_changed”:”2019-10-07T11:13:41Z”},”1″:{“state”:0,”shutter”:0,”nfc_tag”:null,”last_state_changed”:”2019-09-29T12:54:36Z”}}}}

Switching stuff on and off

After more digging around, I eventually capture the Publish command used to control the state of the individual devices.

A 142 bytes WebSocket message sent when I turned on a switch
The content is an MQTT publish (0011)

This enabled me to update the state and thus turn the switches on and off.

I’ve created a simple web app – https://denclient.azurewebsites.net/ – which can be used to control the connected hardware. You just need to use the same process as I did to sniff the packets.

At the time of writing this, the Den app was still working for me, which enabled me to perform some basic packet sniffing. Since I performed this investigation, the Den App is no longer working. I presume that AWS/Azure have killed the Den backend due to unpaid bills.

Advertisements

Set extractor fan to automatic – Part 1

A few months back, after we discovered mould growing on our bathroom ceiling, I replaced the wall mounted extractor fan with an in-line model, mounted in the loft. I never grasped how important the position of the van was in relation to the source of steam and the source of fresh air. Without going into too much detail, the new vent, directly over the shower, is doing its job.

My extractor fan, like most people’s, is wired to the lighting of the bathroom, so turning on the light also turns on the fan. I have two problems with this:

  • You need to have the light on, even if it’s the middle of the day.
  • The fan runs in the middle of the night after a trip to loo.

The first point is my preference. I like natural daylight, so it does annoy me having to turn on the lights. Opening the window just isn’t as effective as the fan. And whilst the in-line unit I purchased is very quiet, in the dead of night, you can hear it roaring away .

It would be nice to only have the fan on when needed e.g. having a shower. Some fans use humidity sensors, but inline fans don’t have that option. Besides, they require the humidity level to rise enough to trigger them, which kinda defeats the point. My wife suggested we add an extra switch to control it, but it’s not practical as I’m not able to get a wire down into the socket. I’ve started looked at some sort of smart alternative.

The plan

I’ve been thinking about a solution and I’ve got an idea that I think will work. There are three parts to it.

#1 Add a temperature sensor to the hot water pipe that feeds the shower. I’ve built one for my son’s room, battery powered, so we can see how hot/cold his room gets during the night. The temperature sensor could tell when the shower is running as the pipe would get up to 50 or 60 degrees Celsius.

#2 Disconnect the fan from the bathroom light and control it using an ESP8266 and a relay. This will allow it to be turned off and on via an MQTT instruction. I will also reduce the fans overrun to zero and control that via software instead.

#3 Create an automation to engage the extractor fan when the temperature sensor reaches a certain temp and to turn it off when the temperature drops back down.

The Temperature Sensor

For this project, I’m planning on using a variation on my own home made temperature sensor.

In order to have a fast response response to changes in temperature, the unit is going to have to be powered constantly. Fortunately, there is an easy access between the shower pipes and the cupboard under the stairs. I’ll be able to run a cable up there with ease.

The Fan Control

The fan that I’m using in my bathroom is a bog standard inline extractor. It takes three inputs. Mains power, live and neutral and a switch live, which is tied to the bathroom lights.

My plan was to use the existing mains power to power my control circuit and to put the switched live under the control of a simple relay, rather than the light switch. I will also use Hass to manage the fan’s overrun, rather than using the inbuilt circuit. This gives me more control and flexibility.

I have a few Hi Link transformers, which take mains voltage and spit out 5v. The Wemos D1 boards I have will take a 5v input and the small relays I have are also powered using 5v.

Converts mains voltage to a steady 5V DC, perfect for Wemos

The operation of the control would be pretty basic. Using MQTT, it would listen for a run command, the body of which would hold a count in minutes. When received, it would engage a relay to the switched live input of the fan. Once the specified number of minutes elapsed, it would disengage the relay and the fan would stop. If a run command was received whilst the fan was already running, the time would just be reset. If a stop command was received, the relay would automatically disengage.

The controller would also publish its current state when it was changed, something that isn’t necessary, but useful for keeping Hassio up-to-date with changes it didn’t cause!

I assembled a small prototype using some veroboard and a relay I had. It is a low trigger relay, which means it’s engaged when the the indicator input has a low voltage. This is a little annoying (it’s using power to engage the contact). I ordered a high trigger relay, but pressed on with the prototype just the same.

The initial prototype

Sadly, this protoype didn’t work! Everything powered up, but the program on the ESP8266 didn’t appear to boot up. Experience taught me this was because of a lack of power, but I expected no more than 300mA to be drawn by both the relay and D1 board.

I attached my bench supply to get a better view of the power consumption.

W1 and the relay (engaged) draw 347mA, well below the 0.6A rating

So it’s wasn’t a power issue. I poked around a little more and after reviewing the MQTT logs, I was happy that the code on the D1 was actually running correctly. This was puzzling. All information pointed to the relay being a problem.

I reconnected to my PC via USB and ran the code again. Everything worked perfectly.

As I’m using a low trigger relay, this means that the relay engages when the output PIN is set to ground. Using my multi meter, I measure the voltage across the PIN and got a value of 0.095V

USB power gives 0.095v when the output pin is set to LOW

Reconnecting my rectifier, I tested the voltage again and got a different value!


Bench power gives 0.11v when the output pin is set to LOW

The penny then dropped. What if the cut off was 0.1v? I quickly popped a resister in series and bingo, the relay engaged!

As I already knew, the low trigger relay didn’t align with my requirements, so aside from a fun diversion, this wasn’t a problem I needed to solve.

HASS control

With the fan control hardware prototype up and running, I turned my attention to Hass control. As I was using the MQTT protocol, this was very straight forward.

After some experimenting, I had to bin my approach of passing the running time as part of the body because of how MQTT works in HASS. Whilst HASS will issue MQTT commands for a particular device, it also listens for status changes from the device. The body of these two messages must match up. For example, if I issued START5, my board would respond with START5 and HASS would turn the fan yellow to indicate its running. If I send the MQTT command outside of HASS (MQTT directly, for example) with a body of START10, HASS won’t identify the fan has started and its state would be wrong. I don’t want to force myself into relying only on HASS to start the fan. Commands like START and STOP are sufficient enough for my needs.

It’s not the end of the world. The fan already has a fixed overun time, so I won’t be any worse off. In the future, I could look at another MQTT command that could dynamically change the overrun time.

Tapping this runs the fan

More to do

The idea was sound, but I have much more work to do.

  • Replace the replay with a high-trigger one
  • Connect the control unit to the extractor fan
  • Connect the temperature sensor to the hot water pipe

I will cover these in future posts on the subect!

Adventures in deep sleep with ESP8266 and a temperature sensor

One of the small ESP8266 projects I did was the creation of a simple temperature sensor.

I build a simple circuit, following the guidance from the following articles:

I opted to use a probe on a long wire rather than using the little component. I ordered some of these from Amazon – https://amzn.to/2IiYEQs. I thought these would give me more flexibility when it came to positioning the probe.

The plan is to build a couple of these sensors and put then around my house. Mostly out of curiosity. I want to see how the house warms and cools during the coarse of the day and what impact the heating & occupancy has (more sensors!)

I had come across this article – https://openhomeautomation.net/esp8266-battery – which describes how an ESP8266 can run for years on a large battery. Seemed very straight forward and I figured that I could use a 9v battery to power one of these units for a few months at the very least.

I built the circuit and wrote the code using VSCode and the amazing PlatformIO plug-in. Essentially, my code connects to my WiFi, connects to an MQTT server (running on Hassio) and sends the temperature value. It will then go into a deep sleep for five minutes and repeat the process. This felt straight forward.

I put the circuit together on a breadboard to ensure I got the temperature reading working. I then moved the assembly onto a small circuit board and soldered it all in.

The 8266 comes requires 3.3v to operate, but comes with an in-built power regulator allowing you to power it with anything between 3.3v and 12v.

This is what I connected my 9v battery to. Everything seemed to work perfectly and my Hassio instance was recording the temperature coming from the sensor.

Temperature logged every 30 seconds until about 6am

Leaving it over night, I checked it in the morning. The temperature was logged every 30 seconds (I initially went for this to test its behaviour) until about 6am, when it went dead.

Some quick investigation showed the 9v battery had drained too much and the ESP8266 was no longer able to connect to the WiFi. That wasn’t what I expected. I knew it would use power when it was connected to the WiFi etc. but to drain a battery in a day? I decided to try and work it out.

First, let’s assume it’s running all the time. According to my multi meter, it’s drawing ~80mA.

This didn’t seem like a whole lot, until I checked this page – http://www.techlib.com/reference/batteries.html – and discovered that there are only 500mA hours in one of those batteries. So, at 80mA draw, the battery would supply the ESP8266 for 500/80 = 6.

Wow. Six hours wasn’t what I had in mind!

I’m not reading the temperature all the time, using a deep sleep as I mentioned before, to reduce its power usage between temperature reads. So if we assume it draws next to nothing when its asleep, let’s work out the power consumption over the course of an hour.

It takes about ten seconds to connect to the WiFi, connect to MQTT and send the temperature reading. This happens every thirty seconds, to in total, it’s essentially forty seconds between each read Read (10) | Sleep (30) | Read (10) etc.

So in an hour, we’ll take 90 readings.

This means we run at ~80mA for 90 x 10s or 15 minutes, per hour. This means our 500mA battery should run for about 24 hours. Except, it didn’t.

Using the multi meter again, I discovered the 8266 was drawing ~11mA when it was in deep sleep.

This was much, much higher than the power consumption outlined by the articles I had read online. Some further researching showed other people have the same problem.

It means the 8266 draws 11mA for 45 minutes of every hour. Out 500mA battery could only run for about forty five hours. That’s not even two days. It should be able to run for over a year on a battery when it’s asleep.

More reading on t’internet about the NodeMCU and one of the comments in this post (https://openhomeautomation.net/esp8266-battery) mentions the voltage regulator on the board draws ~11mA. Something called
Quiescent Current. I was supplying the board with 9v input to the GND/VIN pins, which would require the voltage regulator to kick in. Could this be the problem?

Using my bench power supply, I connected it directly to the 3.3v input and set the voltage to a constant 3.3v. I also removed the temperature sensor hardware and replaced it with a fixed software measurement to ensure no current was drawn through the board.

Zero Effect!

Still drawing 11mA in deep sleep. Note discrepancy between bench and multi-meter

Using the bench power supply did make me aware of one thing. The current readings were different across the two devices.

I had received delivery of some Wemos D1 modules, which other people had reported some success with. I wired up one of these and loaded on the same program (with temperature reading code completely removed).

According to my multi meter, it was using over 150mA, but wasn’t actually working (no message being sent via MQTT). This threw me completely!

In the spirit of clueless experimentation, I moved the input on the multi-meter from mA to 10A and, lo and behold, the current dropped and my MQTT subscriber started getting data. I got some help from @themainframe via Twitter and he told me this down to impedance and quite normal. I made a note to research this topic a little further.

Sending the temperature uses some power

The deep sleep also dropped the current being drawn to a level so low that it didn’t register on my bench supply. Result!!

Nothing being consumed in Deep Sleep

The next step was to re-enable the code and circuity that actually took the temperature reading. In my original design, I was feeding power to the probe from a 3.3v output on the ESP dev board. Following the circuits others designed, this time around I would power the circuit from the power supply directly.

Temperature probe connected to directly to power supply

This worked like a treat! Measuring the current, I could see the draw whilst it was measuring and transmitting the temperature was very low.

Really small power draw

The next step was moving from bench power to battery power. I recalled another blog post where the author had used a very large lithium ion battery to power his IoT device. I found the same battery and ordered a pair and also got some holders for them. It’s an 18650 type, which is 3.7v with a large 2000mAh capacity.

I also needed a way to drop from 3.7v to 3.3v. I had used a voltage regulator on my smart lamp project (blog post pending) so that seemed like what I wanted. I came across the MCP1700-3302E regulator, which seemed perfect. They seemed like they would deliver the 3.3v I needed from the 3.7v battery. They were also able to handle 250mA, which was more than enough for my setup.

Putting it all together and I had a working circuit!

Battery powered temperature with deep sleep (finally working!)

Next step was reducing this down to fit in the little box. I bought some veroboard and set to work.

Using some vero board to create a complete circuit.
I used pin holders rather than soldering the D1 directly to the board.
With battery and sensor attached
The board and battery back into the original box.

Leaving the unit over night and logging to the same Hass.io queue, I was delighted to discover when I came down in the morning that the device was still transmitting. It was interesting to see my kitchen falling to around 15 degrees.

The raw data being written
A smoother graph in Hass, which looks nicer!

With it all packaged up, the last step is to charge the LiPo battery fully before I “deploy” the device.

Once it’s been running for a week or so, I’ll have a much better idea of how reliable it is and then I will look at the next steps. I want to design a PCB for the sensor and get a better box to house it all. The software could also be improved, for example, only sending an updated temperature if it has actually changed. I would also like a way to dynamically alter the sleep period, for example, checking very 30 minutes between midnight and 5am.

It has been interesting to get back into some electronics. I forgot how much I really enjoy experimenting and learning with physical stuff, not just software!

Den – Installing a smart socket

As part of the Den Automation range, they ship a 2 gang smart socket. It has the ability to be switched on remotely, to determine what’s plugged in and to even monitor the energy usage of the item plugged in.

I pre-ordered a few of these units as I saw them being used to turn my TVs off at the wall, rather than use their own standby. I currently achieve this using a few Sonoff Plugs flashed with Tasmota firmware. These are great, but are ugly as hell.

To get the ball rolling, I wanted to test out Den’s Smart Tag feature, the one that knows what is plugged in. I thought this best on a socket that is regularly used. For me, that’s one in my bedroom where my wife plugs in her hair dryer and hair straighteners. I thought this would be a good testing ground!

Installation was very simple. **** DON’T ATTEMPT THIS UNLESS YOUR CONFIDENT YOU KNOW WHAT YOU’RE DOING! REMEMBER TO ISOLATE EVERYTHING AT THE FUSE BOARD AND CHECK THE SOCKET IS DEAD BEFORE TAKING THE COVER OFF. GET A QUALIFIED ELECTRICIAN IF YOU HAVE ANY DOUBT ****

A classic, but dumb, double gang socket!
Simply wiring with two lives, two neutrals and two earths
The inputs on the Den Socket
The socket installed and looking good!

With the socket installed, I tested the manual operation to ensure everything was okay.

The app doesn’t really deal with empty screens all that well!

The pairing process starts the same as the switch. Hold the Den button for a few seconds until the light starts blinking and start the process in the app. It paired very quickly.

Once it was connected, it showed that two sockets individually. Tapping the little socket flicked the physical switch on and off. The sockets don’t have the same 45 second recharge time that the light switches have since these sockets have constant power. A limitation of the lack of neutral in UK light switches. Den still deserves credit for solving that in their light switches.

Once I’d finished this part, the app prompted me to add some smart tags.

The Den Socket comes with five Smart Tags. You can see this in my unboxing post.

I found my wife’s hair dryer and straighteners and popped a tag onto each plug.

I think plugged in one of them.

The part at the bottom is interesting – if the appliance is left on for a specified number of minutes, Den can turn it off automatically. They use hair straighteners as their example for this, so I turned it on, setting ten minutes.

I repeated the process for a hair dryer.

These two items then show up in the Appliance section of the app. It knows *where* it’s plugged in and when something is unplugged.

I haven’t tested the notify if left on feature yet, so I’ll post something when I get a chance to test that.

I was also disappointed to find out that the energy usage feature isn’t currently available. I would have expected them to include something pretty basic (current watt consumption or similar). I’ll update this post when they release that.

I have two more of these units to install. The next one goes onto the TV in the sitting room. I’m going to pair my Den Remote with those sockets, making it easier to control the TV.

I’ll do another post on that in the future.

Den – Installing a light switch

In a previous post, I covered the Den Automation Smart Hub setup. Next up, I’d like to cover the installation and setup of their 1 gang light switch.

I ordered four of these, to cover the rooms upstairs in my house. I’ll post the processing I went through to install one of the switches.

WARNING – CHANGING THESE SWITCHES REQUIRES EXPOSE TO MAINS VOLTAGE, WHICH IS EXTREMELY DANGEROUS. TAKE THE NECESSARY PRECAUTIONS. I AM NOT RESPONSIBLE FOR ANY INJURY THAT MAY RESULT. REMEMBER TO ISOLATE YOUR SWITCHES AT THE FUSE BOARD. IF IN DOUBT, GET AN ELECTRICIAN!

The humble light switch. Please ignore the filth of my walls!

Having turned off the lights at the fuse board (see my stern warning above) I removed the face plate.

A simple switch. Brown is the live and the blue is the switched live. The box is earthed too.

Den Switches require an earth connection to function (I’m guessing they use the voltage across live and earth to charge their capacitor, keeping the leaked current so low it doesn’t trip the RCD – clever sods!)

The Den switch has four inputs, Earth, Live, Switched Live 1 and Switched Live 2.

Den provide a small Earth cable that acts as an extensions, so I wired that into the backing box.

I added the Den earth extension into the earth connector of the backing box.

The backing box on my switches isn’t deep enough to accommodate the Den switch, so I had to use the provided spacer. I hung that over the wires.

I then connected it up and screwed it in place (using the longer screws provided by Den)

The Den Switch after installation

After restoring the power at the fuse board, I was able to turn the light on and off. Pretty useful to know that still worked šŸ™‚

To pair the switch with the Hub, I launched the Den App and, under the settings part, opted to add a new light switch.

The app starts to guide you through the process, similar to the Hub setup
A soft light starts to blink on the switch after holding down the button

The pairing process took about fifteen seconds.
Customising your new light switch

Name the light using their own names or create your own
Add it to a new room….
Choose an existing room
Done

The installation process was quick and painless.

Unfortunately, after I’d installed mine and I was cleaning it down, I noticed it didn’t quite fit correctly:

An imperfection in the switch prevented it sitting flush against spacer

I wrote to Den’s support email and, whilst it took two days to get an actual response, they dispatched a replacement which I received the next day. I swapped them out and the replacement was perfectly fine. I would have liked a faster reply from support, but they did resolve the issue without any question (I just included the above picture).

I swapped out four light switches upstairs, so I can now control all the bedroom lights.

Firmware update messages are kinda useless as you don’t know the room!

One point of complaint that I still has is that one of the switches hasn’t updated its firmware yet. Three updated to the 1.3 firmware without any issues, but the forth is still stuck on the 1.1 firmware. I need to contact support about this.

Den Automation – Unboxing

It’s been a long time in the making, but Den Automation finally started fulfilling their pre-orders earlier this month. I received my pre-ordered items, an order I placed in March 2018, last Monday. I’ve been looking forward to getting my hands on some Den gear since I first heard about the company in 2017. I love to dabble in home automation and the idea of a light switch that was a drop in replacement for a “dumb” light switch sparked joy!

I should point out that I’m an investor in Den Automation, holding a few shares that I bought through Seedrs.

So, what did I buy?

  • Smart Hub (required to control everything else)
  • Four One-Gang switches
  • One Double Gang socket

Den, as a thank you, threw in a remote too. That was a nice surprise.

The packaging looks nice and reminds me a little of Nest product packaging, with a nice sleeve surrounding the box.

The Smart Hub

The Smart Hub is the brains of the operation.

Opening up the Smart Hub Box.
The contents – The Hub, Some instructions, an Ethernet cable, power cable, adapter and mounting screws.

The hub itself was a little smaller than I expected. It was very light in weight. If I’m honest, it does feel a little cheap, but I’m only comparing that a Google WiFi unit that I had close at hand. That said, it didn’t feel flimsy and the connectors were solid when I plugged in the power and Ethernet cables. I was surprised that the power connector on the hub itself wasn’t USB. I was also surprised the Smart Hub required an Ethernet connection.

UPDATE: 28 Jan 2019 I’ve installed four light switches and they feel solid now that they are on the wall. After a few operations I couldn’t tell the difference. The Hub is also in position and I’ll hopefully never touch it again, so comments on its weight seem silly now.

The Smart Switch

This particular device was the reason I love Den’s concept. Smart WiFi switches are nothing new, but most are either touch based or require a neutral connection (like Sonoff’s offerings). I like the old fashioned rocker switch. Familiar and reliable. Lightwave RF have offered WiFi switches for a long time, but I’ve never taken to their push button design.

An extra earth wire, additional screws, spacing plate and switch.

On lifting the switch out and flicking the rocker a few time, I have to admit I felt a little disappointed. The rocker lacked the weight I’m used to. I handed it to my wife and she agreed. Of course, it’s easy to criticise something like this and, weighting aside, we agreed to reserve final judgement until I’d installed them. Having something that can flick itself on and off is *never* going to as solid as something manual.

The spacing plate is provided in case the backing box isn’t deep enough. it was well packaged, being hidden under the insert. This meant it didn’t get in the way of the Switch itself and the box was opened.

The insert contains a message to slip the box over. Wasn’t very obvious! I knew the spacer was included and lifted the insert out in search of it. That message probably needs to more obvious?

I read some of Den Automation’s early tweets and the use of Earth is crucial to the operation of their light switches, so I’m glad the included some extra cabling.

The Smart Socket

I ordered a Smart Socket just to try it out. I currently use one Sonoff Smart Plug to controlling power to my TV. It’s used a lot (the standby on my ten year old telly draws more wattage than I’d care to admit). The sockets in my house are brushed steel downstairs, but the sockets behind my TV aren’t visible, so I think this is a natural place. It will mean I turn off both my Apple TV and the TV itself.

Smart Tags, screws, the spacer and the double socket

One of the things that Den have done in this space is something I personally find very clever. They have created a concept of Smart Tags. These little tags fit over a plug and can be used to identify an appliance or item.

The socket included four smart tags

I haven’t tested them out yet, but the idea is as following. You pair a tag with an appliance i.e. a hair dryer. When you plug it in, the socket *knows* what’s plugged in. The example Den give is around hair straighteners and a person leaving them plugged in and turned on. I think it’s innovative, but requires every socket in your house to be a Den Socket (I don’t know if they have a patent on this idea).

As a neat touch, Den also put a Smart Tag on the power supply for the Smart Hub. That made me smile!

The Smart Hub power adaptor came fitted with a Smart Tag

The Remote

As a gesture of goodwill, for the numerous delays in shipping, Den chucked in a free remote.

It seems to just be an on or off type deal, but I don’t know anything beyond that. I assume you can pair it to one or more sockets or switches in the Den App. Once I get everything setup, I’ll be sure to write more about it.

Summary

The packaging was nice and well presented, but the items themselves felt a little cheap. It’s hard to explain. I have put this feeling down to the type of plastic and how it feels. The weight of the items also feeds into that feeling too. I know it’s pointless to try and gauge quality by the weight or feel of something and I’ll reserve judgement until I’ve installed them and used them.

I’ll do another post on the setup once I get more time.

I’m happy to answer any questions you might have. I think it’s fantastic that a small UK startup are producing products like this and that they have finally shipping is a testament to their hard work and determination. I’ve played no part in the development of the product, nor do I personally know anyone involved, but I can appreciate the monumental effort required to deliver hardware and software, especially consumer facing.

I take my hat off to Yasser and his team.

Project: Water Softener Salt Level Detector

In my house, I have a water softener. This requires topping up with salt at varying intervals, depending on the usage. In the year I’ve been living here, I’ve forgotten twice. Whilst it’s not the end of the world, it does mean that we get some limescale build up on theĀ taps and, more annoyingly, the shower head. I’ve triedĀ a recurring calendar entry to remind me, but the reminds would happen pop up when I was at work, or out and about etc. By the time I got home, I’d forgotten about it.Ā This sort of small annoyance was something I felt could be fixed with a overly complicated, time consuming, technological solution!

The problem

My water softener has a large compartment at the front, which you fill with salt tablets. Overtime, these get used up as the software regenerates itself.

I wanted a way to detect when the level of the salt had dropped to a low level.

How to measure the level?

My first pass at this problem involved using ultra sonic ranging device. I purchased a simple unit that was good for distances up to three metres. More than enough for my needs. To power this unit and make the necessary calculations, I chose a Raspberry Pi Zero, the latest entry to the Raspberry Pi Family. At about Ā£9 it seemed likeĀ a good option to get me started on my first IoT project. To be honest, I bought one on a whim and needed to put it to work!

I connected it all up and, in testing, it worked very well. I went as far as to build a simple iOS app to display the current level (I even build a simple web page with SignalR!!!)Ā  Unfortunately, it was useless when it came to the salt. Ultrasonic works best with flat surfaces and the top of the a pile of salt tables is anything but level! I thought about placing a piece of word or plastic on top of the pile, but this seemed like a hack. Okay, the whole thing is a hack, but I have to maintain some standards!

I went back to the web and started researching how people measure levels like this in real life, coal bunkers and whatnot. They use lasers. I didn’t want to spend any more money than absolutely necessary, so I would need a different approach.

The idea when struck me that I could use a reed switch (one that turns on in the presence of a magnetic field) and a wooden rod with a small magnet on it. The rod would rest of the pile of salt and move downwards, inching the magnet closer to the switch. On paper, this seemed like it would work, but in practice, I didn’t have enough space above the softener for the rod to protrude.

 

img_5492
The initial circuit board with the reed switch

I then had another brainwave. Replace the rod with a piece of string and a weight! The effect was the same, but it didn’t require the space! Genius.

img_5493
Waterproofing the *complex* electronics

img_5494
A lid with the mechanism attached

img_5495
Side view showing the string coming through

I put all the electronics into a water proof box and fed in the USB power cable. I added some LEDs to give me some idea it was working (green indicated my software was running and red indicated low salt). I moved the reed switch to the end of a piece of cable, so I could better position it. Some gorilla tape and a straw (to ensure the string moved unimpeded) and my contraption was complete!

I mounted the contraption onto my softener, replacing the lid.

img_5497

The software is designed to send me an alert once the salt runs low. As tempted as I was to write my own app and host a back end server, sanity prevailed and I just used IFTTT to raise an alert.

img_5498
An IFTTT alert telling me to top up the salt

Summary

The contraption has been in place now for a few months (it’s taken me that long to write this bloody blog post!) and it’s not been a mixed bag. I’ve gotten one alert, which arrived at 3 in the morning. Another time, I just checked the softener on a whim to discover that the salt was low, but the string had snagged and got stuck. I freed it and a second later got the IFTTT alert. At least it proved my python script was reliable.

I’ve put some plastic on top of the wood to ensure the string never snags again and I’m expecting an alert in the next few weeks.

The future?

With version one in place and working, I’ve started thinking about version 2. These are the improvements I plan on making:

  1. Switch to an MCU (Micro Control Unit). The Pi is great, but it’s overkill (running a full OS) and uses much more power than necessary. The NodeMCU board, for example, can be put into a deep sleep, which users very little power.
  2. Replace the breadboard with a PCB to reduce space.
  3. Trigger the measurement at fixed intervals and only notify me when I’m *actually* home. The last part I’m not sure about, but I suspect IFTTT can *know* where you are.
  4. Potentially use an IR sensor for distance measurement. Whilst this would eliminate any moving parts, it would require a hole into the salt holder and I’m worried that water might splash out or onto it.