You are on page 1of 9

V1.

2 13 June 2023

2022-23 Trimester B - Internet of Things MMI126818-22-B (15 Credits)


RESIT Coursework 1: Combined Specification and Submission Template

1 IOT MESSAGING WITHIN GOOGLE IOT CORE.............................................................................3

2 END-TO-END APPLICATION UTILISING IOT DEVICE (PC) AND GOOGLE CLOUD............................5

3 CODE EXPORTS......................................................................................................................... 8

First Name
Surname
Student ID
Date

I declare that this coursework is an original piece of work that has been created only by me. The
work is not based on previous coursework that has been submitted as part of another module or
submitted to another academic programme of study.

Enter your name below as confirmation of this declaration.


Name: YOUR NAME

Page 1 of 9
V1.2 13 June 2023

Notes
 This document delivers the following:
o The CW1 specification
o The details of each response that is expected for each part of the CW. These are
provided as yellow-coloured boxes.
 You must deliver the CW submission within a copy of this current document, using the
entries provided.
 Before submission you must update the index on the page above. Right-click on the index,
select ‘update field’ and then ‘update entire table’ and click OK.
 Do NOT change the structure of this document. Do not remove any content.
 You are required to use your own words in responses to each question. Do not use direct
quotations from external sources. Marks will not be provided for copied narrative or
narrative where you have obviously copied and then altered the text slightly.
 Feel free to state any assumptions that you make in responding to any section.
 Unless specifically stated otherwise, you are required to provide only your own
diagrams/screenshots as part of your responses.
 For snippets of JavaScript code, do not use screenshots; copy the textual code content.
 Use bullet-points when you need to highlight several aspects related to a response you are
making within any part of the report.
 Do not copy diagrams/figures/images from external sources. All such elements must be
originated by you, unless explicitly indicated within the coursework specification. Copied
diagrams will not gain any marks.
 There is an expectation that your report will:
o have consistent layout,
o be spell-checked,
o be grammatically correct,
o have a clear narrative structure,
o have been proof-read to ensure that it meets each of the aspects listed above.
 There is a marking scheme provided. You MUST examine this so that you understand how
marks are allocated to each part of the assessment.
 The report must be submitted via Turnitin and must be in .docx format only; PDF files will
NOT be accepted.

 Writing Skills
o https://www.gcu.ac.uk/aboutgcu/academicschools/cebe/study/ldc/
learningresources
o http://www.sussex.ac.uk/ei/internal/forstudents/engineeringdesign/studyguides/
techreportwriting
o https://www.eecs.qmul.ac.uk/~norman/papers/good_writing/Technical
%20writing.pdf
 The following is a very detailed reference guide. Use this if you are in doubt over structural
aspects of writing:
o https://www.researchgate.net/publication/
240701960_Scientific_Writing_for_Computer_Science_Students

Page 2 of 9
V1.2 13 June 2023

1 IoT Messaging within Google IoT Core

(a) Provide a syntactically correct JSON data structure that represents an example of the
following information relating to a sensor oriented IoT Device. You should create keys and
values within the structure as appropriate, including nesting where this improves clarity. You
should select appropriate values for any data items included in the description. The required
data items are as follows:
 Unit identification, including a unique identifier (text item) for the IoT Device, a
version number of the hardware (number item), a location name (text item) and an
appropriate set of location geographical coordinates (numerical items).
 The time that the unit was last reset (number item, as a Unix timestamp value).
 The names (text items) of three sensors provided within the unit; the data should be
structured as an array. No sensor data is required.

Provide the JSON data structure below. Note that that this should just be JSON and
not a JavaScript expression. This should be formatted text (not a screenshot):

(b) Test the JSON structure by implementing it within a PC Node-RED flow. The flow should have
the following:
i. An ‘inject’ node to initiate a function execution.
ii. A ‘function’ node that emits the JSON data structure created in part (a) above. The
node should have a suitable name. Provide the JavaScript content of the function
node below (as text, not a screenshot):

iii. A ‘debug’ node that shows the value of the data structure in the Node-RED debug
panel. The node should have a suitable name. Show the output of this debug node
below:

