In previous posts I’ve talked about the importance of planning and how to determine which features are essential vs. nice to have. Using my project Hoshi as an example, I’ll now go into how we go from a very high level overview into something we can implement.
Remember that in the previous installment I generated the following MUST and SHOULD list for my sensors:
We MUST have sensors that can detect events in the physical world. The sensors MUST also relay those events to the central system for processing.
The sensors SHOULD be small and inexpensive. The sensors SHOULD be able to be battery powered or use wall power. Users SHOULD be able to have an arbitrarily large number of sensors.
The way the sensors communicate back to the central server SHOULD be robust, easily extensible, and, to be convenient, not require extra hardware to increase range.
Looking at each line, there are some obvious questions that we need to answer. We MUST have sensors that can detect events in the physical world – so what events do we want to detect? In this case, I want to detect motion. I also probably want to detect light levels since I’m building this to control, among other things, lights, and maybe I want to not turn on my lights if it’s broad daylight and I’m getting plenty of sun in a room. So now, my “we MUST have sensors that can detect events in the physical world” becomes:
We MUST have sensors capable of detecting motion and capturing the ambient light level in their environment.”
The next MUST – the sensors MUST also relay those events to the central system for processing – gets me wondering HOW the sensors will relay those events. I could just have the sensors wired directly to the central server, but that seems really limiting – I’d have to run cables all over. So, a wireless connection it is.
This leads us down a further avenue for inquiry – what KIND of wireless connection? And what does having a wireless connection imply for the construction of the sensor – what kind of hardware will I need to support that wireless connection?
For the kind of wireless, I’m going to look at my SHOULDs. I want the sensors to be small and inexpensive, I want them to be able to be battery powered, I want to be able to have an arbitrarily large number of them, and I want my network of sensors to be robust and easy to add nodes to.
So breaking it down into details: I need something that is capable of handling logic for networking as well as reporting back a payload of sensor events over that network – this is clearly a job for a microcontroller such as the Arduino. Looking at my SHOULDs – I need small and cheap, and that means an Arduino Nano, which at ~$3-6 and about 1″x2″ or less, is both small and cheap. Even better, the Nano is readily available in bulk – if I decide I really want to scale up, I won’t need to source rare or difficult to get hardware. For example, if I wanted to use a Raspberry Pi zero – which is much more capable than a Nano and only $5 – I would have a hard time getting my hands on enough of them.
I will need to connect the motion and light level sensors to the Nano, so I’ll create a module for that which can be added to the Nano. This would require a few inexpensive components – a motion detector (about $1), light sensitive resistors/a light sensor (pennies on up to $1-2 for something fancy), and a small proto board (pennies) to put it all on. That qualifies as cheap!
I will need to add wireless networking to the system. I could do wifi – there are $2 chips for that and they can run pretty well on a battery for a fair amount of time. I could look at Bluetooth low power modules, though those run $5-10, which isn’t very cheap. I could use a RF transceiver, which I can get for under a dollar, but which might also have range issues – in order to get those and also solve the range issue, a little research shows they would cost $5-10 per part. So, I will probably go for the wifi chips.
I will need to make sure that range isn’t a problem and that the network is easy to extend – I want to be able to put my nodes wherever I like and they should be reliably able to communicate back to the central system. To me, this says I need to look at a mesh network, where each node in the network helps extend the network range farther. It also makes me think I might want to consider whether or not making some nodes in the network just function as extensions – I could have two models of nodes, one with sensors and one without…
Breaking THAT down, I realize that the sensor module isn’t very expensive, and maintaining two different types of nodes would be a pain, so I’ll just have one type of node. Ultimately, this gives me:
Sensor nodes will use standard parts that are readily available in bulk, and will all share the same design – all nodes will be functionally identical. The nodes will be based on an Arduino Nano. The sensor module will include motion and light level detection. The node will run on battery and use a wifi chip and will be configured to use the least amount of power possible. The node will be configured to work as part of a mesh network, which will allow the network to be extended as new nodes are added.
By breaking things down into the detail that I did, it prompts me to ask questions I might not have thought about when I was only looking at the high level overview. There are still some questions that were raised that I’ve left unanswered – lots of questions about the mesh networking, specific parts I’d want to use, requirements on range for the sensors (detecting motion within 2 meters vs 10 meters, for example).
My feeling is that, for a personal project, I now have an idea of what parts I want to use and can start doing a bit of research & basic implementation to get them working. For V1 of my project, this level of detail is sufficient – it’s a starting point that can be refined through trial and error into something that works. I’m now ready to get it done!