Hallo,
beim kompilieren des Sketches erhalte ich zeitweise folgende Fehlermeldung. Manchmal auch andere, aber immer etwas mit core.a. Kompiliere ich dann nochmal funktioniert das. Flashen funktioniert auch.
C:\Portable Apps\Arduino IDE\hardware\tools\avr\bin\avr-ar: core.a: Permission denied
Binäre Sketchgröße: 17.732 Bytes (von einem Maximum von 258.048 Bytes)
Allerdings verhält sich das Programm seltsam. Am Ende von setup steht:
Serial.println("Initialization done.");
lcd.setCursor(0, 0);
lcd.print(" SD Init done ");
Das erscheint nicht nachdem Upload. Auf dem Display bleibt es bei der Anzeige davor "SD Card present". Nur nach einem weiteren Reset bzw. öffnen des seriellen Monitors erscheint "SD Init done". Die beiden Temperaturen werden jedoch immer aktualisiert wie gewollt auf dem Display.
Ist doch nicht normal.
Mega defekt?
IDE durcheinander?
Windows 7 64 Bit
Arduino IDE 1.0.5-r2
Edit: oder diese aktuelle Meldung
C:\Portable Apps\Arduino IDE\hardware\tools\avr\bin\avr-ar: unable to rename 'core.a'; reason: File exists
Binäre Sketchgröße: 23.192 Bytes (von einem Maximum von 258.048 Bytes)
Sketch
/*
Mit Hardware SPI
EA GOGM Display Beschaltung:
** LCD SI - Pin MOSI - Pin 11 on Arduino Uno und bei Mega2560 Pin 51
** LCD CLK - Pin SCK - Pin 13 on Arduino Uno und bei Mega2560 Pin 52
** LCD RS - Pin 24 Mega2560 frei gewählt
** LCD CSB - Pin 25 Mega2560 frei gewählt (CS)
CSB - Depends on your SD card shield or module.
Pin 4 used here for consistency with other Arduino examples
Exp-Tech SD Modul Beschaltung:
** MOSI - pin 11 on Arduino Uno und bei Mega2560 Pin 51 (DI)
** MISO - pin 12 on Arduino Uno und bei Mega2560 Pin 50 (DO)
** CLK - pin 13 on Arduino Uno und bei Mega2560 Pin 52 (CLK)
** CS - pin 26 frei gewählt Mega2560 (CS)
Pin 4 belegt mit Arduino WiFi/SD Shield
*/
#include <SPI.h>
#include <DogLcdSPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SD.h>
// initialize the library with the numbers of the interface pins
DogLcdSPI lcd(24, 25); // Pins für RS und CSB
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
const int chipSelect = 26;
// Dallas DS1820 Settings
OneWire ds(2); //pin für ds1820
// DeviceAdressen der einzelnen ds1820 Temperatursensoren angeben. (loop anpassen)
DeviceAddress sensor1 = { 0x10, 0x40, 0xDD, 0xC3, 0x2, 0x8, 0x0, 0xB4 };
DeviceAddress sensor2 = { 0x10, 0x8A, 0xB, 0xAC, 0x2, 0x8, 0x0, 0x2C };
char sensor1Name[] = "Garten: ";
char sensor2Name[] = "Wohnzimmer: ";
void setup(void)
{
Serial.begin(9600);
SPI.begin(); // ganz wichtig, sonst geht gar nix los, "Sketch wie tot"
lcd.begin(DOG_LCD_M163); // set up the LCD type and the contrast setting for the display
// SD Card Test, Initializing:
Serial.print("\nInitializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(53, OUTPUT); // change this to 53 on a mega
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
lcd.setCursor(1, 0);
lcd.print("SD Init failed");
Serial.println("initialization failed. Things to check:");
Serial.println("* is a card is inserted?");
Serial.println("* Is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
lcd.setCursor(0, 0);
lcd.print("SD Card present");
Serial.println("Wiring is correct and a card is present.");
}
// print the type of card
Serial.print("\nCard type: ");
switch(card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
root.openRoot(volume);
// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);
Serial.println("Initialization done.");
lcd.setCursor(0, 0);
lcd.print(" SD Init done ");
} // Ende setup
void loop(void)
{
float temp1 = getTemperature(sensor1);
float temp2 = getTemperature(sensor2);
lcd.setCursor(1, 1);
lcd.print(temp1,1);
lcd.setCursor(1, 2);
lcd.print(temp2,1);
delay(1000);
/*
Serial.print(sensor1Name);
Serial.print(temp1);
Serial.println(" Celsius");
Serial.print(sensor2Name);
Serial.print(temp2);
Serial.println(" Celsius");
Serial.println();
delay(1000);
*/
} // Ende loop
// *** Funktionen für DS1820 ***
void writeTimeToScratchpad(byte* address)
{
ds.reset(); // reset the bus
ds.select(address); // select our sensor
ds.write(0x44,1); // CONVERT T function call (44h) which puts the temperature into the scratchpad
delay(1000); // sleep a second for the write to take place
}
void readTimeFromScratchpad(byte* address, byte* data)
{
ds.reset(); // reset the bus
ds.select(address); // select our sensor
ds.write(0xBE); // read the scratchpad (BEh)
for (byte i=0;i<9;i++)
{
data[i] = ds.read();
}
}
float getTemperature(byte* address)
{
int tr;
byte data[12];
writeTimeToScratchpad(address);
readTimeFromScratchpad(address,data);
tr = data[0]; // put in temp all the 8 bits of LSB (least significant byte)
if (data[1] > 0x80) // check for negative temperature
{
tr = !tr + 1; // two's complement adjustment
tr = tr * -1; // flip value negative.
}
int cpc = data[7]; // COUNT PER Celsius degree (10h)
int cr = data[6]; // COUNT REMAIN (0Ch)
tr = tr >> 1; // drop bit 0
return tr - (float)0.25 + (cpc - cr)/(float)cpc;
}