Humidity Sketch causes Vera App to crash



  • I setup the MySensors gateway up today with my Vera Edge (UI7) and have a major issue. It appears that after adding this humidity sensor, it causes the Vera app to crash on my Galaxy Note 3 (Lollipop). I narrowed it down specifically to the Humidity sensor. Basically in the app, if I click on devices, it instantly crashes. The way I narrowed it down was by adding each device separately as a favorite so that it appears on the main screen when logging into the Vera app. Temperature works fine, as does the node itself, but as soon as I add Humidity, it instantly crashes the app. Is this a Vera issue or an issue with the MySensors library/Humidity sketch? Everything works fantastic on the PC


  • Admin

    We're using the standard Vera Humidity device. No special devices is created by the MySensors plugin.

    Do you have any other (z-wave) humidity sensors to compare with?



  • No unfortunately I do not have a zwave humidity sensor to test.
    BUT, I did do some more digging and found out the crash was being caused by a number format exception on Android using the integer class. This caught my attention because I noticed the humidity is being reported with a decimal on the web interface of Vera (eg. Humidity 52.0%) and the Android app is expecting an Integer (not a float). I suspect that the web interface just stores it as a string so it doesn't care about the decimal and Vera is probably attempting to (poorly) parse that string into an Integer in the Android app.
    I did confirm that this is the issue by manually changing the variable for the humidity sensor from 52.0 to 52 and the app works fine (until the sensor reports the humidity again).
    I'm going to do some more playing when I get home tonight, but the fix is probably going to be straight forward. Either send an integer from the sensor sketch instead of a float, change the base station to report as an integer instead of float, or change the luup for the humidity sensor to parse the float into an int (just drop the decimal). I haven't done a lot with luup before and still fairly new to Arduino, so any suggestions on the best route to take would be appreciated!


  • Admin

    Just send an int from the sensor. The sensor does not have the fine grained accuracy anyway.



  • @hek Just a quick update. Changed the float to an int on the sensor during my lunch break. No luck. Vera still recieves it with a decimal. Confirmed with the serial console that the sensor is indeed sending it as a int now though. Perhaps the Arduino gateway is coverting it back to a float before sending it? Will do some more digging after work again


  • Admin

    Strange. You could also try converting it to a string before sending.


  • Admin

    You did remove the number-of-decimal argument?

    msgHum.set(humidity, 1) -> msgHum.set(humidity)



  • @hek Ah Hah! That did the trick. I had only changed the variable to an int but had not removed the decimal argument. Works perfectly now! Thanks @hek !!



  • I have the same issue. Will work on the fix when I get back.



  • @jeylites said:

    I have the same issue. Will work on the fix when I get back.

    The fix is pretty simple, as @hek said the DHT sensors arent extremely accurate anyway (DHT11 is +/- 5% accurate), just change msgHum.set(humidity,1) to msgHum.set(humidity) in the sensor sketch to drop the decimal all together. Worked perfect for me and has been running flawless since yesterday now



  • @Bradley-A
    @hek

    The fix seem pretty easy to follow. But when I exclude the "1" and recompile, I get a bunch of error messages.

    
    Build options changed, rebuilding all
    HumiditySensor.ino: In function 'void loop()':
    HumiditySensor.ino:56:34: error: call of overloaded 'set(float&)' is ambiguous
    HumiditySensor.ino:56:34: note: candidates are:
    In file included from /Users/Jey/Documents/Arduino/libraries/MySensors/MySensor.h:17:0,
                     from HumiditySensor.ino:2:
    /Users/Jey/Documents/Arduino/libraries/MySensors/MyMessage.h:161:13: note: MyMessage& MyMessage::set(uint8_t)
      MyMessage& set(uint8_t value);
                 ^
    /Users/Jey/Documents/Arduino/libraries/MySensors/MyMessage.h:163:13: note: MyMessage& MyMessage::set(long unsigned int)
      MyMessage& set(unsigned long value);
                 ^
    /Users/Jey/Documents/Arduino/libraries/MySensors/MyMessage.h:164:13: note: MyMessage& MyMessage::set(long int)
      MyMessage& set(long value);
                 ^
    /Users/Jey/Documents/Arduino/libraries/MySensors/MyMessage.h:165:13: note: MyMessage& MyMessage::set(unsigned int)
      MyMessage& set(unsigned int value);
                 ^
    /Users/Jey/Documents/Arduino/libraries/MySensors/MyMessage.h:166:13: note: MyMessage& MyMessage::set(int)
      MyMessage& set(int value);
                 ^
    Error compiling.```

  • Admin

    You must cast the value to int.

    gw.send(msg.set((int)xx));



  • @hek

    I'm not following that part ... is it like this

    gw.send(msgHum.set((int)humidity));


  • Admin

    The compile can't find a method matching the argument you're calling the overloaded method "set" with.

    It looks at the type of the argument (float in your case).

    So you can either change "humidity" to be a int when you declare it or cast it to an int.



  • Hello,

    i see this is a old posting, but i have the same problem. But i found an error.
    I use

    send(summsg.set(sum));
    

    but this work:

    send(summsg.set(sum,5));
    

    regards
    ThomasD


Log in to reply
 

593
Online

6.7k
Users

7.6k
Topics

80.3k
Posts

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.