Sensebender Micro + button
-
If I undefine: //#define BATT_SENSOR 199
it's working.
But your code still not 100% so we have to find why.
But... but, i think i'm making a mistake: yes i plan to use 3volts power. But, i don't want it as a sensor ! I wan't it as a battery level like the very first SensebenderMicro sketch. So... I have to undefine BATT_SENSOR ? And i will not have it set to 3Vcc=100% ?

-
@martinhjelmare Any idea why siVolt is reporting values rounding up to either 2V or 3V in Domoticz? All I'd like to have is something like 2.9V
-
@martinhjelmare Any idea why siVolt is reporting values rounding up to either 2V or 3V in Domoticz? All I'd like to have is something like 2.9V
How are you calculating and sending it? Did you change to float? There was a bug in my original sketch.
Make sure at least one of the operands is a float in the division.
float siVolt = vcc / 1000.0; -
How are you calculating and sending it? Did you change to float? There was a bug in my original sketch.
Make sure at least one of the operands is a float in the division.
float siVolt = vcc / 1000.0;Yes, it is declared as float
void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; float siVolt = vcc / 1000; #ifdef BATT_SENSOR gw.send(msgBatt.set(siVolt, 2)); #endifIt is reported as either 2.000V (battery) or 3.000V (USB) in Domoticz
Changing siVolt to int or changing 2 in set does not change anything. -
Yes, it is declared as float
void sendBattLevel(bool force) { if (force) lastBattery = -1; long vcc = readVcc(); if (vcc != lastBattery) { lastBattery = vcc; float siVolt = vcc / 1000; #ifdef BATT_SENSOR gw.send(msgBatt.set(siVolt, 2)); #endifIt is reported as either 2.000V (battery) or 3.000V (USB) in Domoticz
Changing siVolt to int or changing 2 in set does not change anything.@alexsh1 said:
float siVolt = vcc / 1000;You should change 1000 to 1000.0, i.e. a float. Float math will be used if any of the operands is a float.
https://www.arduino.cc/en/Reference/Arithmetic -
@martinhjelmare Stupid me! Thanks for bringing this up - these issues are so simple, but very easy to overlook. I was about to start pulling my hair out....