Environment Sensor

The Environment Sensor example application is a room sensor that measures and reports temperature, humidity, occupancy, and light level. These datapoint values can be sent to a Web page for display, to the Keypad example application for display, or to another application or device.

You can set alarm and warning threshold values for each environment sensor so that if a sensor value reaches below or above a certain threshold, there will be an indication reported by the Environment Sensor alarm output, and in the Environment Sensor Web page.

The motion sensor, along with taking readings, can be toggled on and off. When the motion sensor is connected to the LED Controller and configured properly, the scenes on the LED Controller will act differently based on whether the room is occupied or not.

You can input the alarm and warning thresholds, along with the motion sensor mode, directly from the example Web pages.

This section consists of the following:

Hardware

The schematics are available in Eagle and PDF format in the hardware directory within the Environment Sensor example directory.

Running the Environment Sensor Application

You can start the Environment Sensor example application as a service and optionally enable it to automatically run on boot, or you can run it from the command line. Running from the command line is useful for doing interactive testing and debugging. Running as a service is useful for setting up working networks and demonstrations.

To start the Environment Sensor example application as a service and enable it to run on boot, enter the following command:

izot_enable sensor


To stop the Environment Sensor example application and disable it from running on boot, enter the following command:

izot_disable sensor


To start the Environment Sensor example application without changing its boot status, enter the following command:

izot_start sensor


To stop the Environment Sensor example application without changing its boot status, enter the following command:

izot_stop sensor


To display the status of all IzoT services, enter the following command.

izot_stat


To run the Environment Sensor example application from the command line, change to the Environment Sensor example directory at $IZOT/izot/examples/env_sensor and enter the following command at the Linux shell prompt:

supy env_sensor.py [-C] [-D] [-d DEVICE] [-h] [-I] [-i] [-l LOG] [-m] [-n NVD] [-p PROGRAM_ID] [-s none] [-v] [-r RESET_TYPE]


The following table summarizes the command-line flags and options:

Flag / OptionDescription
-CEnables debugging with the PyCharm IDE.
-DRuns the Environment Sensor example application in debug mode. The log level is increased for both the console log and the application log.
-d DEVICESets the device URI, e.g., uc://10.0.1.12:1628. If not specified the default URI is used.
-hDisplays the available flags and options.
-IDisables ISI. Without ISI, the application requires installation by a network management tool such as the IzoT Commissioning Tool.
-iRuns the Environment Sensor without any attached I/O hardware. This is useful for running the Environment Sensor on platforms that do not have the Environment Sensor I/O hardware.
-l LOGSets the path and filename for log files. If not specified, the default path is the Environment Sensor example directory, and the filename is sensor.
-mRuns the Environment Sensor in demo mode. In demo mode, periodic ISI messaging is increased to speed up device and connection discovery. The result is that more bandwidth is consumed for ISI messaging provide faster discovery at the expense of less bandwidth for application data.
-n NVDSpecifies the path for the non-volatile data directory. If not specified the default directory is sensor-nvd in the Environment Sensor example directory.
-p PROGRAM_IDSpecifies a program ID for this running instance of the application. PROGRAM_ID is a 16-digit hex value described in the Defining the Program ID. If not specified the default program ID for the Environment Sensor example application is 9F:FF:FF:05:00:68:00:03. Specify a different program ID if you have modified the IzoT interface for the example application and you need to load a different device class file for the modified application.
-r RESET_TYPEClears persistent data. Set RESET_TYPE to 0 to clear all persistent data; set RESET_TYPE to 1 to clear all persistent data except for the device unique ID. RESET_TYPE 1 is useful to prevent a change in unique ID which will result in a new discovery of the device by the IzoT Server.
-s noneDisables the sensor hardware.
-vRuns the Environment Sensor example application in verbose mode. The log level is increased to the maximum level for both the console log and the application log.