2.2.1 Application Task
By default, the user input can be sent through serial communication, and if the
lte_on
command is issued, the LTE module will be enabled, and
communication will be done exclusively through the cloud.
For example, the light intensity can be set through serial sending l70 or through MQTT sending Level70 to board commands topic.
A list of available commands through serial are as follows:
- help: Print the help menu
- gl: Get the actual gear level
- gs: Get the gear status
- motion_on/motion_off: Enables or disables the motion sensor
- light_on/light_off: Enables or disables the ambient light sensor
- lXYZ: Sets the light intensity
- lte_on: Enables LTE module and disables serial communication. Board reset is required to regain serial communication.
The application task covers:
- Serial communication
- If enabled, LTEIoT_tasks cover the LTE IoT module initialization steps and MQTT configuration
- Light control in these four possible
use cases:
- User controlled through serial or MQTT
- Automatic control based on motion sensor
- Automatic control based on light sensor
- Automatic smart control based on both motion and light sensors
In order to do various operations at a specific interval, the SysTick timer is used. Periodic operations are as follows:
- Check LTE signal status.
- Interrogate the AWS MQTT server for latest received messages on the command topic.
- Publish latest data to the AWS MQTT status topic.
- Change subscription status in case of LTE module reset.
- Monitor for how long the lights were turned on in specific use cases.
- Add delay when changing the light from a value to another over a specific time.
Both Microwave and Ambient Light sensors give their values through the analog pin found on mikroBUS, and ADC0 and ADC1 were used in the application to read their values.
The evaluation board has two switches that were used to give rapid commands to D4i gear. Pressing SW1 will send the light off command and pressing SW2 will send lights level to 20 percent.