Sensebender Micro + button
-
@tbowmo "call of overloaded 'set(float&)' is ambiguous"
I don't know what it mean.
And i don't know why the very first sketch is working for you and not for me ! :sweat_smile:/******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ 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)); #endif // Calculate percentage vcc = min(vcc, 3000L); // vcc max is 3000 vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 11.0; gw.sendBatteryLevel(percent); transmission_occured = true; } } /*******************************************f``` -
@tbowmo "call of overloaded 'set(float&)' is ambiguous"
I don't know what it mean.
And i don't know why the very first sketch is working for you and not for me ! :sweat_smile:/******************************************** * * Sends battery information (battery percentage) * * Parameters * - force : Forces transmission of a value * *******************************************/ 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)); #endif // Calculate percentage vcc = min(vcc, 3000L); // vcc max is 3000 vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 11.0; gw.sendBatteryLevel(percent); transmission_occured = true; } } /*******************************************f```Sorry that was my addition and I haven't actually tested the siVolt thing yet. Everything else works though. But I don't see why it shouldn't work if you declare it properly first.
-
BATT_SENSOR si declared.
... I think msgBatt is not.
Does it should be here ?// Sensor messages MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);Wait not it's just under:
#ifdef BATT_SENSOR MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE); #endif -
BATT_SENSOR si declared.
... I think msgBatt is not.
Does it should be here ?// Sensor messages MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);Wait not it's just under:
#ifdef BATT_SENSOR MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE); #endifIt's declared three lines below, inside the ifdefine.
Try declaring siVolt outside the if block in the battery function.
Edit: Scrap the last suggestion.
-
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% ?

-
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% ?

Might you need to specify decimals if sending float as message. If you want to try, add a second argument with an integer number for decimals.
https://github.com/mysensors/Arduino/blob/1.5.3/libraries/MySensors/MyMessage.cpp#L212 -
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)); #endif // Calculate percentage vcc = min(vcc, 3000L); // vcc max is 3000 vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at long percent = vcc / 11.0; gw.sendBatteryLevel(percent); transmission_occured = true; } } -
The measurement method is not accurate at all. It relies on an internal reference that can vary in value between boards (I can't remember the accuracy of it at the moment)
If you don't want the battery voltage, then uncomment the #define for BATT_SENSOR in the top of the sketch, and move the float siVolt = vcc/1000; to be within the #ifdef BATT_SENSOR like:
#ifdef BATT_SENSOR float siVolt = vcc / 1000; gw.send(msgBatt.set(siVolt, 2)); #endifNow it should compile, and send battery percentage as the standard sensebender sketch.
-
I personaly think that it's quite good. When powered by FTDI, it found 3.00V.
And I have only add the "//" to BATT_SENSOR and it work good.
(you inverted the thing in the message just above).Thanks again for you help.
Now i work very good and very fast. I just have to check for adding an antenna to the controller. -
@Pierre-P How do you find the battery life please? I am planning to fit Sensebender with nrf24l01+ SMD and CR2032, but I wonder how long the battery is going to survive? Appreciate if depends on your sketch, but given one is conservative (i.e. no need to send temp/hum every 30-60 sec, but probably every 5-10mins or so), what's your estimate please?
-
I can't tell you for the moment, I haven't check the real voltage of the CR2032 at the beginning. I'll try to make two mesure between 30 days.
But my sketch is 1800000ms or 30min sleeping (if no-one press the button). Because it's a redundant information, my Jeedom controler have a meteo plugin who's working good. (i'll use it for the mini-night-temperature to have a message if there is glass on my car's windows). -
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.
