Ovdje pročitajte kako se registrirati na forum.

SD card na Croduino

Tehnička podrška za sve module i aktuatore iz ponude e-radionica.com
Odgovorite
advancedgwt#5598
Ozbiljni hardveraš
Ozbiljni hardveraš
Postovi: 115
Pridružen/a: pon lip 11, 2018 12:42 pm

SD card na Croduino

Post Postao/la advancedgwt#5598 » čet srp 12, 2018 7:29 pm

Zdravo Davide,
Video sam vas post na YouTube kanalu o SPI vezi i DHT11, da ne bih prepisivao sa ekrana nasao sam ovaj kod i Arduino IDE ga je dobro uplodovao na Croduino Basic2

Medjutim, SD kartica nece da se inicijalizuje, proverio sam i MISO i ostale (prema uputstvu sa vaseg YouTube kanala) i mislim da sam sve dobro prikacio.

Svaka sugestija je dobrodosla

Pozdrav,
Dragan

Kod: Označite sve

// Arduino data logger with SD card and DHT11 humidity and temperature sensor
 
#include <SPI.h>        // Include SPI library (needed for the SD card)
#include <SD.h>         // Include SD library
#include <DHT.h>        // Include DHT sensor library
 
File dataFile;
 
#define DHTPIN 4            // DHT11 data pin is connected to Arduino pin 4
#define DHTTYPE DHT11       // DHT11 sensor is used
DHT dht(DHTPIN, DHTTYPE);   // Initialize DHT library
 
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial)
    ; // wait for serial port to connect. Needed for native USB port only
  Serial.print("Initializing SD card...");
  if (!SD.begin()) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");
  delay(2000);
}
 
uint16_t line = 1;
 
void loop() {
  delay(1000);
  // Read humidity
  byte RH = dht.readHumidity();
  //Read temperature in degree Celsius
  byte Temp = dht.readTemperature();
  
  dataFile = SD.open("DHT11Log.txt", FILE_WRITE);
  
  // if the file opened okay, write to it:
  if (dataFile) {
    Serial.print(line);
    Serial.print(":    Temperature = ");
    Serial.print(Temp);
    Serial.print("°C,    Humidity = ");
    Serial.print(RH);
    Serial.println("%");
    // Write data to SD card file (DHT11Log.txt)
    dataFile.print(line++);
    dataFile.print(":    Temperature = ");
    dataFile.print(Temp);
    dataFile.print("°C,    Humidity = ");
    dataFile.print(RH);
    dataFile.println("%");
    dataFile.close();
    
  }
  // if the file didn't open, print an error:
  else
    Serial.println("error opening DHT11Log.txt");
}
Avatar
david.zovko#7069
e-radionica.com team
e-radionica.com team
Postovi: 264
Pridružen/a: ned tra 15, 2018 2:59 pm
Lokacija: Osijek, Croatia
Kontakt:

Re: SD card na Croduino

Post Postao/la david.zovko#7069 » pon srp 16, 2018 9:11 am

Pozdrav

dobra ideja bi bila staviti linkove za download koda u opis youtube videa, definitivno se slažem...

Jel može, molim te, jedna slika gdje se vide konekcije između SD kartice i Croduina?
advancedgwt#5598
Ozbiljni hardveraš
Ozbiljni hardveraš
Postovi: 115
Pridružen/a: pon lip 11, 2018 12:42 pm

Re: SD card na Croduino

Post Postao/la advancedgwt#5598 » pon srp 16, 2018 10:08 pm

Igleda je tu bio problem, SD kartica se inicijalizovala.

Sada se pojavio problem sto text fajl nece da se otvori
Avatar
david.zovko#7069
e-radionica.com team
e-radionica.com team
Postovi: 264
Pridružen/a: ned tra 15, 2018 2:59 pm
Lokacija: Osijek, Croatia
Kontakt:

Re: SD card na Croduino

Post Postao/la david.zovko#7069 » uto srp 17, 2018 1:13 pm

Morate formatirati SD karticu na FAT16 ili FAT32 filesystem. Evo ovdje par tipova: https://www.arduino.cc/en/Reference/SDCardNotes
advancedgwt#5598
Ozbiljni hardveraš
Ozbiljni hardveraš
Postovi: 115
Pridružen/a: pon lip 11, 2018 12:42 pm

Re: SD card na Croduino

Post Postao/la advancedgwt#5598 » pon srp 23, 2018 4:22 pm

Hvala puno
Odgovorite