Hello everyone, this is my first post on this forum so I would like to say sorry for some mistakes and thanks for the help. I`m usin Arduino Mega and Arduino 1.0 with new 1-wire library.
I wrote program which write the mensurment from one wire sensor to the sd card at .csv file. But I have some problem when I verify it
some problem occures,
m_arduino_ds18b20_10sensors_datalog_rev1.cpp: In function 'void loop()':
m_arduino_ds18b20_10sensors_datalog_rev1:231: error: call of overloaded 'String(uint8_t [8])' is ambiguous
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:70: note: candidates are: String::String(long unsigned int, unsigned char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:69: note: String::String(long int, unsigned char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:68: note: String::String(unsigned int, unsigned char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:67: note: String::String(int, unsigned char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:66: note: String::String(unsigned char, unsigned char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:65: note: String::String(char)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:60: note: String::String(const String&)
C:\Documents and Settings\f\Pulpit\ARDUINO\arduino-1.0\hardware\arduino\cores\arduino/WString.h:59: note: String::String(const char*)
m_arduino_ds18b20_10sensors_datalog_rev1:234: error: expected ',' or ';' before 'File'
m_arduino_ds18b20_10sensors_datalog_rev1:235: error: 'logFile' was not declared in this scope
I know that the line
String dataString = String(temp1) //save on sd for example temperatur from first onewire sensor
is wrong. Probably I should convert the temp1 variable to something else but how?
And this is my program listning:
//***********************************************************************************************
// Read from 10 onewire sensor and write to sd card
//***********************************************************************************************#include <OneWire.h>
#include <DallasTemperature.h>
#include <SD.h>//Pn legend for Arduino MEGA
//MOSI = Pin 51<<<<< WAZNE
//MISO = Pin 50<<<<< AHTUNG
//SCLK = PIN 52<<<<< WARNINGint CS_pin = 53;
int pow_pin = 22; // 53 moze dla mega dla 9 duemilanove#define ONE_WIRE_BUS 30 //// !!!!!!!!!!!!!!!!!!!!!! TRZEBA ZMIENIC
#define ledZasilanie 40 //// dioda zasilania
#define ledTryb 42 //// dioda trybu jesli ledTryb = 1 to rozpoznawanie 1w jesli
//// ledTryb = 0 to pomiar temp z czujnikow// ustawienie oneWire do komunikacji z jakimkolwiek urz?dzeniem OW
OneWire oneWire(ONE_WIRE_BUS);// przekazanie naszej referencji oneWire do czujników
DallasTemperature sensors(&oneWire);// address onewire sensor
DeviceAddress temp1 = { 0x28, 0x06, 0xE2, 0x86, 0x03, 0x00, 0x00, 0xC1 }; //0
DeviceAddress temp2 = { 0x28, 0x31, 0xE4, 0x86, 0x03, 0x00, 0x00, 0x35 }; //1
DeviceAddress temp3 = { 0x28, 0xE3, 0x84, 0x86, 0x03, 0x00, 0x00, 0x8E }; //2
DeviceAddress temp4 = { 0x28, 0x57, 0xFE, 0x86, 0x03, 0x00, 0x00, 0x85 }; //3
DeviceAddress temp5 = { 0x28, 0x3B, 0x04, 0x87, 0x03, 0x00, 0x00, 0xAF }; //4
DeviceAddress temp6 = { 0x28, 0xFF, 0xFC, 0x86, 0x03, 0x00, 0x00, 0xFB }; //5
DeviceAddress temp7 = { 0x28, 0x77, 0x25, 0x87, 0x03, 0x00, 0x00, 0x92 }; //6
DeviceAddress temp8 = { 0x28, 0xD6, 0x6D, 0x86, 0x03, 0x00, 0x00, 0xA1 }; //7
DeviceAddress temp9 = { 0x28, 0x1C, 0x77, 0x86, 0x03, 0x00, 0x00, 0x30 }; //8
DeviceAddress temp10 = { 0x28, 0x52, 0xF1, 0x86, 0x03, 0x00, 0x00, 0x01 }; //9int nrPomiaru = 0;
//***********************************************************************************************
void setup(void)
{
pinMode(22, OUTPUT);
pinMode(24, INPUT);
Serial.begin(9600);
Serial.println("Initializing Card");
//CS Pin is an output
pinMode(CS_pin, OUTPUT);//SD Card will Draw Power from Pin 8, so set it high
pinMode(pow_pin, OUTPUT);
digitalWrite(pow_pin, HIGH);//Initialize Card
if (!SD.begin(CS_pin))
{
Serial.println("Card Failure");
return;
}
Serial.println("Card Ready");//Write Log File Header
File logFile = SD.open("LOG.csv", FILE_WRITE);
if (logFile)
{
logFile.println(", , , ,"); //Just a leading blank line, incase there was previous data
String header = "Nrpomiaru, Czujnik1, Czujnik2, Czujnik3, Czujnik4, Czujnik5, Czujnik6, Czujnik7, Czujnik8, Czujnik9, Czujnik10";
logFile.println(header);
logFile.close();
Serial.println(header);
}
else
{
Serial.println("Couldn't open log file");
}// w??czenie biblioteki
sensors.begin();// set resolution to 12bit
sensors.setResolution(temp1, 12);
sensors.setResolution(temp2, 12);
sensors.setResolution(temp3, 12);
sensors.setResolution(temp4, 12);
sensors.setResolution(temp5, 12);
sensors.setResolution(temp6, 12);
sensors.setResolution(temp7, 12);
sensors.setResolution(temp8, 12);
sensors.setResolution(temp9, 12);
sensors.setResolution(temp10, 12);}
//***********************************************************************************************
//not use (futuer use)
void discoverOneWireDevices(void)
{
byte i;
byte present = 0;
byte data[12];
byte addr[8];Serial.print("Looking for 1-Wire devices...\n\r");
while(oneWire.search(addr))
{
Serial.print("\n\rFound '1-Wire' device with address:\n\r");
digitalWrite(22, HIGH);
for( i = 0; i < 8; i++)
{
Serial.print("0x");
if (addr < 16)
- {*
- Serial.print('0');*
- }*
_ Serial.print(addr*, HEX);_
_ if (i < 7) {_
_ Serial.print(", ");_
_ }_
_ }_
_ if ( OneWire::crc8( addr, 7) != addr[7])_
_ {_
_ Serial.print("CRC is not valid!\n");_
_ return;_
_ }_
_ }_
_ Serial.print("\n\r\n\rThat's it.\r\n");_
oneWire.reset_search();
_ return;_
_}_
//***********************************************************************************************
void printTemperature(DeviceAddress deviceAddress)
_{_
_ float tempC = sensors.getTempC(deviceAddress);_
_ if (tempC == -127.00)_
_ {_
_ Serial.print("n/a"); // n/a = nie znaleziono czujnika*_
* }*
* else*
* {*
* //Serial.print("C: ");*
* Serial.print(tempC);*
* // Konwersja na stopnie farrenhaita*
* //Serial.print(" F: ");*
* //Serial.print(DallasTemperature::toFahrenheit(tempC));*
* }*
}
//***********************************************************************************************
void loop(void)
{//collect the data from the sensor
* sensors.requestTemperatures();** nrPomiaru++; //counting how many times data were collected*
* Serial.print(";");*
// Serial.print("Czujnik 1: ");
* printTemperature(temp1);*
* //Serial.print("\n\r");*
* Serial.print(";");*
// Serial.print("Czujnik 2: ");
* printTemperature(temp2);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 3: ");
* printTemperature(temp3);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 4: ");
* printTemperature(temp4);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 5: ");
* printTemperature(temp5);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 6: ");
* printTemperature(temp6);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 7: ");
* printTemperature(temp7);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 8: ");
* printTemperature(temp8);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 9: ");
* printTemperature(temp9);*
// Serial.print("\n\r");
* Serial.print(";");*// Serial.print("Czujnik 10: ");
* printTemperature(temp10);*
// Serial.print("\n\r");
* Serial.print(";");** Serial.print("\n\r");*
* //Create Data string for storing to SD card*
* //We will use CSV Format ** String dataString = String(temp1) //save on sd for example temperatur from first onewire sensor*
* //Open a file to write to*
* //Only one file can be open at a time*
* File logFile = SD.open("LOG.csv", FILE_WRITE);
_ if (logFile)_
_ {_
_ logFile.println(dataString);_
_ logFile.close();_
_ Serial.println(dataString);_
_ }_
_ else*_
* {*
* Serial.println("Couldn't open log file");*
* }** delay(5000);*
}[/quote]
[/size][/size][/size][/size][/size][/size]