iv. A ‘function’ node that extracts the name of the first sensor name in the array. The
node should have a suitable name. Provide the JavaScript content of the function
node below:

v. A ‘debug’ node that shows the first sensor name in the Node-RED debug panel. The
node should have a suitable name. Show the output of this debug node below:

Page 3 of 9
V1.2 13 June 2023

vi. Provide a screenshot of the overall flow developed for this question.
Screenshot:

(c) The IoT Device data structure in Parts (a)/(b) above is to form an appropriate message for
publishing to Google IoT Core. We will call this Message-1.
There is also another message that needs to be published; this message is to provide a single
example of values from all three sensors, an appropriate entry representing Unit
Identification, and the time of the message generation (as a Unix timestamp value). We will
call this Message-2.

Provide a JSON data structure that contains one example of Message-2 content:

Provide the name of the Google IoT Core messaging type that is appropriate for sending
Message-2 content:

Provide the name of the Google IoT Core messaging type that is appropriate for sending
Message-1 content:

(d) At the point in time when an IoT Device opens a connection to Google IoT Core, (i) identify
which Google IoT Core message-type can be automatically sent to the device from IoT Core,
and (ii) describe the type of data that this might contain:

(e) A Google Cloud application interacts with a controllable IoT Device (lighting) that will be
frequently updated with a set of parameters. Identify the name of the Google IoT Core
message-type that would be appropriate for sending this type of data:

Page 4 of 9
V1.2 13 June 2023

(f) When messages are received from an IoT device via Google IoT Core, describe how these
messages can be accessed within a Cloud application deployed on Node-RED. Note that your
answer should include the fact that two types of Google IoT Core messages can be received:

2 End-to-end application utilising IoT Device (PC) and Google Cloud.

You are required to build the following application that has two parts.
 The first part utilises an IoT Device that:
o Generates sensor data to be sent to a Node-RED application deployed on Google
Cloud.
o Receives commands that are used to control an LED matrix display.
 The second part uses the Google Cloud application that:
o Receives IoT sensor data and displays this on charts and gauges.
o Processes the sensor data.
o Sends updates to the IoT device to control the LED matrix, based upon processing
the sensor data.

The application is described in two sections. The first section deals with all aspects of the IoT Device
functionality. The second section deals with all aspects of the Google Cloud application functionality.
The communication between the Device application and the Cloud application is to utilise MQTT
messaging.

(a) IoT device functionality

The device has the following functionality:


 Is implemented in Node-RED on you PC or Mac.
o All nodes are given clear descriptive names, including any ‘debug’ nodes.
 Utilises the ‘Sense HAT’ simulator for simulated sensors and LED display.
 Regularly sends data as a single message to the Google Cloud application that
includes sensor values and timestamp:
o Sends pressure and temperature sensor data using the relevant interface on
the Sense HAT simulator. Humidity data must not be sent.
 You must restrict the data range from each sensor to be as follows:
 Temperature: 20 degrees C and above only.
 Pressure: 900mb and above only.
o Sends the current time in Unix timestamp format, as a number.
o The frequency of sensor data must be restricted to sending one set (both
sensors) of data every 10 seconds.
o Utilises standard MQTT (not Google IoT Core) via a public broker to send
each message to the Google Cloud application, using a unique topic. MQTT
topics should be unique (especially since you are using a public broker) and
be suitably descriptive.

Page 5 of 9
V1.2 13 June 2023

 Receives command messages from the Google Cloud application as follows:


o Utilises standard MQTT (not Google IoT Core) via a public broker to receive
each message from the Google Cloud application. See Part (b) below for the
MQTT specification relating to this.
o The received message values are listed below. For each received message,
the whole of the Sense HAT LED display should be set to a specific colour as
listed in the table below.

Command Message Received (text) LED Matrix Colour


‘NORMAL’ green
‘WARNING’ amber
‘CRITICAL’ red

Please deliver the following items. You can include clearly named ‘debug’ nodes (with
screenshot output from the debug panel) to evidence any aspects that you wish to highlight.

A screenshot of the complete IoT device Node-RED application. Please ensure that the
complete browser window is included – full width and height, with URL Bar.

