# Konflikt zweier Bibliotheken

**URL:** <https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764>\
**Category:** Deutsch\
**Created:** [October 24, 2023, 3:27pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764 "2023-10-24T15:27:39Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![HotSystems](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hotsystems/32/219785_2.png) [@HotSystems](https://forum.arduino.cc/u/HotSystems)\
**Post date:** [October 24, 2023, 5:35pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/22 "2023-10-24T17:35:55Z")

</div>

Ok, dann bleibt aus meiner Sicht nur die Verwendung der Hardware Serial, wie schon geschrieben. Da gibt es in der Library auch ein Beispiel.

---

<div class="post-metadata">

**Author:** ![sucher13](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sucher13](https://forum.arduino.cc/u/sucher13)\
**Post date:** [October 24, 2023, 5:37pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/23 "2023-10-24T17:37:16Z")

</div>

Was meinst Du mit  
"Verwendung der Hardware Serial"?

---

<div class="post-metadata">

**Author:** ![HotSystems](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hotsystems/32/219785_2.png) [@HotSystems](https://forum.arduino.cc/u/HotSystems)\
**Post date:** [October 24, 2023, 5:42pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/24 "2023-10-24T17:42:05Z")

</div>

Hardware Serial ist ein Schnittstelle die schon in der Hardware fest integriert ist.  
Das ist eine eigene Steuerung die in der Regel immer funktioniert.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 5:45pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/25 "2023-10-24T17:45:09Z")

</div>

Ich habe was

```arduino
Der Sketch verwendet 17162 Bytes (53%) des Programmspeicherplatzes. Das Maximum sind 32256 Bytes.
Globale Variablen verwenden 1530 Bytes (74%) des dynamischen Speichers, 518 Bytes für lokale Variablen verbleiben. Das Maximum sind 2048 Bytes.

```

Dabei habe nur die SD eingebunden, ohne Schreiben usw.  
@sucher13 teste mall ob deine daten vom Sensor werden angezeigt

```arduino
 
#include <SPI.h>
#include <SD.h>
const int chipSelect = 10;

#include "SdsDustSensor.h"
int rxPin = 1;
int txPin = 2;
SdsDustSensor sds(rxPin, txPin);

int interval = 5; //Log to SD Card every 5 seconds
long timer;
String SensorDaten_1, SensorDaten_2;

void setup() {
  Serial.begin(9600);
  Serial.println("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("SD Card error");
    return;
  }
  Serial.println("card initialized");

  sds.begin();

  Serial.println(sds.queryFirmwareVersion().toString()); // prints firmware version
  Serial.println(sds.setActiveReportingMode().toString()); // ensures sensor is in 'active' reporting mode
  Serial.println(sds.setContinuousWorkingPeriod().toString()); // ensures sensor has continuous working period - default but not recommended
}

void loop() {
  PmResult pm = sds.readPm();
  if (pm.isOk()) {
    Serial.print("PM2.5 = ");
    Serial.print(pm.pm25);
    Serial.print(", PM10 = ");
    Serial.println(pm.pm10);

    // if you want to just print the measured values, you can use toString() method as well
    Serial.println(pm.toString());
  } else {
    // notice that loop delay is set to 0.5s and some reads are not available
    Serial.print("Could not read values from sensor, reason: ");
    Serial.println(pm.statusToString());
  }

  delay(500);
}
```

---

<div class="post-metadata">

**Author:** ![HotSystems](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hotsystems/32/219785_2.png) [@HotSystems](https://forum.arduino.cc/u/HotSystems)\
**Post date:** [October 24, 2023, 5:46pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/26 "2023-10-24T17:46:55Z")

</div>

Pin D1 geht aber nicht für den Sensor.

---

<div class="post-metadata">

**Author:** ![sucher13](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sucher13](https://forum.arduino.cc/u/sucher13)\
**Post date:** [October 24, 2023, 5:52pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/27 "2023-10-24T17:52:24Z")

</div>

0 und 1 benötige ich zur Programmübertragung.

mit 2 und 3: keine Antwort der seriellen Schnittstelle - keine Anzeige am Bildschirm

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 5:55pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/28 "2023-10-24T17:55:11Z")

</div>

Danke.  
Sehe jetzt soll eben 3 nehmen 😉  
Habe die Lib durchgeguckt auf die Schnelle , normal habe nichts verdächtiges gefunden kein IRQ nix

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 5:59pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/29 "2023-10-24T17:59:07Z")

</div>

Habe Fehler gehabt doppeltgemoppelt  
lösche mall die erste

```arduino
#include "SdsDustSensor.h"

```

habe nicht Dein Sensor 🙄

---

<div class="post-metadata">

**Author:** ![HotSystems](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hotsystems/32/219785_2.png) [@HotSystems](https://forum.arduino.cc/u/HotSystems)\
**Post date:** [October 24, 2023, 6:00pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/30 "2023-10-24T18:00:49Z")

</div>

Du weißt schon, dass der Fehler erst im Betrieb auftritt.

---

<div class="post-metadata">

**Author:** ![sucher13](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sucher13](https://forum.arduino.cc/u/sucher13)\
**Post date:** [October 24, 2023, 6:01pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/31 "2023-10-24T18:01:51Z")

</div>

Der Fehler tritt mit und ohne Sensor auf. Und er ist mit und ohne Sensor weg, sobald immer nur eine Bibliothek eingebunden ist. Ich such mal nach einer Lösung ohne die SdsDust.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:02pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/32 "2023-10-24T18:02:38Z")

</div>

Ja nur öfters ist das Problem wann was angesprochen wird gerade bei der SD.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:04pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/33 "2023-10-24T18:04:52Z")

</div>

Das blöde ist für den Sensor gibt es nur eine Lib.  
Was für SD Lib nutzt du?

---

<div class="post-metadata">

**Author:** ![sucher13](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sucher13](https://forum.arduino.cc/u/sucher13)\
**Post date:** [October 24, 2023, 6:06pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/34 "2023-10-24T18:06:29Z")

</div>

```arduino
#include <SPI.h>
#include <SD.h>

```

---

<div class="post-metadata">

**Author:** ![sucher13](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@sucher13](https://forum.arduino.cc/u/sucher13)\
**Post date:** [October 24, 2023, 6:09pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/35 "2023-10-24T18:09:21Z")

</div>

Ich habe jetzt eine Variante, die mir Daten ausliest, aber nun muss ich prüfen, ob diese die richtigen sind...

```arduino
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>

SoftwareSerial sdsSerial(2, 3); // RX, TX

const int chipSelect = 10; //10 is default by shield, but normally on Pin 4
int interval = 5; //Log to SD Card every 5 seconds

long timer;
String SensorDaten_1, SensorDaten_2;

void setup() {
  Serial.begin(9600);
  sdsSerial.begin(9600); // SDS011 kommuniziert normalerweise mit 9600 Baud
  delay(3000);
  Serial.println("Initializing SD card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("SD Card error");
    return;
  }
  Serial.println("card initialized");
  
}
// ************************************************L O O P*********************
void loop() {
  if ((timer + interval * 1000) < millis()) {
    timer = millis();
    DatenAuslesen(); //Get your value
    DatenSichern(); //Write value to SD
  }
}
// *******************************************************************************

void DatenAuslesen(){
   if (sdsSerial.available() >= 10) { // Warten, bis genügend Daten verfügbar sind
    if (sdsSerial.read() == 0xAA && sdsSerial.read() == 0xC0) { // Prüfen Sie das Header-Byte
      uint8_t data[8];
      for (int i = 0; i < 8; i++) {
        data[i] = sdsSerial.read();
      }
      
      uint16_t pm25 = (data[1] << 8) | data[0]; // PM2.5 in µg/m³
      uint16_t pm10 = (data[3] << 8) | data[2]; // PM10 in µg/m³
      SensorDaten_1 = pm25;
      SensorDaten_2 = pm10; 
      Serial.print("PM2.5: ");
      Serial.print(pm25);
      Serial.print(" µg/m³\t");
      Serial.print("PM10: ");
      Serial.print(pm10);
      Serial.println(" µg/m³");
    }
  }

}

void DatenSichern() { //Write to SD card
  String AusgabeZeile = SensorDaten_1 + ";" + SensorDaten_2;
  File dataFile = SD.open("datalog.csv", FILE_WRITE);
  if (dataFile) {
    dataFile.println(AusgabeZeile);
    dataFile.close();
    Serial.println(AusgabeZeile);
  }
  else {
    Serial.println("error writing datalog.csv");
  }
}

```

Jedenfalls kann ich nun Daten auslesen, und schreiben. Mein Problem ist, dass ich den Code noch nicht so richtig verstehe, aber vielleicht, wenn ich ausgeschlafen bin.

Bisher jedenfalls vielen Dank für die schnelle Unterstützung.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:10pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/36 "2023-10-24T18:10:55Z")

</div>

Installiere mall die, ist ein wenig anders aufgebaut, hat schon mall mit der Standard SD Probleme, wollte nicht mit ESP.

> **[GitHub - greiman/SdFat: Arduino FAT16/FAT32 exFAT Library](https://github.com/greiman/SdFat)**
>
> Arduino FAT16/FAT32 exFAT Library. Contribute to greiman/SdFat development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:15pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/37 "2023-10-24T18:15:12Z")

</div>

Also ohne

```arduino
sds.begin();

```

sehe das Schwarz

---

<div class="post-metadata">

**Author:** ![Tommy56](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tommy56/32/232943_2.png) [@Tommy56](https://forum.arduino.cc/u/Tommy56)\
**Post date:** [October 24, 2023, 6:15pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/38 "2023-10-24T18:15:13Z")

</div>

Sowohl der ESP8266, als auch der ESP32 haben eigene SD-Libs im Core. Die sollte man auch benutzen. Beide basieren auf der SdFet.

Gruß Tommy

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:17pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/39 "2023-10-24T18:17:36Z")

</div>

Wais ich, leider hat bei mir nicht funktioniert, ist aber kein Problem habe andere Gefunden und seit dem funktioniert 1A

---

<div class="post-metadata">

**Author:** ![HotSystems](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/hotsystems/32/219785_2.png) [@HotSystems](https://forum.arduino.cc/u/HotSystems)\
**Post date:** [October 24, 2023, 6:21pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/40 "2023-10-24T18:21:21Z")

</div>

Hallo,  
wieso denn ESP8266 bzw. ESP32 ?  
Hier wird der Uno genutzt.

---

<div class="post-metadata">

**Author:** ![fony](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/fony/32/936882_2.png) [@fony](https://forum.arduino.cc/u/fony)\
**Post date:** [October 24, 2023, 6:23pm UTC](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764/41 "2023-10-24T18:23:28Z")

</div>

Die gezeigte SdFat ist doch auch für UNO,

[Previous page](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764.md?page=1)

[Next page](https://forum.arduino.cc/t/konflikt-zweier-bibliotheken/1181764.md?page=3)
