How do I correct this?

I wrote an apps by MIT app inventor that will receive Humidity value from DHT 11 via Bluetooth module and an alarm will turn on if the value more than 50. However my humidity value is blinking and the alarm is always turn on although the value that I get is lower than 50. And also for some reason there is 'OK' on the humidity value.

WhatsApp Image 2021-02-02 at 9.57.29 PM
this is the code block


this is how the result

in blocks set clock 1 timer always fires to false when clock 1 timer I mean
Inside the yellow clock 1 timer put set clock 1 timer always fires to false
In properties set clock 1 always fires to tick, enabled to tick

I edited please try

thank you for the reply will try to do it :blush:

Hello mochi

Your actual bug is the 'If' statement. It only updates the Text Box if the value received is greater than 50. Also, that really needs a Maths Block compare. Set the Text Box value after the data is received, then start your 'If'.

The Blinking is no doubt a timer interval that is too short. Timer intervals should always be set to be the maximum practical.

Hello to you to
Thank you for the reply and will try to do it also :blush:

1 Like

Yes, the "If" instruction, but not necessarily when greater than 50. The value of 50 is important for the alarm, while the label should display each value. So you have to add "IF" for "bytes avalible to receives". So when we receive a byte, we display it. When there is nothing in the buffer, we do not update the label.

That's essentially what I have said Patryk :upside_down_face:

:grin: I guess I got it wrong.

I would do it like this:

In arduino, use serial.println(humidity);

The word "ok" probably sends arduino, so you have to eliminate it there.

1 Like

for the code already try but bad argument keep popping out

What argument are you writing about? You need to present the problems in more detail.

It become like this

Put your arduino code here. Because from what I can see there are more parameters there, not only humidity.

#include "DHTesp.h"

#define DHTpin 13

DHTesp dht;
String voice;
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
Serial.println();
Serial.println("Humidity (%)");

dht.setup(DHTpin, DHTesp::DHT11);

}

void loop()
{
delay(dht.getMinimumSamplingPeriod());

float humidity = dht.getHumidity();

Serial.print(humidity);
Serial.print("\t\t");
}

If you just want humidity, that should be enough.

    #include "DHTesp.h"

    #define DHTpin 13

    DHTesp dht;
    String voice;
    void setup()
    {
    pinMode(13, OUTPUT);
    Serial.begin(9600);
    dht.setup(DHTpin, DHTesp::DHT11);

    }

    void loop()
    {
    delay(dht.getMinimumSamplingPeriod());

    float humidity = dht.getHumidity();

    Serial.println(humidity);
    }

thank you so much it still got some problem but I will try to solve it :smile:

What problem? Also set the clock so that it receives data faster than it is sent from the arduino. Or, clear the bluetooth buffer after each reading. And it is important that you enter "10" in DelimiterByte.

You can do it like this:

It is then certain that the buffer will not overflow and that the data will be kept up to date.

If, in addition to humidity, you want to read other parameters, then you need to rework a bit.

1 Like


this thing pop out but just once and will try the code block that you provide

If you don't use arduino code identical to mine and blocks, it won't work. Do not send the % symbol from arduino, just set it in the application. Only send numbers with arduino.

I see alright