Hallo zusammen das bin ich wieder, leider schneller als gehofft.
Ich hab mir die Teile besorgt und versucht meinen Code darauf laufen zu lassen.
Ich habe einen Wemos D1 mini pro und ein SD-Shield mit RTC.
Ich hab die LCD im Code mal ausgeklammert, aber auch ohne der LCD bekomme ich auf dem Serial Monitor nicht das was ich sehen möchte.
Die SD - Karte wird zwar erkannt, aber es wird darauf nichts geschrieben.
Im Serial wird folgendes angezeigt.
<
Initializing SD card...card in⸮
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld
Nehme ich die SD heraus dann steht im Serial
<
Initializing SD card...Card failed, or not present
Soft WDT reset
ctx: cont
sp: 3ffffd90 end: 3fffffd0 offset: 01b0
stack>>>
3fffff40: 3fffdad0 0000001b 3ffeeca0 40205580
3fffff50: 3fffdad0 3ffee884 3ffeeca0 402056c9
3fffff60: 3ffe8a50 003d0900 3ffeeb24 402056c9
3fffff70: 3ffe898c 00000001 3ffeeca0 402056f4
3fffff80: 3fffdad0 3ffee884 3ffeeca0 40205718
3fffff90: feefeffe 3ffee884 3ffeeca0 40202c64
3fffffa0: feefeffe feefeffe feefeffe feefeffe
3fffffb0: feefeffe 00000000 3ffeecd4 40205d44
3fffffc0: feefeffe feefeffe 3ffe85f0 40100739
<<<stack<<<
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld
Ich glaube das mein Code so nicht kompatibel ist und ich wieder von neuem beginnen muss?
Kann mir jemand sagen:
Kann ich meinen Code verwenden?
Wenn ja, in welchem Bereich muss ich was umbauen?
Ich komme der zeit nicht weiter weil ich nicht weiß wo ich suchen soll.
Danke erst mal.
Hier nochmal mein Code.
#include <SD.h>
#include <SPI.h>
#include "RTClib.h"
#include <Wire.h>
/*#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
#define outputA 6
#define outputB 7*/
int n = 1;
int var3 = 0; // counter
int var1 = 0; // Druckgeber 1 Presszylinder
int var2 = 0; // Druckgeber 2 Getriebedruck
int Pressensensor = 0; // Potipin fuer Demo
int Getriebesensor = 1; // Potipin fuer Demo
float counter = 0; // float fuer Kommastellen int fuer ganze Zahlen
float Vortriebsstrecke = 0;
//LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
RTC_DS1307 rtc;
//Definiere Prototypen
void speichernAufSD(void);
#define outputA 6
#define outputB 7
int aState;
int aLastState;
const int chipSelect = 4;
unsigned long timer;
const unsigned int speicherZyklus = 5000; //Speichern alle 5 Sekunden
void setup() {
Serial.begin(115200);
pinMode(SS, OUTPUT);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
while (!Serial) {
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
while (1);
}
Serial.println("card initialized.");
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
pinMode(Pressensensor, INPUT);
pinMode(Getriebesensor, INPUT);
pinMode(outputA, INPUT);
pinMode(outputB, INPUT);
timer = millis(); //Startwert von timer
/*lcd.begin (20,4);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.setCursor ( 0, 0 );
lcd.print(" BOHRDATENLOGGER ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print("Vortrieb m/t:");
lcd.setCursor ( 0, 2 ); // go to the next line
lcd.print("Vortrieb bar:");
lcd.setCursor ( 0, 3 ); // go to the next line
lcd.print("Getriebe bar:");*/
}
void loop(){
/*{
lcd.setCursor ( 15, 1 );
Vortriebsstrecke = counter * 0.05;
var1 = analogRead(Pressensensor);
var1 = map(var1, 0, 1000, 0, 400);
var2 = analogRead(Getriebesensor);
var2 = map(var2, 0, 1000, 0, 400);
lcd.print(Vortriebsstrecke);
lcd.setCursor ( 15, 2 ); // go to the next line
lcd.print(var1);
lcd.print(' ');
lcd.setCursor ( 15, 3 );
lcd.print(var2);
lcd.print(' ');
}*/
aState = digitalRead(outputA); // Reads the "current" state of the outputA
// If the previous and the current state of the outputA are different, that means a Pulse has occured
if (aState != aLastState)
{
// If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
if (digitalRead(outputB) != aState)
{
counter ++;
}// else
{
//counter --;
}
speichernAufSD();
aLastState = aState; // Updates the previous state of the outputA with the current state
}
//Hier wird nun im Zyklus von "speicherZyklus" das Unterprogramm "speichernAufSD()" aufgerufen
if (millis() >= timer + speicherZyklus)
{
timer = millis();
speichernAufSD();
}
}
void speichernAufSD()
{
DateTime now = rtc.now();
if (now.day() < 10) {
Serial.print('0');
}
Serial.print(now.day(), DEC);
Serial.print('/');
if (now.month() < 10) {
Serial.print('0');
}
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(", ");
if (now.hour() < 10) {
Serial.print('0');
}
Serial.print(now.hour(), DEC);
Serial.print(':');
if (now.minute() < 10) {
Serial.print('0');
}
Serial.print(now.minute(), DEC);
Serial.print(':');
if (now.second() < 10) {
Serial.print('0');
}
Serial.print(now.second(), DEC);
Serial.print(',');
Serial.print(var1);
Serial.print(", ");
Serial.print(var2);
Serial.print(", ");
Serial.println(counter * 0.05);
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// if the file is available, write to it:
if (dataFile) {
if (now.day() < 10) {
dataFile.print('0');
}
dataFile.print(now.day(), DEC);
dataFile.print('/');
if (now.month() < 10) {
dataFile.print('0');
}
dataFile.print(now.month(), DEC);
dataFile.print('/');
dataFile.print(now.year(), DEC);
dataFile.print(",");
if (now.hour() < 10) {
dataFile.print('0');
}
dataFile.print(now.hour(), DEC);
dataFile.print(':');
if (now.minute() < 10) {
dataFile.print('0');
}
dataFile.print(now.minute(), DEC);
dataFile.print(':');
if (now.second() < 10) {
dataFile.print('0');
}
dataFile.print(now.second(), DEC);
dataFile.print(",");
dataFile.print(var1);
dataFile.print(", ");
dataFile.print(var2);
dataFile.print(", ");
dataFile.print(counter * 0.05);
dataFile.println();
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}