Temperature sensor

Hello,

For my graduation project for art school I want to make a camera that takes a picture when the temperature is above 25 celsius. I got both components (camera and temperature sensor) to work individually but I have no idea how to make it work together. I don’t know a lot about Arduino, only the basics. I’ve attached the code and I really hope someone can give me tips or tell me how I should build the code.

Camera___temp_sensor.ino (7 KB)

You don’t read the temperature sensor. The code presumes that you have a DS18B20 sensor in place. You try to extract the temperature from the raw data you get from the sensor but there is no code to really read that data from the sensor.

There is also a conceptual error in your project. Temperatures usually are changing quite slowly. So if the temperature goes above 25°C it usually stays there for a some time. During that time the camera continues to make pictures one after the other.

The code contains other errors, the

while (1) {

is probably wrong because the outside code (part of the temperatue reading/conversion) will only be called once.

while (celsius < 25);      //wait for buttonPin status to HIGH

is definitely wrong because it’s not waiting for a button as the comment states but it will wait forever if celsius is less than 25 at the moment it is reached or does nothing if celsius is greater than 25. You probably should re-read the temperature inside that loop.