UNO Temp sensor

New to Arduino:

Want to use temp sensor that came w/Starter Kit, but I don't know what temp sensor it is that was included ? How do I tell and when I do find out, how do I load the libraries ?

The most sophisticated project that comes w/my starter kit is writing out text to the display.
I would have expected a Temp project of some type?

Is there a project on this site that uses the temp sensor included shows how to include the library for it ?

Thanks
Sid.

(deleted)

There is more than one starter kit.
Is this a 2-pin sensor (thermistor) or a 3-pin sensor.
If it has three pins, it might be an LM35 or TMP36.
It should have some writing on it.
All three require different code.
Post a picture if you're not sure.
Leo..

Sorry, No numbers on the box. Title: "The Arduino Starter Kit"

Number off the 3 pin chip: Looks like a transistor !
|> TMP
36G7
#1421
882904

How do I post a picture to this forum ?

(deleted)

Found a simple project and wired it up, seems to work w/o any extra libraries ?

temp seems to jump about 1 -2 degrees every time the sensor is queried, is this normal ?

Is there a better sensor to use ?

sid3:
Found a simple project and wired it up, seems to work w/o any extra libraries ?

temp seems to jump about 1 -2 degrees every time the sensor is queried, is this normal ?

Is there a better sensor to use ?

Hi, good to hear you had some success.
Can you post your code and a link to where you got the circuit setup please?
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Thanks.. Tom.. :slight_smile:

sid3:
Found a simple project and wired it up, seems to work w/o any extra libraries ?

temp seems to jump about 1 -2 degrees every time the sensor is queried, is this normal ?

Is there a better sensor to use ?

No libraries needed for an anaolgue sensor like that.

Yes, because of the simple example code.
Need to use better code to make the sensor independent of supply fluctuations etc.

Yes. A digital DS18B20. Need to install a library for that one though.
Leo..

/*
Source project and code found here.

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int i = 0;
const int temperaturePin = 0;
float voltage, degreesC, degreesF;

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
delay(1500);
}

void loop() {

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Counting: " + String(i));

voltage = getVoltage(temperaturePin);

// Now we'll convert the voltage to degrees Celsius.
// This formula comes from the temperature sensor datasheet:

degreesC = (voltage - 0.5) * 100.0;
degreesF = degreesC * (9.0/5.0) + 32.0;
lcd.setCursor(0,1);
lcd.print("Temp F: " + String(degreesF));

delay(1000);
i++;
}

float getVoltage(int pin)
{
return (analogRead(pin) * 0.004882814);
}

Avoid instructables.com, unless you know more than the author of the article.

Attached code uses the internal 1.1volt Aref of the Uno for improved stability and resolution.
Try to merge the LCD code with this, so you can print to LCD instead of the serial monitor.
Code can be further 'improved' with averaging/smoothing.
Leo..

// LM35_TMP36 temp
// connect LM35 to 5volt A0 and ground
// connect TPM36 to 3.3volt A0 and ground
// calibrate temp by changing the last digit(s) of "0.1039"

float tempC; // Celcius
float tempF; // Fahrenheit

void setup() {
  analogReference(INTERNAL); // use internal 1.1volt Aref
  Serial.begin(9600);
}

void loop() {
  //tempC = ((analogRead(A0) * 0.1039)); // uncomment this line for an LM35
  tempC = ((analogRead(A0) * 0.1039) - 50.0); // uncomment this line for a TMP36
  tempF = tempC * 1.8 + 32.0; // C to F
  Serial.print("Temperature is  ");
  Serial.print(tempC, 1); // one decimal place
  Serial.print(" Celcius  ");
  Serial.print(tempF, 1);
  Serial.println(" Fahrenheit");

  delay(1000); // use a non-blocking delay when combined with other code
}

Thanks, that code fix did appear to stabilize it some.

Looking at the code examples for DS18B20, if I want to have multiple sensors on different data pins.
Do I need to create an object for each sensor, or can I just pass the pin number at the time of the request ?

Thanks

sid3:
Thanks, that code fix did appear to stabilize it some.

Looking at the code examples for DS18B20, if I want to have multiple sensors on different data pins.
Do I need to create an object for each sensor, or can I just pass the pin number at the time of the request ?

I forgot to say that that TMP36 sensor needs a direct connection to the Arduino.
No (ground) wires can be shared with other devices on a breadboard.

The DS18B20 is easier to use. Many can share the same Arduino (data) pin.
You need one (4k7) pull up resistor between data pin and 5volt.
Here is a test sketch for two sensors.
Leo..

#include <DallasTemperature.h>
#include <OneWire.h>

OneWire oneWire(6); // pin D6
DallasTemperature sensors(&oneWire);
float temp1, temp2;

void setup() {
  Serial.begin(115200);
  Serial.println("DS18B20 thermometer");
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  temp1 = sensors.getTempCByIndex(0); // first sensor
  temp2 = sensors.getTempCByIndex(1); // second sensor
  
  Serial.print("Temp1 is ");
  Serial.print(temp1, 1); // one decimal place
//Serial.print(temp1, 4); // four decimal places
  Serial.println(" C");
  Serial.print("Temp2 is ");
  Serial.print(temp2, 1);
  Serial.println(" C\n");
}

What I don't understand is how do you determine which device is which ?
If you have more than one device on the same bus, how do you determine which is which.
Do the devices go through some type of negotiation ??

if I placed each senor on its own data pin, then I could report its status and value ?

Thanks

Each temp sensor has a unique factory burned-in address.
The simple sketch I gave you just reads the sensors in order of address.
Fine for a few sensors.
There are also other (more complicated) ways.
Leo..

That's what I thought, I just don't want to have to plug-in-play until I get them in the right locations.

Thanks

I use small strips of colored heat shrink. 3 colors and 3 bands and you have decent set of color options.

makes your life easier when you know the order. or if you do use the ID number.

When I look online for temp and humidity sensors I see all different prices.

when you purchase, do you test for accuracy ?

I feel like I need to purchase a box of 5 or more and test them for accuracy ?
Then build my project with the ones that have test values close to the others.

Packs of five "waterproof DS18B20" sensors are about US6.00 shipped to your door on ebay.
Never had any issues with accuracy (I think they are calibrated to 0.5C).

If you want them to be exactly the same, bunch them up (same temp),
and force them to display the same temp by adding an offset value to the code.
Leo..

I was looking at the DHT22, but I have no idea how to calibrate a humidity sensor ?

sid3:
I was looking at the DHT22, but I have no idea how to calibrate a humidity sensor ?

They are factory calibrated to within a readable standard as set out in the datasheets.
There are many libraries the help you read them.
Tom.. :slight_smile: