Thank you. It is solved now.
Here is the new sketch reporting battery level using the vcc library.
/*
Mysensors Smart Button
*/
#define MY_DEBUG
#define MY_RADIO_NRF24
#define MY_NODE_ID 7
#include "OneButton.h"
#include <SPI.h>
#include <MySensors.h>
#include <Vcc.h>
#define SN "Kitchen Table"
#define SV "1.0"
#define CHILD_ID 1
#define SLEEP_PIN 2
// Setup a new OneButton on pin D2. true will set pin high (internal pull up), false will set pin low.
OneButton button(2, true);
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
const long interval = 5000;
const float VccMin = 1.9; // Minimum expected Vcc level, in Volts. (NRF can only go to 1.9V)
const float VccMax = 3.3; // Maximum expected Vcc level, in Volts.
const float VccCorrection = 1.0 / 1.0; // Measured Vcc by multimeter divided by reported Vcc
Vcc vcc(VccCorrection);
MyMessage on(CHILD_ID, V_SCENE_ON);
// setup code here, to run once:
void setup() {
// link the doubleclick function to be called on a doubleclick event.
button.attachClick(click);
button.attachDoubleClick(doubleclick);
button.attachPress(press);
} // setup
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo(SN, SV);
present(CHILD_ID, S_SCENE_CONTROLLER);
}
int messageA = 1;
int messageB = 2;
int messageC = 3;
void loop() {
currentMillis = millis();
// keep watching the push button:
button.tick();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
float p = vcc.Read_Perc(VccMin, VccMax);
sendBatteryLevel((uint8_t)p);
Serial.println("Sleep");
sleep(SLEEP_PIN - 2, CHANGE, 0);
}
} // loop
// this function will be called when the button was pressed one time
void click() {
send(on.set(messageA));
}
// this function will be called when the button was pressed 2 times in a short timeframe.
void doubleclick() {
send(on.set(messageB));
} // doubleclick
// this function will be called when the button was pressed for about one second
void press() {
send(on.set(messageC));
}