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 ?
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..
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..
// 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);
}
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 ?
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 ?
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..
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..