Dcf77 mit WS2812b

hallo ich habe versucht eine uhr mit ein dcf77 und eine ws2812b matrix zu bauen nur kriege ich die zeit Synchronisation nicht hin alles andere ist so weit gut

weis jemand was der fehler ist

// Adafruit_NeoMatrix example for single NeoPixel Shield.

#include <DCF77.h>
#include <TimeLib.h>

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 6

#define DCF_PIN 2           // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0     // Interrupt number associated with pin

time_t prevDisplay = 0;          // when the digital clock was displayed
time_t time;
DCF77 DCF = DCF77(DCF_PIN, DCF_INTERRUPT);

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_GRBW    Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(60, 8, PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_RGB + NEO_KHZ800);

const uint16_t colors[] = { //G/R/B
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0), matrix.Color(0, 255, 255), matrix.Color(0, 0, 255), matrix.Color(255, 0, 255)
};


void setup() {

  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(20);
  matrix.setTextColor(colors[0]);
  
  DCF.Start();
  setSyncInterval(30);
  setSyncProvider(getDCFTime);
  
  pinMode(7, OUTPUT);
  pinMode(10, INPUT);
}

int x    = matrix.width();
int pass = 0;

int taster = 0;

unsigned long lastUpdateTime = 0;
const unsigned long updateInterval = 100; // Aktualisierungsintervall in Millisekunden

void loop() {
unsigned long currentTime = millis();
      
  if( now() != prevDisplay) //update the display only if the time has changed
  {
    prevDisplay = now();
      }
  int stunde = hour();
  int minuten = minute();

  // Aktualisiere die Zeit und andere Aufgaben nur alle updateInterval Millisekunden
  if (currentTime - lastUpdateTime >= updateInterval) {
    lastUpdateTime = currentTime;

    if ((stunde >= 9 && minuten > 45) && (stunde < 10)) {
      matrix.fillScreen(0);
      matrix.setCursor(x, 0);
      matrix.print(F("Es ist  "));
      printDigits(hour());
      matrix.print(F(":"));
      printDigits(minute());
      matrix.print(F(" Uhr "));
      matrix.print(F("     Viel Spaß in der Frühstückspause"));
      if (--x < -348) {          // je zeichen -6(pixel breite)
        x = matrix.width();
        if (++pass >= 6) pass = 0;
        matrix.setTextColor(colors[pass]);
      }
      matrix.show();
    }
    else if ((stunde >= 12) && (stunde <= 12 && minuten < 30)) {
      matrix.fillScreen(0);
      matrix.setCursor(x, 0);
      matrix.print(F("Es ist  "));
      printDigits(hour());
      matrix.print(F(":"));
      printDigits(minute());
      matrix.print(F(" Uhr "));
      matrix.print(F("     Viel Spaß in der Mittagspause"));
      if (x < -324) {
        x = matrix.width();
        if (++pass >= 6) pass = 0;
        matrix.setTextColor(colors[pass]);
      }
      matrix.show();
    }
    else if (stunde == 16 && minuten > 30) {
      matrix.fillScreen(0);
      matrix.setCursor(x, 0);
      matrix.print(F("Es ist   "));
      printDigits(hour());
      matrix.print(F(":"));
      printDigits(minute());
      matrix.print(F(" Uhr "));
      matrix.print(F("     Schönen Feierabend"));
      if (--x < -240) {
        x = matrix.width();
        if (++pass >= 6) pass = 0;
        matrix.setTextColor(colors[pass]);
      }
      matrix.show();
    }
    else {
      matrix.fillScreen(0);
      matrix.setCursor(4, 0);
      printDigits(hour());
      matrix.print(F(":"));
      printDigits(minute());
      matrix.print(F(" Uhr"));
      matrix.show();
      taster = digitalRead(10);
      // Taster gedrückt
      if (taster == HIGH) {
        // Zur nächsten Farbe wechseln
        if (++pass >= 6) pass = 0;
        matrix.setTextColor(colors[pass]);
      }
    }
  }
}

void printDigits(int digits) {
  // utility function for digital clock display: prints preceding colon and leading 0
  if (digits < 10)
    matrix.print('0');
  matrix.print(digits);
}

unsigned long getDCFTime()
{ 
  time_t DCFtime = DCF.getTime();
  // Indicator that a time check is done
  if (DCFtime!=0) {
    digitalWrite(7, HIGH); // Optional: Indicate successful synchronization
       unsigned long currentTime = millis();
       if (currentTime - lastUpdateTime >= 500) {
          lastUpdateTime = currentTime;
    digitalWrite(7, LOW); 
       }
  }
  return DCFtime;
}

