Problem writing CSV data from muiti Dallas Temp Sensors to Adafruit SD shield

I started this project a couple months ago. Last week was the first time I was able to save temperature data to the SD.

The issue is how to handle:

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress); --Line 187

As near as I can tell, that line prints sensor # 0,1,2,3 to serial monitor but dosen’t work with:

LOGFILE(void printTemperature(DeviceAddress deviceAddress) example error messages are
on lines 222 - 227

I tried cleaning up the code, but too often I’d get errors on compile.
The program executes and prints data to serial monitor, and all but the sensor {device} ID on the SD card.

Output to serial monitor…
.Header Info….
Dallas Temperature IC Control Library Demo
Locating devices…Found 4 devices.
Parasite power is: ON
Found device 0 with address: //this was printing the HEX addr…I can fix tha I suspect “{” pair issue//

Resolution is set to: 9 Device - Time then - Temp in F
Found device 3 with address:
Setting resolution to 9
Resolution is set to: 9 Device - Time then - Temp in F
Initializing SD card…card initialized.
Logging to: LOGGER43.CSV

Data output is what I want
Sen #,F ,time-sec,yr/mo/da
0,erh,66.207,2017/12/2
1,erh,68.908,2017/12/2
2,erh,68.009,2017/12/2
3,erh,68.0010,2017/12/2

Out put to SD card
Data is actually: Temp-F, Temp-C, Time-sec , Date
All is good, except this in output from 4 sensors

Temp-F Time - ms YR/MO/DA
LOGGER43.CSV
66.2 19 8 2017/12/2
68.9 20.5 9 2017/12/2
68 20 10 2017/12/2
68 20 11 2017/12/2
66.2 19 18 2017/12/2
68.9 20.5 19 2017/12/2

data_log00_15a.ino (7.42 KB)

//logfile.print(deviceAddress);

deviceAddress corresponds with the definition typedef uint8_t DeviceAddress[8]; in the Dallas header file. To print it out you would need to use a for loop to print out each byte of the array separately (probably best in hex).

 //logfile.print(float tempC = sensors.getTempC(deviceAddress));

Remove the float tempC = bit.

I think you will get a better start here
http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
The datalogging example in the SD section of the IDE should be all you need.

I've been on Hacker before...excellent site.

There example does not offer anything about writing Dallas data to SD.

thanx for the suggestion.
ed

It's not any different from writing any other data to an SD. Quit looking for an example that writes specifically data from that particular sensor to an SD. You've made things too specific. Study up how to get the data from the sensor into a variable and how to write data to an SD. Separate the two a little and you'll get it.

Delta, I agree with what you're saying.

the code that works for serial, but not SD is:

LOGFILE(void printTemperature(DeviceAddress deviceAddress) example error messages are
on lines 222 - 227

As I noted I tried several variations of the above, all with resulting errors.

Writing the Temp, time, date to SD is not the issue.

I also need the sensor #, as near as I can tell

void printTemperature(DeviceAddress deviceAddress);

prints to the serial.

Any other thoughts?
ed

So go look at the printTemperature function and see how it does that. Or make a copy of it and change all the lines that print to serial monitor to go instead to the SD. But just jamming the function prototype between two parenthesis and hoping isn't going to work.

I think you would get a LOT of good out of a basic tutorial on C++. Spend a day on that and watch how much clearer this all gets once you understand how to read the code you have and don't have to guess anymore.

edpe77:
There example does not offer anything about writing Dallas data to SD.
/quote]

edpe77:
Writing the Temp, time, date to SD is not the issue.