How to simulate a counter widget?


#1

hi! I would like to know if you can do something similar to a widget in Cayenne. A meter of water for example that registers the m3 consumed. :slight_smile:


#2

Hi @ricardo_ramos,

What are you using as a sensor?

Cheers,

Craig


#3

hi!! I’m using flow meters


#4

So you would interface them to the Pi or Arduino analog in, then create a VIRTUAL_OUT function with a calculation to express your flow in volume, then display the virtual channel using MQTT or native Cayenne using the generic value or graph widgets.

Cheers,

Craig


#5

Yes, I had thought about it. But how to restart that counter after a while? it’s possible?


#6

Then you would have a reset button on your dashboard, and when pressed, you have a VIRTUAL_IN function in your code that clears the counter.

How are you thinking of interfacing? is it 4-20mA or analog voltage out, serial?

Craig


#7

The power is by usb. What would be the code?

This is what you mean? ( a example)


#8

You can use a button widget to reset your counter.

Here is a good example of using that sensor.

http://forum.arduino.cc/index.php?topic=8548.0

Then you would need to just add an accumulator and integrate it with the Cayenne serial sketch from the cayenne.mydevices.com dashboard.

Once you are connected to Cayenne and reading flow, I can help you with the virtual functions if you haven’t figured it out yet. Searching CAYENNE_OUT and CAYENNE_IN in this forum, should help.

Cheers,

Craig


#9

I’ll try. Thank you, I’ll tell you later