Home automation with AI
About this lesson
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.
Year band: 5-6, 7-8Curriculum Links Assessment
Links with the Digital Technologies Curriculum Area.
Examine the main components of common digital systems and how they may connect together to form networks to transmit data (ACTDIK014)
Examine how whole numbers are used to represent all data in digital systems (ACTDIK015)
Define problems in terms of data and functional requirements drawing on previously solved problems (ACTDIP017)
Explain how student solutions and existing information systems are sustainable and meet current and future local community needs (ACTDIP021)
Investigate how data is transmitted and secured in wired, wireless and mobile networks, and how the specifications affect performance (ACTDIK023)
Investigate how digital systems represent text, image and audio data in binary (ACTDIK024)
Define and decompose real-world problems taking into account functional requirements and economic, environmental, social, technical and usability constraints (ACTDIP027)
Evaluate how student solutions and existing information systems meet needs, are innovative, and take account of future risks and sustainability (ACTDIP031)
Investigate how electrical energy can control movement, sound or light in a designed product or system (ACTDEK020)
Investigate the ways in which products, services and environments evolve locally, regionally and globally and how competing factors including social, ethical and sustainability considerations are prioritised in the development of technologies and designed solutions for preferred futures (ACTDEK029)
Electrical energy can be transferred and transformed in electrical circuits and can be generated from a range of sources (ACSSU097)
Use and influence of science
Scientific knowledge is used to solve problems and inform personal and community decisions (ACSHE100)
Energy appears in different forms including movement (kinetic energy), heat and potential energy, and energy transformations and transfers cause change within systems (ACSSU155)
Use and influence of science
Solutions to contemporary issues that are found using science and technology, may impact on other areas of society and may involve ethical considerations (ACSHE135)
Typically, by the end of Year 6, students:
Identify the impacts of ICT in society
- Explain the main uses of ICT at school, home and in the local community, and recognise its potential positive and negative impacts on their lives
Select and evaluate data and information
- Assess the suitability of data or information using a range of appropriate given criteria.
Typically, by the end of Year 8, students:
Identify the impacts of ICT in society
- Explain the benefits and risks of the use of ICT for particular people in work and home environments
Select and evaluate data and information
- Assess the suitability of data or information using appropriate own criteria.
Choose from these suggested assessment approaches and tasks that best suit your students.
|Possible tasks||Relevant content description(s)|
||(ACTDIK014) / (ACTDIK023)|
||(ACTDIK015) / (ACTDIK024)|
||(ACTDIP017) / (ACTDIP027)|
||(ACTDIP021) / (ACTDIP031)|
|ANN||artificial neural network|
|IoT||internet of things|
Tool used in the plugged part of the MyComputerbrain activity
This image shows the view in the MyComputerbrain application for the level 1 differentiation of the activity. On the right, we see four actions that our home automation system can execute. It can turn the lights on or off, and the fan on or off.
The left-hand side of the image depicts an artificial neural network (ANN), described here as the ‘input pattern’. The boxes in the input, hidden and output layers are called ‘perceptrons’. These can be likened to neurons in the brain. Within the input pattern, we see all the words that the ANN is able to understand. The three black boxes, ‘switch’, ‘light’ and ‘on’, represent one set of training data. You can drag the slider above the ‘input pattern’ label to see all training data.
Discuss the internet of things (IoT), which has made it possible to automate many processes we undertake in our daily lives. Now with the emergence of AI and the opportunities for voice commands, another level of automation is possible.
In pairs, ask students to sketch the floor plan of a typical house, and draw and label five ways that they could make the home a ‘smart home’ through automation. As a class, have the students share the different ideas. Which of them require AI? Which require sensors? How would digital and electrical systems interact with each other?
Discuss home automation:
- Have you used home automation personally? What were your experiences?
- Why do people use home automation?
- What are some typical use cases for home automation?
- How might a person with a disability benefit from home automation?
Explain that computers can be programmed to be intelligent or, at least, smart. Ask the class if they think a computer could understand the meaning of something they say or write. How would it do that? At this point, students might mention their use of Siri, Alexa or similar technologies.
This step relates to the main components of common digital systems and how they may connect in the context of home automation.
- Input: What forms of human input might a home automation system process (speech, written text, gestures etc)?
- Decision-making: How might a home automation system process human input in order to decide what needs to be done?
- Output: How might a home automation system turn a decision into a physical action? This question alludes to what is known as ‘actuators’, such as computer-controlled electronic switches or motors.
Input, decision-making and output, in the context of a home automation system, are highly suitable for covering a range of content descriptors in the Australian Curriculum: Digital Technologies. Consider flow charts or any other form of diagram 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 a home automation system. This step also provides an opportunity to discuss scientific ideas about electrical systems and how they can be controlled by a digital system.
The plugged activity explores input and decision-making, as discussed in Step 3 above. For the output step separate activities can be undertaken with Arduino, Raspberry Pi, or BBC micro:bit. These activities demonstrate how code drives actuators.
This plugged activity allows students to interact with an AI application to recognise written commands and make meaningful decisions, such as turning the lights on or off. No coding is required by the teacher or students. Students can use a total of 12 expressions, including single words and whole sentences, to train the AI.
The underlying AI runs locally in the browser, so it’s learning speed only depends on the speed of the local processor, rather than internet speed. For example, the training process will take approximately 30 seconds on a 2012 laptop.
To increase the speed of the learning process, the lines representing the synapses can be hidden by clicking on 'Hide wires' in the menu.
To see the colour changes of the lines representing the synapses, drag the slider to the left.
Note, however, that this will slow the learning process.
Students investigate the control required to switch lights and fans on or off. The training data for the ANN has already been provided and cannot be changed by the students. The experiment is available here.
Students are given the freedom to decide on four different outputs and to develop the training data. Students develop data sets and enter them into a table. Sample training data is provided for inspiration. The experiment is available here.
- The instructions in the right-hand menu of the application will guide students through the process, which consists of the following three main steps:
- exploration (level 1) or creation (level 2) of training data
- training of the ANN, via the Start Learning button
- testing of the ANN by entering short sentences into the input field at the top of the window.
On level 2, the experiment has a special feature, which is that the ANN is constructed in real time while students enter the training data. This is intended to help students understand how the input data influences the topology of the ANN. It is an opportunity for the teacher to discuss data input, and more general human sensory perception with students.
Note: The student input is not stored. When the browser window is reloaded, the experiment is reset.
- Share what you have learned about AI and how ‘smart’ a computer can be.
- In level 2, students may come up with their own training data and project to test the AI further with additional scenarios. Here are some prompts:
- What other home automation scenarios can you imagine?
- How would the AI need to be changed if more than four outputs were required?
- How could the AI be improved (eg by adding a thesaurus that would recognise similar words)?
- How could an actuator be connected to the output perceptrons?
- When the AI has been trained, highlight the level of shading for the four output perceptrons of the ANN to represent the confidence level.
- Hover over any of the output perceptrons to display a pop-up that shows the perceptron’s internal values.
- Discuss the scale. If the box is fully black this means that the AI was very sure, whereas a light grey means that it was not quite sure.
- When was the AI very sure of its guess?
- When was it not so sure?
- In the example below, the AI is 0.91 sure that the input ‘lights’ is to be understood as a command to switch the lights on.
- Observe the table with the headings ‘input’, ‘weight’, ‘product’, ‘sum’ and ‘output’.
- Each perceptron receives input data from other perceptrons.
- Each input is multiplied by a weight, leading to a product.
- The products are added up, leading to a sum, and then pushed through a function, which determines the output of the perceptron.
- Notice that the mathematics is not very difficult, but quite effective.
- Hover your mouse over any perceptron to check its data. Observe that the colour of the lines that connect to the input of a perceptron on its left correspond to the colours in the ‘weight’ column in the table.
- Let students visually compare the ANNs on their computers. Note that the colours of the lines will be different among ANN instances. The reason that each ANN is unique is that each starts with different random values in the synapses. These are represented in the weight column. If we had assigned the same value to each weight at the start, then the ANN could not have learned. The learning process leverages these small differences to achieve a successful learning outcome.
- Reset the experiment and retrain the ANN. Observe how the colours of the lines change as the AI learns. Green indicates positive values, red indicates negative values and black is neutral (close to zero). These lines regulate the data flow between the perceptrons and can be compared to the synapses in our brains and they.
- Is green more valuable to the learning than red or black? No, they are all equally required to achieve the learning outcome.
- Note that the words from the training data are provided to the ANN as binary numbers. The ANN–internal representations of the words are 1’s and 0’s.
The function depicted above is a Sigmoid-function: f(x)= 1 / (1 + e^(-x)). During the learning process, the ANN also uses the following derivative of the Sigmoid function: df(x)/dx = f(x) * (1 - f(x)).
Why is this relevant?
AI is the ability of machines to mimic human capabilities in a way that we would consider 'smart'.
Machine learning (ML) is an application of AI. With ML, we give the machine lots of examples of data, demonstrating what we would like it to do so that it can figure out how to achieve a goal on its own. The machine learns and adapts its strategy to achieve this goal.
In our example, we are feeding the machine with words. The more varied data we provide, the more likely the AI system will correctly classify the input as the appropriate output. In ML, the system will provide a confidence value. In this case, it is a decimal value between 0 and 1, and the output box is coloured white, shades of grey or black. The confidence value provides us with an indication of how sure the AI is of its classification.
This lesson focuses on the concept of classification. Classification is a learning technique used to group data based on attributes or features.