Find my error, win my adulation

Greetings,

I have been working on this for far too long, mostly going in circles. I have an app that communicates with a sensor and, when Clock2 triggers, if the temperature or humidity minimum or maximum thresholds are exceeded, the app sounds a spoken text alarm.

I have three blocks below. The first two work. If I just check temperature, the app reports when the min and max thresholds for temperature have been exceeded. If I just test for humidity, the same holds true and I can test for when the min and max set humidity is exceeded.

When I try to use both if/then subsets together, things get whacky and not all conditions are reported. Would someone with more skill than I please advise me as to my error(s)? I believe the error lies in my lack of knowledge about how to test both conditions, and not outside this group of blocks.




BLE_5_15.aia (3.1 MB)

you have 2 different BLE components, one for Temp, the other for Humidity
just use 2 different clocks, one for Temp, the other for Humidity

Taifun

1 Like

Here is an experiment for you to try, using the Do It facility.

I just did it on my phone, and I want to see if you can appreciate the results of the experiment.

Locate a block of code that invokes speech for two different messages, and connect your phone in the Companion so that when you apply Do It to those speech blocks, your phone speaks the message.

In quick succession, apply Do It to the first message, then to the second message while the first message is still being spoken.

Have the second message rudely interrupt the first.

Now think back to the last time we discussed this problem.

I think you mean search my entries for a possibly relevant message from you, as my memory is spotty and, when I am attempting different solutions, I tend to dismiss that which previously didn't work.

If @Taifun is not pulling my leg, his is a simpler solution that requires no memory recall on my part.

In such case why should not think about it

if ( (temperature > tempMax) or (temperature < tempMin) or (humidity > humidityMax) or (humidity < humidityMin) )
then
    call Speaker1.Speak ("Temperature or humidity threshold exceeded!")
end

Or

When Clock2.Timer
do
   if ( (temperature > tempMax) or (temperature < tempMin) )
       then
          call Speaker1.Speak ("Temperature threshold exceeded!")
   if ( (humidity > humidityMax) or (humidity < humidityMin) )
       then
          call Speaker1.Speak ("Humidity threshold exceeded!")

Actually the third one should work as you expected. Doesn't? Or use one lable in all four situation to know whether the four circumstances are triggering properly or not. You may use lable text as 1,2,3,4 for all the four. So depending upon the text appear you will come to know which instances was triggered and can design further logics. Also make sure both true will not trigger at a time to avoid confusion in the speech

I posted a solution to this problem here.

Here is a sample you can play with for the multiple Clock approach in

For slowly changing values like temperature and humidity, multiple very slow clocks with different intervals can deliver the error messages most of the time.


Speech_Clocks.aia (2.2 KB)

I chose long error messages, like

Pardon me, sir, but please adjust switch one. It is on. I apologize for the interruption. Thank you.