Skip to content

Mongoose OS project with ADC and MQTT functionality

License

Notifications You must be signed in to change notification settings

tailucas/meter-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License

About The Project

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.

How it works

This project makes use of the ESP32 GPIO interrupt mode to act as a basic counter. When using the LDR Sensor Module, the photo-diode can be placed on the LED indicator of a prepaid electricity meter to tally metered kWh units fairly precisely. The model is useful because it allows the photo-diode sensitivity to be appropriate for the LED on the device. In some early testing, I got an appreciation for how quickly the interrupt handling is when I was incorrectly counting the 50Hz ripple in the LED brightness and it was necessary to filter it out. As an added level of resilience, I would also "debounce" the input according to the maximum theoretical current draw of the household through the meter.

Basic operation

At startup, the counter can start in one of two modes. The default mode is GPIO-interrupt where the interrupts are responsible for incrementing the counter and a separate timer is responsible for doing the accounting on the register value. The other mode uses a polling approach and the analog-to-digital converter (ADC). I left both implementations in the code because it is useful, tested boilerplate for other projects.

Depending on whether the counter is set to incrementing or decrementing, the counted values update a register_reading as part of a few other useful fields in an MQTT publish message. The meter also subscribes to a topic meter/electricity/control/# to enable remote resetting of the register. A tempting addition is to automatically read the real register value using some kind of non-invasive image recognition but that is outside the scope of this project.

(back to top)

Built With

Technologies that help make this project useful:

Espressif Mongoose OS MQTT

(back to top)

Getting Started

Here is some detail about the intended use of this project.

Prerequisites

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.

(back to top)

Usage

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.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Acknowledgments

(back to top)

Hits

About

Mongoose OS project with ADC and MQTT functionality

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published