Arduino Projects DISCUSSION

ds18b20 temperature sensor and arduino

Started by syedzainnasir ds18b20 temperature sensor and arduino
1 replies 248 views 2 participants
Latest activity · 20 Feb 2017

ds18b20 temperature sensor and arduino

syedzainnasir Arduino Projects Forum
#1
I am currently writing this simple code to check the temp sensor
[code]#include <One Wire . h> int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2 void setup(void) { Serial.begin(9600); } void loop(void) { float temperature = getTemp(); Serial.println(temperature); delay(100); //just here to slow down the output so it is easier to read }[/code] I m getting "sketch_feb27a:14: error: 'getTemp' was not declared in this scope"
can someone tell me why?

Community replies 1

Re: ds18b20 temperature sensor and arduino

#2
[quote=Patricia post_id=121 time=1487601587 user_id=75] I am currently writing this simple code to check the temp sensor
[code]#include <One Wire . h> int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 //Temperature chip i/o OneWire ds(DS18S20_Pin); // on digital pin 2 void setup(void) { Serial.begin(9600); } void loop(void) { float temperature = getTemp(); Serial.println(temperature); delay(100); //just here to slow down the output so it is easier to read }[/code] I m getting "sketch_feb27a:14: error: 'getTemp' was not declared in this scope"
can someone tell me why? [/quote]
Either you have not extracted the OneWire library to the correct location, or have made a mistake in the #include line. Include it without spaces

*include<OneWire.h>
If getTemp() is not a part of the library OneWire then obviously you have to make your own getTemp() function

Recommend Tutorial:
[url=http://www.theengineeringprojects.com/2015/02/interfacing-temperature-sensor-18b20-arduino.html]TEMPERATURE SENSOR 18B20 WITH ARDUINO[/url]
TEP COMMUNITY