help using ds18b20 with moteino?

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

void setup(void) {
 Serial.begin(9600);
}


double Thermister(int RawADC) {
 double Temp;
 Temp = log(((10240000/RawADC) - 50000));
 Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
 Temp = Temp - 273.15;           // Convert Kelvin to Celcius
 return Temp;
}

void printTemp(void) {
 double fTemp;
 double temp = Thermister(analogRead(0));  // Read sensor
 Serial.print("Temperature is:");
 Serial.print(temp);
 Serial.print(" C / ");
Temp = (temp * 1.8) + 32.0;    // Convert to USA
 Serial.print(fTemp);
 Serial.println(" F");
}

void loop(void) {
 printTemp();
 delay(1000);
}

Hi all,
When I upload this code, it reads me random temperatures. I am using a Moteino rather than an Arduino, so I haven't yet found information about how to set up the breadboard. I was wondering if anyone could help me with either of these things? thank you so much!

Isn't the ds18b20 a digital device?

It is, but I'm not yet aware of how this a problem and how to change my code to account for/fix this? Thanks!

I'm not yet aware of how this a problem

Well, your code appears to do an analogRead, but doesn't appear to perform a one-wire read.

How would I fix this? (I'm sorry if I'm inconveniencing or frustrating you; I'm just learning.)

Aren't there any example code with the DallasTemperature library?
If not, I'm sure Mr Google could find some.

Hi,

I am in the process of connecting a Moteino (similar to an Arduino Uno) to a DS18B20. My operating system is a Mac.

I can upload my code without problem, but no temperatures are displayed. Since I have very little experience with Arduino and am still learning, I was wondering if anyone was available to check out my code and circuit, and give me tips.

I've been researching for weeks since Moteinos are not very commonly paired with DS18B20s, but nothing seems to work. So, any help would be very greatly appreciated!
Thank you so much!

temp_7.ino (928 Bytes)

I have never heard of a Moteino but if you can load other Uno programmes into it, you should be OK with one for a DS18b20. If it is 3.3v that should be OK as the sensor can run on 3v.

You might get better advice here

Please post your code in the proper manner using the </> tags

Looking at the Moteino pinout it seems like you should not be using pin2

...R

That is where I see a lot of people having problems with a Moteino. They neglect to read the chart on the right that shows a rundown of all the pins.