@berkseo Good question. The code seemed good at the time I wrote it, but I can't say that it was extensively tested. I may circle back to it at a future date, and if so, I'll take a closer look. Even with more than 500 downloads of the code, no one has posted any feedback on how well (or not) it has run. Also, I not sure how compatible the posted code is with newer releases of the mysensors library.
Even with the 0.1uF capacitor, I had wrong values.
So, I've gone with the voltage divider method, and it seems more reliable, at least for my case.
4.7V max to VCC, R1 1M, R2 330k, another 0.1uF capacitor in parallel with R2.
I don't need a very good accuracy, just a trend in order to know when to change my batteries.
Thanks for your help.