Decimals not appear at Vera UI



  • Hello , I am modifying files multimeter to work well in UI7 , so far work well , but can not get me decimals appear in the interface vera ( in arduino if displayed) , only the first number , for example appears .

    Sketch

    gw.send ( msgVoltBat.set ( ( int ) VoltLevelBat , 2) , 1) ;

    sends 3.95 volts and appears vera UI 3.00

    I tried to change the type of variavle in S_Multimeter1 to i4 , UI4 , string , float without results.

    Use this skit to control the voltage of the battery and solar module and need to be accurate.

    Thank you very much


  • Admin

    @rabeliyo said:
    VoltLevelBat must be a float (or casted to a float) when calling set.



  • ok!! Like this?

    float VoltBatScale = analogRead(A2);
    float VoltLevelBat = VoltBatScale*4.12/376; //376 is the analog read at 4.12v (full charged battery)
    if (VoltLevelBat != lastVoltLevelBat) {
    gw.send(msgVoltBat.set((float)VoltLevelBat,2),1);
    lastVoltLevelBat = VoltLevelBat;


  • Contest Winner

    @rabeliyo

    yes, but you shouldn't need to cast a float to a float like you are doing here:

    gw.send(msgVoltBat.set((float)VoltLevelBat,2),1);
    

    also, because of the way floating point numbers work:

    if (VoltLevelBat != lastVoltLevelBat) {
    

    may be a LOT more frequently than you may actually wish. Consider just updating the controller with a simple timer instead.



  • Works!!! Thanks a lot, i upload my remake of multimeter for UI7, all works but i only use the current and the voltage for my solar module, i will change the impedance to Kw/h

    0_1459000846524_Sin título.jpg

    Vera Files:
    http://www51.zippyshare.com/v/fk2Ay5ww/file.html

    Now i have a problem with the 3.3 PIR mod, i open a new post XD


 

Suggested Topics

389
Online

8.1k
Users

9.0k
Topics

95.3k
Posts