Nano 33 Iot - RTC And BLE To Update Alarm Times - Arduino Forum Home » Arduino Nano 33 Ble Rtc » Nano 33 Iot - RTC And BLE To Update Alarm Times - Arduino Forum Maybe your like Arduino Nano 33 Ble Rx Tx Arduino Nano 33 Ble Sense 5v Arduino Nano 33 Ble Sense Aliexpress Arduino Nano 33 Ble Sense Code Arduino Nano 33 Ble Sense Eeprom Nano 33 iot - RTC and BLE to update Alarm times Projects Programming ian5142 June 7, 2020, 4:55pm 1 Hello All, I am trying to update the Alarm times for my Nano 33 iot using BLE. I can get the BLE example to work but when I add in the RTC and sleep functionality, it breaks. I only need to be able to update the times when the nano is awake (not in Low Power mode). My Android phone can see the nano's LED Service on nRF Connect, but it never actually connects to it. Thanks, Ian /* Sleep RTC Alarm for Arduino nano 33 IOT with time set from a DS3231 */ #include <ArduinoBLE.h> #include <RTCZero.h> #include <SPI.h> /* Create an rtc object */ RTCZero rtc; //RTC_DS3231 extrtc; boolean awake = false; boolean turnRelayOff = false; const int relayPin = 2; // use this pin to drive the Relays const int ledPin = LED_BUILTIN; // pin to use for the LED //const unsigned long timeON = 60000; byte timeON = 6; // In hours //unsigned long time_now = 0; //unsigned long previousMs; byte alarmHours = 13; byte alarmMins = 31; byte alarm2Hours = 00; byte alarm2Mins = 35; /* Change these values to set the current initial time */ const byte seconds = 0; const byte minutes = 30; const byte hours = 13; /* Change these values to set the current initial date */ const byte day = 7; const byte month = 6; const byte year = 20; //BLEService alarmService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE Hour Service BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service // BLE Alarm Hour Characteristic - custom 128-bit UUID, read and writable by central //BLEIntCharacteristic hoursCharacteristic("19B10000-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); //BLEByteCharacteristic minsCharacteristic("3862A78D-13AF-4EC9-9615-D599F201617C", BLERead | BLEWrite | BLENotify); //BLEByteCharacteristic timeONCharacteristic("3862A78D-13AF-4EC9-9615-D599F201617C", BLERead | BLEWrite | BLENotify); BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite); //21600000; void setAlarm () { rtc.setAlarmTime(alarmHours, alarmMins, 00); rtc.enableAlarm(rtc.MATCH_HHMMSS); rtc.attachInterrupt(alarmMatch); } void setAlarm2 () { rtc.setAlarmTime(alarm2Hours, alarm2Mins, 00); rtc.enableAlarm(rtc.MATCH_HHMMSS); rtc.attachInterrupt(alarm2Match); } void setup() { Serial.begin(115200); // if (! extrtc.begin()) { // Serial.println("Couldn't find RTC"); // while (1); // } // if (extrtc.lostPower()) { // Serial.println("RTC lost power, let's set the time!"); // // When time needs to be set on a new device, or after a power loss, the // // following line sets the RTC to the date & time this sketch was compiled // extrtc.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(ledPin, OUTPUT); // set LED pin to output mode digitalWrite(ledPin, LOW); pinMode(relayPin, OUTPUT); // set relay pin to output mode digitalWrite(relayPin, HIGH); // DateTime now = extrtc.now(); rtc.begin(); rtc.setTime(hours, minutes, seconds); rtc.setDate(day, month, year); // rtc.setTime(now.hour(), now.minute(), now.second()); //Set internal RTC from DS3231 // rtc.setDate(now.day(), now.month(), now.year()); setAlarm(); rtc.standbyMode(); } void loop() { if (awake) { if (!BLE.begin()) { Serial.println("starting BLE failed!"); while (1); } // set the local name peripheral advertises BLE.setLocalName("LED Sign"); // set the UUID for the service this peripheral advertises: // BLE.setAdvertisedService(alarmService); // BLE.setAdvertisedService(ledService); // add the characteristics to the service // alarmService.addCharacteristic(hoursCharacteristic); // alarmService.addCharacteristic(minsCharacteristic); // alarmService.addCharacteristic(timeONCharacteristic); ledService.addCharacteristic(switchCharacteristic); // add the service // BLE.addService(alarmService); BLE.addService(ledService); switchCharacteristic.writeValue(0); // hoursCharacteristic.writeValue(alarmHours); // minsCharacteristic.writeValue(alarmMins); // timeONCharacteristic.writeValue(timeON); // start advertising BLE.advertise(); BLEDevice central = BLE.central(); // poll for BLE events BLE.poll(); if (central) { while (central.connected()) { digitalWrite(ledPin, LOW); delay(500); if (switchCharacteristic.written()) { if (switchCharacteristic.value()) { // any value other than 0 Serial.println("LED on"); digitalWrite(ledPin, HIGH); // will turn the LED on } else { // a 0 value Serial.println(F("LED off")); digitalWrite(ledPin, LOW); // will turn the LED off } } } // end while central } // end if central Serial.begin(115200); Serial.println("I'm Awake"); digitalWrite(relayPin, LOW); digitalWrite(ledPin, HIGH); awake = false; } // end of if awake Serial.println("Going to sleep"); if (turnRelayOff) { digitalWrite(relayPin, HIGH); digitalWrite(ledPin, LOW); turnRelayOff = false; } // end of turnRelayOff rtc.standbyMode(); // Sleep until next alarm match } // end of loop() void alarmMatch() { awake = true; setAlarm2(); } void alarm2Match() { setAlarm(); turnRelayOff = true; } bioerror April 29, 2021, 6:41pm 2 Greetings. I also have been having this issue. My troubleshooting leads me to believe that when the arduino calls the rtc chip (DS3231 in my case) this somehow interferes with the BLE. Unfortunately I have yet to find an answer. system Closed August 27, 2021, 6:41pm 3 This topic was automatically closed 120 days after the last reply. New replies are no longer allowed. Related topics Topic Replies Views Activity RTC on Arduino Nano 33 BLE? Nano 33 BLE 10 5339 October 1, 2021 Syncing Nano 33 BLE with RTC to the computer? General Guidance 1 651 May 5, 2021 Arduino NANO BLE - DS3231 alarm+interrupt example gets stuck Nano 33 BLE 4 751 August 22, 2023 Nano BLE33 - interrupt wake-up with DS3231 alarm General Guidance 6 643 August 2, 2023 How to broadcast data from one IoT to another IoT or BLE Sense via bluetooth Nano 33 IoT 28 6813 May 7, 2021 Tag » Arduino Nano 33 Ble Rtc RTC On Arduino Nano 33 BLE? RTC Available ? How To Use It ? - Nano 33 BLE - Arduino Forum RTC In BLE Nano - Question - Mbed Lab: Using A Real-Time Clock - NYU ITP Arduino Nano 33 IoT With Battery RTC - YouTube Arduino Clock (without Rtc) With Temperature And Humidity NANO 33 BLE Download - CircuitPython Ostaquet/Arduino-Nano-33-IoT-Ultimate-Guide - GitHub Arduino Usage | Adafruit DS3231 Precision RTC Breakout Arduino Nano 33 IoT Board - Getting Started - DroneBot Workshop Arduino Nano 33 BLE | ABX00030 | Core Electronics Australia All Libraries - Arduino Library List