Gauge widget issue (data sent via MQTT)

Hi All,

I have a Raspberry Pi 3B with a python scripts that sends data from some sensors to a Cayenne Dashboard via MQTT.
Everything is working good except for 1 gauge (I have a total of 5 gauges) where it should display the battery voltage of a battery powered ESP8266.
This ESP8266 sends data to the Raspberry where, after some processing, a python script is used to send these data “back” to the dashboard every 10 minutes (temperature, humidity, solar light intensity, battery voltage and load current).
The gauge that is facing a problem is the one regarding the battery voltage: everytime there is new data, it always displays “0.000” and only when I refresh the web page with F5 it displays the correct value (for example 3.723).
The other gauges display their value as soon as data are received without the need of refreshing the page.
Of course each gauge has its own channel so…why this behaviour?
Thank you, regards.

Roberto

can you share the code you are using?

Let me know if you need the complete python code…by the way, the line used to send the value to the dashboard is the following:

client.virtualWrite(11, 0+bVoltage, dataType=’’, dataUnit=’’)

where “bVoltage” contains the value to be displayed in the gauge.
The lines for the remaining gauges are the same except for the channel number and the variable.

Roberto

yes.

Ok, when I’m at home later, I will publish the complete code.

Roberto

I attached the complete code.

mqtt_pwr.txt (4.1 KB)

The value to display on the various gauges are sent with this format:
value*command

for example, to send the battery voltage the command is “3.600*b”.
The logic is the following: an ESP8266 “nodeMcu” sends the readings from the sensors to a Raspberry Pi through TCP, the Raspberry processes data, formats them and then sends to the python script all the values via “TCP:9080”.
The python script sends values to the gauges via MQTT.
The only gauge that has the described issue is the one that receives data with the command “b” (in the source code the line “if tipo==‘b’:…”), all the others don’t have problems.

Roberto

            client.virtualWrite(11, 0+valore, dataType='', dataUnit='')

can you pass an analog sensor data type in it. You will need to delete and let it re-add new widget.

I did it but the issue still remains.
I tried the following:

  • removed the gauge, set it up again on a different channel, issue remains
  • removed the gauge, after some seconds it appeared (automatically) a “Value widget”
  • left the “value widget”, the issue didn’t appear
  • I set one more “Gauge widget” on an unused channel (15), modified the python script to send battery voltage to channel 11 (–>value widget) and 15 (gauge widget): the “value widget” updated its value automatically, the “gauge widget” updated its value to “0.000”…pressed F5 and also the gauge widget displayed the correct value (the same of the “value widget”).
    So the issue seems to affect only the gauge widget…

Roberto

are you setting the gauge via the dashboard or change the widget setting?

I removed the gauge by clicking on the small “gear” in the upper right corner of the widget and then clicked on “remove”.
Then I added it clicking on “Add New–>Device and Widgets–>Custom Widgets”, set the channel up to “15” and saved it.
Once it is on the dashboard, if I have to modify its settings, I click on the small “gear”…

don’t add it this way.
Follow these steps:-

  1. Remove the widget.
  2. On the next publish from the device, a green temporary widget on channel 15 will appear on the dashboard.
  3. Click on the “+” to add it to the dashboard.
  4. Click on the setting and change the widget type to gauge.

It worked, thank you.

Roberto

1 Like