I want my SD card to read, write and save two temperatures from DS18B20's.
I was able to have the serial monitor print the two temperatures and have them labelled like i like.
Taking things one step (Component) at a time I am really struggling with the code for the SD module.
I have run the SD library example for my cards info and it is FAT32 bit and connected correctly.
Here is the Code
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
//one_wire sensor address finder
DeviceAddress insideTemperature = { 0x28, 0x19, 0x5C, 0x3A, 0x22, 0x20, 0x01, 0x70};
DeviceAddress outsideTemperature = { 0x28, 0x27, 0xDD, 0x22, 0x22, 0x20, 0x01, 0xAC };
//Change this to match your SD shield or Module
const int ChipSelect =4;
//Name File
char filename[] = "Test.CSV";
//Create a file to store data
File myFile;
void setup(void){
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideTemperature, 10);
sensors.setResolution(outsideTemperature, 10);
delay(500);//Wait for newly restarted system to stabalize
//make sure that the default chip select pin is set to
//output, even if you dont use it:
//pinMode(53, OUTPUT); // MEGA
pinMode (10,OUTPUT); //UNO
Serial.print("Initializing SD card...");
if (!SD.begin(10))
{
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
void loop(){
delay(2000);
Serial.print("Getting temperatures...\n\r");
sensors.requestTemperatures(); // Call readings from the addresses
Serial.print("Inside temperature is: ");
printTemperature(insideTemperature);
Serial.print("\n\r");
Serial.print("Outside temperature is: ");
printTemperature(outsideTemperature);
Serial.print("\n\r");
myFile = SD.open(filename, FILE_WRITE);//<<<<<<<<<<<<< OPEN
myFile.print(insideTemperature);
myFile.print(",");
myFile.println(outsideTemperature);
myFile.close();//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>CLOSE
}
//sensorValue function
float sensorValue (byte deviceAddress[])
{
tempC = sensors.getTempC (deviceAddress);
return tempC;
}
error message :
C:\Users\jorda\Documents\Arduino\arduino_ds18b20_temperature_sensor\arduino_ds18b20_temperature_sensor.ino:103:3: note: suggested alternative: 'memcpy'
tempC = sensors.getTempC (deviceAddress);
^~~~~
memcpy
exit status 1
no matching function for call to 'print(DeviceAddress)'
any suggestions will be put to the test ![]()
also any tips for searching these kinds of error messages would be appreciated.
Thanks !!!

