homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 307 forks source link

QUESTION: need help setting up pulse counter #267

Closed bertmelis closed 7 years ago

bertmelis commented 7 years ago

Dear,

First of all: great work on the Homie framework!

I'm in trouble with the convention and how to do this in de code. I find the temperature example somehow confusing.

Everything is working great, using the git-version. But I need some help with the setup/convention. I've got a interrupt-based pulse counter. Idea is to make a node WaterMeterNode("WaterMeter", "Counter"). The node has 2 properties: counter and totalcounter. The latter should be settable. Both have a number of litres water as "content". So the unit would be "litres"? Could anyone help me out to get my head straight?

By the way: I use a debouncer in the interrupt handler since I wasn't fully sure how the Bounce library works. Publishing is done by a ticker, so also interrupt-based. So I make a "snapshot" of the counters when it's time to publish. That was I won't be missing any pulses during publishing.

bertmelis commented 7 years ago

to see what I've made from it: https://github.com/bertmelis/homie-utility/blob/master/homie-utility.ino

tripflex commented 6 years ago

Guessing you figured this out? Just for reference wanted to post this here, haven't tried it yet, but here's one I found for a pulse meter: https://github.com/yves-ledermann/homie-esp8266-supplements/blob/master/src/Nodes/PulseCounter.cpp