IoT: My Journey - The Prime Directive

IoT: My Journey - The Prime Directive

1. Why should you care?

Well, that is for you to decide. Are you the type of person who gets excited by cool bits of tech you can show off to your friends and family? Want an easier life by removing the need to pause the tv with the remote as you leave the room. Perhaps you are security conscious, wronged by a past theft and is looking to find a solution to this problem.

2. Who the heck are you?

My name is Fabrizio, and I have had these problems before. This journey starts with me being straight up bored. I just recently graduated Uni and still having a hard time finding a job. So, in the meantime I have built a cannon, learned some reinforcement learning, a new programming language (Elixir, real cool stuff) CAD software for 3D printing and dabbled back into electronics (specifically esp32s).

3. So where does IoT come in?

Hang on I’m getting there. During this time, my parents just recently acquired two new puppies. Now doesn’t that sound great? Well, not if you have a garden. It is more like a golf course now with the skeletons of past meals dug into 2 feet deep pot holes. I would show you a photo but it would be much too embarrassing, so here is me with them on the beach!

  • Dont be fooled - they are wee devils and cannot be trusted much like the Ferengi.

So their garden needs a make over. With much debate and drawings, the final design of the garden will include a garden room (with a home theatre, heating and a small kitchenette), raised beds, porcelain tiled throughout. Here are some 3D renders of the idea:

3d render gif

3d render gif lighting

4. This still isn’t IoT, you lied right?

Not at all! This is where it gets into the tech. I remember watching Wendell’s IoT video series and it got me thinking, if he is THAT passionate about it, there must be something to it. So I got some ideas about how the lighting around the garden and inside the garden room would work…

Ideas like:

  • Lights fading on as you walk past them
  • Playing cricket/night sounds at night through the outdoor speakers
  • Automating different scenes during holiday seasons
  • Implementing camera systems and sensors to monitor break ins (more on this later).
  • Automatically turning on heating when they arrive into the house.
  • And much more! (I can’t think of more off of the top of my head)

This is where I got real excited, blubbering out to anyone and everyone about these crazy ideas ( I still don’t think my parents even fully understand the potential). But as any silicon valley start up nut knows, a minimum viable product to show to potential clients is much needed. So I began my journey to discover the world of IoT.

5. Things I thought I knew and what I learned.

suck-it-yinyang

So media of late hasn’t given us the greatest idea of IoT devices, smart fridges that get hacked and are used in botnets etc. So security was one hurdle that was making me question my decision to go IoT.
Turns out there are various technologies that have been released with this in mind.

5.1 Aren’t IoT devices insecure?

Some are more secure than others. First of all, its all about how your “Hub” is setup.

Whats a hub?

It’s like Captain Picard, your IoT hub manages all of your IoT devices in the USS Enterpri…err I mean your home. And by manages I mean is able to receive data from IoT devices, send data to others and automate processes/scripts to do pretty much anything you want.
There are many types of IoT hubs and most are targeted towards consumers and are for “ease of use”. However as tech people, we don’t mind getting our hands dirty, which always mean, raspberry pi and open source code! Here comes home assistant.

Home Assistant?

The development of home assistant is crazy awesome. I am still trying to get used to using the YAML scripts and terminology but I digress - home assistant make connecting all brands of zigbee, ikea, phillips hue, z-wave, wifi, samsung, sonos etc devices come together for example.

  • Trigger: Shed Indoor Radar Sensor Detects movement
  • Action: Turn on TV, dim lights, play ST: The next generation on firestick
  • When: TV isn’t on, lights are off, its after 9pm

Kinda looks like a SQL statement doesn’t it? Anyways…

The interface have become easier to use and that is to pre-built integrations from the community, connecting devices is as simple as downloading an addon and configuring it.

So what about security?

You connect to your hub through your local network. Simple as https://homeassistant.local:8123 and your off to the races. It is possible to setup SSL certificates, tunnels, VPNs so that you are able to remotely access your home assistant instance, much like your home nas but as always exposing ports to the internet can be a security concern. But with IoT devices, I would be more concerned about what they are sending over the internet back to the manufactures. Now most IOT devices you will buy are from China, simply because they are CHEAP. But if you don’t like sending your sensor data back to the homeland and having remote firmware updates I suggest you stick to these devices -

5.2 Mesh Network devices

The first of which are mesh based network protocols which do not depend on wifi connection. That is right - no more sending home to china all your data… well in theory. Two of the most popular implementations are ZigBee and Z-Wave.

