Help for creating an alarm once temperature reaches a certain number

Hey all, I'm using an ESP32 as my temperature sensor module and my task is to generate an alert continuously if the temperature is higher than 30°C. Alert is cancelled only when the temperature drops below 29°C. generate an alarm continuously if the temperature is higher than 32°C. Alarm is cancelled only when the temperature drops below 31°C.

image
image
image

this is my timer block. when i code it like this it shows Error 703: Unable to play sound. It is a problem with the placing of the blocks because the sound was able to be played previously when I just used a simple if else loop. (I edited the codes as it didn't fulfill my code fully as the task wanted)

TLDR: can anyone help me with my task?

Set the source of the sound to play in the blocks
Is it a file in the assets?
Alternatively try the Player component

Taifun

Do a cleanup blocks to show everything.

I don't see Bluetooth data being read in the clock Timer.

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

You never assigned a sound file to any of your sound components:
image

Also, your temperature range comparisons are all mixed up (they should be one if/then/elseif ladder in ascending or descending order), and you destroy the variable contents (temperature) right before testing them.

As advised earlier, switch those Sound components for a Player component preloaded with the alarm sound, and use this block to test if it is playing already, instead of keeping a flag variable:
component_set_get

That should simplify your logic.

Here is an alternative ladder, with temperature boundaries in order, using a Player:

P.S. Keeping two separate lists in CloudDB is awkward, putting your data at risk if the two lists get out of sync.

It's better to add pairs (time, temp) to a single list.

For purposes of graphing later, avoid formatting the timestamps, instead use milliseconds (Clock1.SystemTime).

I am not sure what is an Alert?

The Sound component has a vibrate option

A post was split to a new topic: Can you teach me how to code for a temperature alarm