temperature-alarm-ikki646i v1.1.0
IoT Devices - Assignment - Temperature
This assignment requires you to create a Node.js package that implements a basic temperature alarm.
Create a class TemperatureAlarm
which periodically (every 10 seconds for example, don't hardcode it) reads a temperature from a file (later this will be refactored for the RPi).
Add an EventEmitter to the class so users can get notified if the temperature changes or reaches a given threshold.
Add a readme to the project with an example.
Make sure to create a package.json
file using npm init
.
Setup
Use npm install
to install the required packages before using the alarm.
Usage
The temperature_alarm requires a temperature sensor object with a get_temperature() method that returns a temperature (number).
An example temperature sensor class TemperatureSensor is included for demonstration purposes. It will return the value read from a specified json file when get_temperature() is called.
To run the demonstration use the command npm start
. In this example an update interval of 10 seconds and a threshold of 30 is used. You can change the value of temperature inside the temperature.json file (not while the TemperatureSensor is reading from it).
The temperature will be printed to the console when a change in temperature is detected and "alarm" with the temperature will be printed if the value reaches the threshold.