Thermometer using Arduino

Thread Starter

rahul411

Joined Feb 19, 2018
260
I saw this project on this site and found interesting https://forum.allaboutcircuits.com/...ith-74hc595-4x-seven-segment-displays.133589/
As the project is completed but coding is done in such a way that it displays temp in fahrenheit and im better familiar with Celsius unit. So what changes needs to be done in code to get temp value in degree Celsius.
Also it would be nice to make this using attiny 85, is there any possibility of that? For this im thinking of only 2 digits to display. As there are less IO pins in tiny85
 

Ya’akov

Joined Jan 27, 2019
9,170
I saw this project on this site and found interesting https://forum.allaboutcircuits.com/...ith-74hc595-4x-seven-segment-displays.133589/
As the project is completed but coding is done in such a way that it displays temp in fahrenheit and im better familiar with Celsius unit. So what changes needs to be done in code to get temp value in degree Celsius.
Also it would be nice to make this using attiny 85, is there any possibility of that? For this im thinking of only 2 digits to display. As there are less IO pins in tiny85
The code included with the project seems self evident, what problem are you having?

Code snippet:
  1. void loop()
  2. {
  3. digitalWrite(ledPin, HIGH);
  4. sensors.requestTemperatures();
  5. tempC = sensors.getTempC(insideThermometer);
  6. tempF = DallasTemperature::toFahrenheit(tempC);
  7. tmp = int(tempF*10);
  8. if (tempF < 0){
  9. sign = true;
  10. tmp = abs(tmp);
  11. }
 

Thread Starter

rahul411

Joined Feb 19, 2018
260
The code included with the project seems self evident, what problem are you having?

Code snippet:
  1. void loop()
  2. {
  3. digitalWrite(ledPin, HIGH);
  4. sensors.requestTemperatures();
  5. tempC = sensors.getTempC(insideThermometer);
  6. tempF = DallasTemperature::toFahrenheit(tempC);
  7. tmp = int(tempF*10);
  8. if (tempF < 0){
  9. sign = true;
  10. tmp = abs(tmp);
  11. }
The guy made this project has values in fahrenheit by default. So i just have to erase the tempf part from code? Or what?
 

Ya’akov

Joined Jan 27, 2019
9,170
The guy made this project has values in fahrenheit by default. So i just have to erase the tempf part from code? Or what?
It would appear that you just need to eliminate the conversion to F and change the tests that use F.

I am not sure, at first glance what the scaling in the definition of tmp is for. But it is easy enough to try and see what you get.

Looking in the DallasTemperature library, there's good information in there as well. Do you understand the code at all?
 

Ya’akov

Joined Jan 27, 2019
9,170
Ah, well. Do you understand that the code calls a library that includes the routines needed to get and convert the temperature information?

I really think it would help you a lot, and not be too hard, to try and trace what the program does so you can modify it yourself. Particularly if you want to port this to a different MCU. It's probably a really good program to learn on, it's really not too complicated.

Have you ever written code for the Arduino?
 

Thread Starter

rahul411

Joined Feb 19, 2018
260
Do you understand that the code calls a library that includes the routines needed to get and convert the temperature information?
Yes, but never actually opened the library files to see what code is there.
I really think it would help you a lot, and not be too hard, to try and trace what the program does so you can modify it yourself. Particularly if you want to port this to a different MCU. It's probably a really good program to learn on, it's really not too complicated.
Yes I'd be glad to learn. So what all things prior to understanding of library, i must know?

Have you ever written code for the Arduino
Yes, the blinking led. But it is not something ground breaking in terms of what this code is.
 

Ya’akov

Joined Jan 27, 2019
9,170
I think you should try to write your own program that uses the library to read out in °C.

Not because you have to, but because that will give you a concrete project to learn from. You can use the existing code as a reference, but if you make each part work with your own code, you'll actually understand it.

The first step is probably to write a program that will give you an idea of how to use the IDE from scratch, variables, looping, and calling libraries so I recommend something that, say, counts up seconds on the display. It doesn't have to be super accurate or anything, you can just use

delay(1000)

to act as one second which it will be close to, and display the current count.

I think if you go through a few tutorials, look at the current program, and ask questions here when you are stuck, in a few hours you will be able to write your thermometer program. There are plenty of people here who like to help folks get started with Arduino programming, so real and specific questions about it will likely get good answers.
 

Thread Starter

rahul411

Joined Feb 19, 2018
260
I think you should try to write your own program that uses the library to read out in °C.

Not because you have to, but because that will give you a concrete project to learn from. You can use the existing code as a reference, but if you make each part work with your own code, you'll actually understand it.

The first step is probably to write a program that will give you an idea of how to use the IDE from scratch, variables, looping, and calling libraries so I recommend something that, say, counts up seconds on the display. It doesn't have to be super accurate or anything, you can just use

delay(1000)

to act as one second which it will be close to, and display the current count.

I think if you go through a few tutorials, look at the current program, and ask questions here when you are stuck, in a few hours you will be able to write your thermometer program. There are plenty of people here who like to help folks get started with Arduino programming, so real and specific questions about it will likely get good answers.
Thank you very much
 
Actually, if I am reading it correctly, all you have to do is change these two lines:

C:
  tempC = sensors.getTempC(insideThermometer);
  tempF = DallasTemperature::toFahrenheit(tempC)
to:

C:
  tempF = sensors.getTempC(insideThermometer);
  //tempF = DallasTemperature::toFahrenheit(tempC)
Sure, it completely negates the idea of meaningful variable names, but if you are outright saying you can't understand the code, the variable names don't have any meaning.

(and yes, I hope the TS, takes the time to understand the project and the code)

cc @Remembermyname
 
Top