Explain how you form the complete message to be sent to the Google Cloud application.
This should include the textual JavaScript content (not a screenshot) of any Node-RED
‘function’ node, and the configuration of any other nodes (as screenshots). Add debug
output as appropriate to evidence the functionality.

Show the full configuration of the MQTT Out node:

Show the full configuration of the MQTT In node:

Explain how each incoming MQTT message is processed all the way through to updating
the LED matrix. This should include the textual JavaScript content (not a screenshot) of
any Node-RED ‘function’ node, and the configuration of any other nodes (as screenshots).
Add debug outputs as appropriate to evidence the functionality:

Page 6 of 9
V1.2 13 June 2023

Show debug screenshots of the three types of incoming messages and the related Sense
HAT simulator LED outputs:

(b) Google Cloud Node-RED application functionality:

 Receives messages that include Temperature and Pressure data, and timestamp
values.
 Provides a Node-RED dashboard.
o Displays the following on the dashboard:
 A clearly labelled chart with Temperature data for the last hour.
 A gauge with the last received Temperature data item.
 A clearly labelled chart with Pressure data for the last hour.
 A gauge with the last received Pressure data item.
 The time of the last received data, in a text human readable format,
extracted from the received timestamp.
 A text output, representing the outcome of the rules shown in the
table below.
o The two Temperature-related items should be in one dashboard group.
o The two Pressure-related items should be in a second dashboard group.
o All other items should be in the final dashboard group.

 Processes each received message with the following rules, updating the dashboard
and sending command messages to the IoT Device as appropriate:

Rules are to be tested in the following order. The Send following Update the ‘outcome’
first rule that is true completes the rules-testing. Command to IoT dashboard text output
Device: with the following text:
(Temperature < 25) AND (Pressure < 1000mb) ‘NORMAL’ ‘Sensors OK’
(Temperature >= 30) AND (Pressure >= 1050mb) ‘CRITICAL’ ‘SYSTEM CRITICAL’
Otherwise ‘WARNING’ ‘Warning sent’

 The MQTT messaging to the IoT device utilises standard MQTT (not Google IoT Core)
via a public broker to send each message to the Google Cloud application, using a
unique topic. The MQTT topic should be unique (especially since you are using a
public broker) and be suitably descriptive.
 Sends a message to a Slack channel (created by you) when the ‘SYSTEM CRITICAL’
outcome is generated.
o The maximum rate that messages should be sent to Slack is once per
minute, and any messages that occur within the 1-minute period after
message-send should be discarded.

Please deliver the following items. You can include clearly named debug nodes (with
screenshot output from the debug panel) to evidence any aspects that you wish to highlight.

A screenshot of the complete Cloud Node-RED application. Please ensure that the
complete browser window is included – full width and height, with URL Bar.

Page 7 of 9
V1.2 13 June 2023

A screenshot of the complete dashboard, showing the charts, gauges and text outputs.
The charts should show at least 10 minutes of sensor values.

Show three examples of the ‘outcome’ output for the rules. You should show the
incoming sensor data on the debug panel, and the ‘outcome’ output on the debug panel
and on the dashboard.

Show how you deliver a message to the IoT device, describing the code for the rules and
the MQTT output. This should include the textual JavaScript content (not a screenshot) of
any Node-RED ‘function’ node, and/or screenshots of other nodes.

Describe (with narrative & screenshots as appropriate) the process of sending the SYSTEM
CRITICAL alert messages to Slack. Explain any authentication aspects of Slack messaging.

Explain how each incoming MQTT message is processed through to updating the Charts,
gauges, and the two dashboard text outputs. This should include the textual JavaScript
content (not a screenshot) of any Node-RED ‘function’ node, and the configuration of any
other nodes (as screenshots). Add debug output as appropriate to evidence the
functionality.

3 Code Exports

Please export the PC Node-RED code and the Google Cloud Node-RED code.
Ensure that only a single export is placed in each box. Do not combine exports!

The complete export of your Node-RED device flow, Courier font, font size 8
REPLACE THIS with device code.

The complete export of your Cloud Node-RED flow, Courier font, font size 8

Page 8 of 9
V1.2 13 June 2023

REPLACE THIS with Cloud code.

Page 9 of 9

You might also like