• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Zapis danych z czujników na karcie SD
#1
Witajcie męczę się kilka dni już z zapisem danych z czujnika DS18B20 na karcie sd i dostaję informacje przy kompilacji że zmienna "float" nie może zostać zapisana po zmianie na int zapisuje ale pokazuje w cały świat. Oto fragment kodu:
Kod:
#include <SPI.h>
#include <SD.h>
#include <OneWire.h>
#include <DS18B20.h>
#include <iostream>
#include <stdio.h>

const int chipSelect = 10;
#define ONEWIRE_PIN 2
byte address[8] = {0x28, 0x1, 0x4F, 0x2C, 0x6, 0x0, 0x0, 0x1C};
OneWire onewire(ONEWIRE_PIN);
DS18B20 sensors(&onewire);

void setup() {

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial)

sensors.begin();
sensors.request(address);
{
 
}

Serial.print("Initializing SD card...");

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
  Serial.println("Card failed, or not present");
  // don't do anything more:
  return;
}
Serial.println("card initialized.");
}

void loop() {
delay(2000);
if (sensors.available())
{
  float temperature = sensors.readTemperature(address);
  sensors.request(address);
}

File dataFile = SD.open("datalog.txt", FILE_WRITE);

// if the file is available, write to it:
if (dataFile) {
  dataFile.println(address);
  dataFile.close();
  // print to the serial port too:
  Serial.println(address);
  Serial.println();
}
// if the file isn't open, pop up an error:
else {
  Serial.println("error opening datalog.txt");
}


}


serdeczne dzięki za pomoc
 
Odpowiedź
  


Wiadomości w tym wątku
Zapis danych z czujników na karcie SD - przez photohubercik - 02-08-2015, 18:06

Skocz do:


Przeglądający: 1 gości