Getting buzzer to work with DS18b20 sensor

Hey all.

I have a question regarding the buzzer and how to get it to work with the DS18b20 sensor.

Im pretty new to the arduino world and therefore trying my luck in here.

My problem is I want the buzzer sensor to go off after the DS18b20 sensor have read a stable temperature in the scope of 36.8 - 37.3 degrees celsius for about 2 min.

I know how to get the sensor to read and also to get the buzzer making sound, but I cant find a way to get it to blast sound after the 2 min of stable reading have been made.

Best regards

Anden753

Use a global boolean to keep track of whether you're in the zone of temperatures you're using for the buzzer. Initialize it to false.

If the DS18B20 reports that the temperature is in range and your boolean is false, set it true and record the value of millis.

If the temperature is out of range and your boolean is true, set it false.

If millis()-startTime > two minutes and the boolean is still true, sound the buzzer.

Hey Wildbill.

Thank you very much for your answer, I will try to implement your recommendations into the code.

Best regards

Hey all.

Sorry for my broken english. Im pretty new to the arduino/coding world and is currently in an intership for my education. Here I've got a code from one of the coworkers that is being used to run some temperature tests. We've been messing with the idea on including a buzzer to this set up.

The code is being used to measure temperatures with 3 DS18B20 sensors on 3 Arduino nano boards.

The problem: The way we want the buzzer to go off is, when the 3 sensors have read a temperature between 36.8 to 37.2 degrees for 2 mins, so the stablelliazing in that temperature spectrum, the buzzer will go of.

But I find it very hard to getting it to work, so I uploaded the sketch with temperature measurement code.

Best regards.

Incubator_temp.ino (3 KB)

Anden753:
The code is being used to measure temperatures with 3 DS18B20 sensors on 3 Arduino nano boards.

It's not evident from the code how three separate Arduinos agree among themselves that the temperature is stable - or, who's going to drive the buzzer.

Anden753:
But I find it very hard to getting it to work...

What does this mean?

Your sketch is small enough that you could post it within code tags. See < / > symbol in posting box or just use the 'copy for forum' under edit in the IDE.

I have merged your two threads @Anden753. Please only create one thread per subject. The reason is that having multiple threads about the same subject may result in wasting the time of the people trying to help you due to duplicated efforts.