The short of it is that ZigBee uses 2.4Ghz spectrum much like WiFi but isn’t as fast, however can communicate with other zigbee devices via a mesh network. Z-Wave is similar to ZigBee but runs at sub-ghz frequency of 908.42Mhz meaning it doesn’t have the potential to interfere with Wifi Networks unlike ZigBee. Both options are great, they can both run on batteries for years or be plugged into the wall. Both are power efficient and quick BUT Z-Wave devices tend to be more expensive due to having stricter requirements that need to be met. However, that comes with the guarantee that all Z-Wave devices will play ball. ZigBee is an open-stand much like Z-Wave but is not as strict, as a result devices from brands like Aqara may drop messages in the mesh network from Philips Hue devices.

However, this can be mitigated by running separate gateways for each network. Speaking of which, both of these technologies require a “gateway” or in other word a usb dongle (much like a wifi dongle). The one I am currently using is the SONOFF Zigbeee 3.0 Plus. Works out of the box for home assistant. Users online report that if you have connection issues, using a USB extender may help reduce interference with your hub, however mine so far is doing fine in my pi’s USB 2.0 port.

I will be buying a Z-Wave gateway as soon as development in our garden begins.

5.3 ESPHome devices

Continuing on with devices, ESP-32s are just amazing. I love them. £1.50 for a wifi, bluetooth micro controller with 2 CORES? cough I’ll take 10 please. No but seriously, if you haven’t messed around with them I really suggest you do.

And ESPHome makes them even awesome…r? It everything ESP development should be, a firmware that runs on the microcontroller that allows easy remote updates to configure GPIO and functionality with a simple YAML script. It’s supper cool.

The process is simple:

  • Install the ESP-Home integration
  • Go to the web UI
  • Pop in your SSID and password for your wifi
  • Plug in your ESP32 into your home (or download the .bin file)
  • Flash it to your ESP with either the GUI or a esp-flasher tool.

And that’s it! (sometime you’ll encounter the odd bug or unsupported utility but most of the time its a smooth experience)

So what can you do with a microcontroller?

Pretty much everything a zigbee device could do but on Wifi, bluetooth, usb or even SPI or I2C! Basically if you go on ebay or aliexpress, you can pick anything from:

Basically, I would use these in environments where constant power is available most of the time (however, there are sleep modes you can put the esp32 into but connecting back to wifi takes time, slowing down trigger events unlike the Z-wave/Zigbee devices). And best of all - most of the sensors out there are VERY cheap. If you have a replicator, you can also make cool little cases for your projects… if not then a 3D printer would do but it is far slower.

5.3 Aside: MQTT

For you programmers out there, MQTT is an interesting messaging protocol. Much like web sockets and such, its a publish-subscribe network protocol built specifically for IoT. This may interest you because you can write a script very easily in python and do the configuration ON THE DEVICE and home assistant will know what it is capable of and all of its details.

The libraries for MQTT are SUPPER simple to use and with python a simple pip install paho-mqtt is all you need to get your hands dirty and experimenting. If anyone is interested, I created entity for a VLC player which will loop a video depending on which one home assistant selects for it. Great for doing something like simulating the weather through a screen light in Disney’s Treasure planet.

6. The Prime Directive

So why did I reference the prime directive here? My main aim with this project is setup a complete automated smart garden (and eventually house) where ZERO interference or interfaces are needed to get basic things done. I realised this when I was watching Star Trek on my plex server and had to keep pressing the pause button, but that required finding the remote… Which I have now lost. Wouldn’t it be great just to walk out of the room and the room know I was leaving? So I did that, I bought a cheap SONOFF door sensor and whenever the TV was playing content and I opened the door, it would pause, then resume playing when I closed the door. It works perfectly! However, I plan to upgrade this with a radar sensor and expand this out to lighting and the rest. Damn, I can’t wait!

Well hopefully I will continue this thread, maybe, if the contractors do a good job… only time will tell. Until then, this is Fabrizio - Signing off.

1 Like

Update: 01/05/2023

What’s new?

Ok, so it appears that their build will take longer than usual, contractors are a pain to deal with at the moment and pricing is crazy. So we’re still looking at and collecting new quotes.

For the time being, I have been working with some electronics to get a custom PWM led driver for the outside steps. I want it so that when a zigbee motion sensor triggers at night, then the leds fade in. A bit light this…

lightshow

So I have been working on a PWM circuit that can handle over 150w led strips on 8 channels (1200w) in total. Of course I won’t be using that much but its overhead for the 10m runs of led strips.
Once I have the board made, I’ll be posting the schematics and models on here so that its free for others to go onto JLCPCB and print their own boards.

I’ll be coming back with an update soon on the progress of that.

Networking

Looks like I will be upgrading our network to support the new home assistant features. Firstly, our old tp-link router will be replaced with a lenovo M720Q running opnsense, their server will be running tp-links omada controller software, with omada switches and four APs (two in main house, one outside and one in the garden room).

Super excited to see how the roaming feature will work with these access points. So far I have one Omada EAP650 AP and its been doing great, solid performance and range. There will be an update to this too.

That’s all for now!