Arduino MKR 1010 Wifi

I have bought an Arduino mkr 1010 wifi and would like to use the code that I used for the Arduino UNO that worked but it does not work in the Arduino mkr 1010. I used exemples->rtclib-ds3131 instead and then I get the correct time but when I use the code that I used for Arduino UNO I get the following error code
In file included from C:\Users\ulfer\OneDrive\Dokument\Arduino\Arduinows2812DS3231hourminencolorny\Arduinows2812DS3231hourminencolorny.ino:1:0:
c:\Users\ulfer\OneDrive\Dokument\Arduino\libraries\DS3231/DS3231.h:120:3: error: 'Twi' does not name a type
Twi *twi;
^~~

exit status 1

Compilation error: exit status 1
I want to use this code:

#include <DS3231.h>
#include <FastLED.h>
#define NUM_LEDS 300
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 40
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;

DS3231 rtc(SDA, SCL);
Time t;

const int OnHour = 5;
const int OnMin = 30;
const int OffHour = 8;
const int OffMin = 1;

const int OnHour2 = 17;
const int OnMin2 = 1;
const int OffHour2 = 23;
const int OffMin2 = 55;

void setup() {
  Serial.begin(115200);
  rtc.begin();
  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);
  FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();
}
void loop() {
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  Serial.print(t.min);
  Serial.print(" minute(s)");
  Serial.println(" ");
  delay(1000);

  if ((t.hour >= OnHour && t.min >= OnMin) && (t.hour <= OffHour && t.min <= OffMin) || (t.hour >= OnHour2 && t.min >= OnMin2) && (t.hour <= OffHour2 && t.min <= OffMin2)) {
    digitalWrite(Relay, HIGH);
    Serial.println("LIGHT ON");
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;
      FastLED.show();
      delay(50);
    }
  } else {
    digitalWrite(Relay, LOW);
    Serial.println("LIGHT OFF");
  }
}

I tried this code instead and then I get the time but it says light off all the time.

//#include <DS3231.h>
#include <RTCZero.h>
#include <FastLED.h>
#define NUM_LEDS 300
#define DATA_PIN 8
#define COLOR_ORDER GRB
#define CHIPSET WS2812B
#define BRIGHTNESS 40
#define VOLTS 5
#define MAX_AMPS 500
CRGB leds[NUM_LEDS];

int Relay = 4;

/* Create an rtc object */
RTCZero rtc;

/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 24;
const byte hours = 15;

/* Change these values to set the current initial date */
const byte day = 27;
const byte month = 11;
const byte year = 23;

void setup() {

  Serial.begin(9600);
  rtc.begin();  // initialize RTC 24H format

  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);

  rtc.setHours(hours);
  rtc.setMinutes(minutes);
  rtc.setSeconds(seconds);

  rtc.setDay(day);
  rtc.setMonth(month);
  rtc.setYear(year);

  FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_AMPS);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
  FastLED.show();
}
void loop() {
  Serial.print(rtc.getDay());
  Serial.print("/");
  Serial.print(rtc.getMonth());
  Serial.print("/");
  Serial.print(rtc.getYear());
  Serial.print(" ");


  Serial.print(rtc.getHours());
  Serial.print(":");
  Serial.print(rtc.getMinutes());
  Serial.print(":");
  Serial.print(rtc.getSeconds());

  Serial.println();

  delay(1000);

  if ((hours >= 15 && minutes >= 26) && (hours <= 15 && minutes <= 40) || (hours >= 15 && minutes >= 50) && (hours <= 16 && minutes <= 10)) {
    digitalWrite(Relay, HIGH);
    Serial.println("LIGHT ON");
    for (int i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::White;
      FastLED.show();
      delay(50);
    }
  } else {
    digitalWrite(Relay, LOW);
    Serial.println("LIGHT OFF");
  }
}

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