Home Automation is all the rage. You talk to your mobile phone to control the lights, the fan, the air conditioner, or your pool pump. But how does it work? In this lesson, we explore the AI that could power a home automation system.
Let's consider a simple artificial neural network that takes a range of input commands and turns them into decisions to turn the lights or the fan on or off.
You can follow these steps along by opening the application MyComputerbrain in a separate browser window.
The image above shows the view in the application. On the right, we see the actions that our home automation system can execute. It can turn the lights on or off, and the fan on or off.
On the left hand side we see all words that the ANN is able to understand. The three black boxes ‘switch’, ‘light’, ‘on’ represent one set of training data. Drag the slider above the words ‘Input Pattern’ to see all training data. In between the input and output is an artificial neural network (ANN). The boxes in the input, hidden and output layer are called Perceptrons, corresponding to neurons in the brain.
Training the network
Before we can use the network, we have to train it first. Let's run the training process by clicking on the start learning button in the top right corner of our screen
The training data will be shown to the AI and it will make a series of repeated improvement attempts until the error of the network falls below a preset threshold. This process is called backpropagation.
The dial at the bottom-right will eventually turn green when the training process is complete. The network is now trained.
In this scenario, we use text input, but it isn't hard to imagine how a speech to text module would listen to verbal commands and convert them into text, or, alternatively, provide the audio directly to the ANN. We use text here, because of its simplicity.
Let's now enter a command for the AI to analyse. We could try my oven is too warm. Note how the AI is initially unsure about what to make out of 'my oven is', but then the words 'too warm' lock in with the AI's knowledge base. The result is that the fan gets switched off.
Let's assume you enter a room and you say just 'lights'. Most of us would want the lights on. This is an interesting case, because the word 'lights' is used both in conjunction with turning lights on and off.
Interestingly, the AI agrees with our human notion of 'lights' and decides that turning on the lights is the right decision over and above turning the lights off. Notice how the 'Lights on' output is firmly black whilst the 'Lights off' block is grey. This is an indication of how confident the AI is. Hover your mouse over the blocks to see inside.
Try to find a scenario that turns the fan on and the lights off!
In the experiment, the scenario and the training data were fixed. This is suitable for younger students and beginners. However, you can level this up and give students a freer reign over the scenario and training data.
In the following experiment you can build a simple home automation system that can do any four different things at your command.
Discussion & Reflection
Exploring the necessary elements of home automation, let's consider the main components of common digital systems and how they may connect.
Input: What forms of human input might a home automation system process (speech, written text, gestures, …)?
Decision-making: How might a home automation system process the human input in order to come to a decision about what needs to be done?
Output: How might a home automation system turn the decision into a physical action? This refers to what is called actuators, such computer-controlled electronic switches or motors.
These three aspects of a home automation system are very suitable to cover a range of content descriptors in the Australian Curriculum:Digital Technologies. Consider flow charts or any other form of diagrammatic representation to conceptually explore sequences, branching and iterations. The purpose of this step is not to write any code, but to explore and visualise possible steps and actions that might occur in home automation system. This task also provides an opportunity to discuss scientific ideas about electrical systems and how they are controlled using a digital system.
Our activity explores the above steps 1 (input) and 2 (decision making). For 3 (output) via physical actuators, a separate activity can be undertaken with Arduino, Raspberry Pi, or BBC micro:bit activities that demonstrate how code drives actuators.
The lesson plan for this activity, jointly developed by the Digital Technologies Hub and the Digital Technologies Institute, is now available. It can be accessed on the DT Hub Website.
Let us know what you think.
Until next time,
Acknowledgements. We'd like to thank Apps For Good, UK and the Digital Technologies Hub for their contributions to the inspiration and refinement of this scenario.