See my write-up on IoT with Mongoose OS. Here you can find a brief write-up about my projects based on Mongoose OS and my general experience with this IoT platform.
This is a Mongoose OS project containing a configuration template and code written in the so-called minimal JavaScript or mJS.
This project makes use of a choice between GPIO and analog-to-digital (ADC) inputs as sensory inputs for a security appliance. The project configuration should give some hints as to its use. Configuration key prefixes app.input
provide labels that are then used in MQTT messages.
Given the simplicity of the program and the constraints of mJS, you will notice overt duplication of logic for each of the required input channels.
At startup, the inputs are initialized based on the selected choice of ADC mode or GPIO mode. I was experimenting with the difference between the approach of sampling effective electrical resistance versus pulling the GPIO channels. Since the code was written, I decided to leave both in this implementation. Fork what works for you.
Two timers are started. The first timer is responsible for sampling the inputs at a configured rate, applying some trigger de-duplication logic, and then the second is responsible for sending heartbeat messages in the absence of any input deemed in an active state. If a sampled input is outside of the configured threshold, then an MQTT message is sent which contains some summary information about all inputs, including the one that is in an active state.
The use of the onboard LED pin provides useful feedback for when a given input has been deemed triggered.
Technologies that help make this project useful:
Here is some detail about the intended use of this project.
Your development environment needs to have the mos
tool available to build firmware binaries and for first-time configuration of the device. Mongoose OS has a good getting started guide with installation instructions.
The Mongoose OS documentation provides a detailed but concise instruction on how to use the mos
tool to build the binaries that can then either be flashed directly to a USB-connected IoT device or that can be uploaded to the mDash site and delivered as an OTA update.
Distributed under the MIT License. See LICENSE for more information.