Im Thema DCF77 vs adafruit Neopixel kannst du mir helfen? habe ich mal ein Programm gemacht, das wohl funktioniert hat. Schau mal, ob es Dir hilft.

Leider nicht hatte es schon mal so

.
.weiterer code
.
void setup
DCF.Start();
.
.weiterer code
.
void loop
  delay(5000);
  time_t DCFtime = DCF.getTime(); 
  if (DCFtime!=0)
  {
    setTime(DCFtime);
  }	
.
.weitere code
.

Problem war das der delay sich mit dem lauf Text der matrix gestört hat deswegen habe ich die delays mit mills() getaucht nur funktionierte die zeit Synchronisation da nicht mehr

So?

.
.weiterer code
.
byte uhr = 1;
void setup
DCF.Start();
.
.weiterer code
.
void loop
{
 //delay(5000);
 time_t DCFtime = DCF.getTime();
 if (DCFtime != 0)
 {
   uhr = 1;
 }
 switch (uhr)
 {
   case 1:
     setTime(DCFtime);
     .
     .weitere code
     .
     break;
 }
}

nur so aus dem Kopf ob funktioniert ?
Wenn Der DCF hat Synchronisiert springt in Switch, Case1.

hat geklappt danke

Wenn das Thema damit für Dich erledigt ist, könntest Du #4 als Lösung markieren und Dein jetzt funktionierendes Programm der Allgemeinheit zur Erbauung zeigen.

Damit nimmst Du nicht nur Hilfe, sondern gibst auch was zurück :slightly_smiling_face:

kommt noch gleich ich mache es noch übersichtlicher und pass noch ein par dinge an kommt spätesten morgen am 25. juli

Super, laß Dir Zeit!

Ein Foto sagt manchmal mehr als tausend Worte, ich mag Fotos :slightly_smiling_face:

// ws28xx uhr mit DCF77 by The_Ripper (G.P.Minacapilli)

#include <DCF77.h>
#include <TimeLib.h>

int stunde, minuten, Time, zeit;

#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define PIN 6

#define DCF_PIN 2           // Connection pin to DCF 77 device
#define DCF_INTERRUPT 0     // Interrupt number associated with pin

time_t prevDisplay = 0;          // when the digital clock was displayed
time_t time;
DCF77 DCF = DCF77(DCF_PIN,DCF_INTERRUPT);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// einstellen der matrix

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_GRBW    Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(60, 8, PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_RGB + NEO_KHZ800);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// farb konfiguration

const uint16_t colors[] = { //G/R/B
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0), matrix.Color(0, 255, 255), matrix.Color(0, 0, 255), matrix.Color(255, 0, 255)
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//einstellen der Zeitverzögerungs variabeln

unsigned long lastUpdateTime = 0;
const unsigned long updateInterval = 50; // Aktualisierungsintervall in Millisekunden
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//dcf77 und ws28xx matrix einstellen

void setup() {
  DCF.Start();
  setSyncInterval(30); // synchronisations Zeit in sekunden
  setSyncProvider(DCF.getTime(););

  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(10);
  matrix.setTextColor(colors[0]);

  while(timeStatus()== timeNotSet) { 
     // wait until the time is set by the sync provider  
      matrix.fillScreen(0);
      matrix.setCursor(4, 0);
      matrix.print(F("Suche..."));
      matrix.show();
      delay(2000);
    //}
  }
  pinMode(7, OUTPUT);
  pinMode(10, INPUT);
}



int x    = matrix.width();
int pass = 0;

int taster = 0;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// zeit anzeigen

void loop() {
  if( now() != prevDisplay){ //update the display only if the time has changed
    prevDisplay = now();
      matrix.fillScreen(0);
      matrix.setCursor(4, 0);
      printDigits(hour());
      matrix.print(":");
      printDigits(minute());
      matrix.print(F(" Uhr"));
      matrix.show();
      taster = digitalRead(10);
      // Taster gedrückt
      if (taster == HIGH) {
        // Zur nächsten Farbe wechseln
        if (++pass >= 6) pass = 0;
        matrix.setTextColor(colors[pass]);
      }
  }
 }

ist es ver. 1

Danke für die Rückmeldung.

Wird m. E. nicht verwendet.

Can you show your configuration? I have this old dcf clock that broke down and then I bought a seperate dcf77 receiver, that I want to try on the arduino one and two 16*16 Ws2812 square panels...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.