Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 29 21:20
    Makuna unlabeled #110
  • Sep 29 21:20
    Makuna closed #110
  • Sep 29 21:15

    Makuna on master

    enable travis build using platf… (compare)

  • Sep 29 21:15
    Makuna closed #116
  • Sep 23 20:22
    Makuna closed #120
  • Sep 23 20:22
    Makuna updated the wiki
  • Sep 23 20:13
    Makuna updated the wiki
  • Sep 23 08:34
    T0m92 opened #120
  • Aug 27 15:58
    Makuna closed #119
  • Aug 27 15:58
    Makuna labeled #119
  • Aug 27 15:55
    Makuna closed #118
  • Aug 27 08:15
    Bredahl opened #119
  • Aug 03 15:39
    Flavian opened #118
  • Aug 01 19:24
    Makuna closed #117
  • Aug 01 17:19
    lucagrosshennig opened #117
  • Jul 31 17:46
    thijstriemstra opened #116
  • Jul 25 23:30

    Makuna on 2.3.5

    (compare)

  • Jul 25 23:28

    Makuna on NextRelease

    (compare)

  • Jul 25 23:28

    Makuna on master

    increment version (#115) (compare)

  • Jul 25 23:28
    Makuna closed #115
Ivan Maltarić
@jasamico_twitter
I already did that, using a website to fetch time and date, but the thing is I have microSD card adapter/module and I write the measurements in it so if by any chance the station is not connected to WiFi you can still see what it measured so I wanna print the date in the SD card next to the certain values
egge12
@egge12
Hi, I'm using DS3231 RTC together with RTC by Makuna... thanks for great work! Now it looks that I have a problem with eeprom... so I wanted to test DS3231_Memory.ino in the examples folder... unfortunately I'm getting an error while compiling: "DS3231_Memory:194:25: error: 'snprintf_P' was not declared in this scope dt.Second() );" any suggestions, what I'm doning wrong?
Michael Miller
@Makuna
what platform?
What Arduino are you building for?
egge12
@egge12
Hi Michael, it is not an Arduino but an STM32 blue pill (automatic telescope control): https://onstep.groups.io/g/main/wiki/6408. With the Arduiono-SAM Boards (32 bit ARM Cortex 3); Arduino_STM32 Package; RTC by Makuna library and digitalWriteFast library it should run like an arduione... setup itself works fine... e.g. bink-sketch can be executed normally... the eeprom of DS3231 is recognized, however it seems that there might be some issues with writing procedures... therefore I'm looking for test procedures... thanks for your support.
Michael Miller
@Makuna
@egge12 The STM32 is not very Arduino compatible, they didn't implement the _p variants of functions (one of the few platforms that didn't).
Replace that line with
    snprintf(datestring, 
            countof(datestring),
            "%02u/%02u/%04u %02u:%02u:%02u",
            dt.Month(),
            dt.Day(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
egge12
@egge12
@Makuna Thanks a lot Michael! Worked perfectly... after flashing, I got from serial monitor at 57600baud: 22:04:14.319 -> data read (29) = "What time is it in Greenwich?"
22:04:19.333 -> 08/23/2020 22:04:13... does this mean my DS3231 works properly including eeprom??? is there a write/read sequence to/from eeprom included in DS3231_Memory.ino?
Michael Miller
@Makuna
@egge12 If you read the sketch, there is a section that writes everytime. To confirm it is storing after reboot, you need to comment out the complete section as it states. Remove the * / at the end of this first line will do that.
/* comment out on a second run to see that the info is stored long term */
    // Store something in memory on the Eeprom

    // store starting address of string
    RtcEeprom.SetMemory(0, stringAddr); 
    // store the string, nothing longer than 32 bytes due to paging
    uint8_t written = RtcEeprom.SetMemory(stringAddr, (const uint8_t*)data, sizeof(data) - 1); // remove the null terminator strings add
    // store the length of the string
    RtcEeprom.SetMemory(1, written); // store the 
/* end of comment out section */
Note that this code is demonstrating a technique to store offsets at the front to different data and lengths of those data sets. Sort of a cheap FAT.
Ivan Maltarić
@jasamico_twitter
Hi, another question, which init part do I need to comment out for DS1302, because each time i reset my NodeMCU the time goes back to when the program was uploaded
Michael Miller
@Makuna
@jasamico_twitter That is what this code in the examples does
    RtcDateTime now = Rtc.GetDateTime();
    if (now < compiled) 
    {
        Serial.println("RTC is older than compile time!  (Updating DateTime)");
        Rtc.SetDateTime(compiled);
    }
Ivan Maltarić
@jasamico_twitter
So it means that it's necessary to leave that part in? Because even with that part if I decide to hit reset button, after 10 mins of measuring, the time goes back as if those 10 mins didn't happen, and the update never happens, it just loops back to the starting point.
Michael Miller
@Makuna
Thats one example. Do you have any other code that calls SetDateTime, comment it out. Most of the examples when they call it like the above, they output a message so you know why, are you getting any of those messages?
egge12
@egge12
@Makuna Thanks Michael, worked perfectly... I flashed DS3231_Memory.ino and after that I did it again, with the complete section commented out... serial monitor gave 22:54:56.018 -> 08/24/2020 22:54:50
22:55:01.007 -> data read (29) = "What time is it in Greenwich?"
22:55:06.007 -> 08/24/2020 22:55:00
22:55:10.998 -> data read (29) = "What time is it in Greenwich?"
22:56:03.398 -> data read (29) = "What time is it in Greenwich?"
22:56:08.420 -> 08/24/2020 22:56:02
22:56:13.413 -> data read (29) = "What time is it in Greenwich?"
22:56:18.400 -> 08/24/2020 22:56:12; first 4 lines were with section and second 4 lines were without section... so no differences... is this a good sign? Does this mean write/read works on the eeprom?
Michael Miller
@Makuna
yup, it read the string "What time is it in Greenwich" from the EEPROM on the RTC.
egge12
@egge12
@Makuna Thanks a lot, so this seems to prove, that my DS3231 works??? In this case my problem seems to be somewhere else... One last possibility could be the STM32 itself (I'm using blue pill). They are sold with 64kB flash - usually all of them have 128kB... the application OnStep also requires 128kB... in some rare cases the STM32 only have 64kB, however I don't have any idea how to test this... are you familar with STM32 and have a good hint? thanks in advance.
Michael Miller
@Makuna
No, not very familiar with the STM32. Is there a forum/channel for it?
egge12
@egge12
@Makuna thanks again... you helped me a lot... I will try to search for STM32 groups
Luca Grosshennig
@lucagrosshennig
Hey when I try this(https://github.com/Makuna/Rtc/blob/master/examples/DS3231_Memory/DS3231_Memory.ino) script with my esp8266 and the ds3231. I just get errors. What can i try?
compiled: Aug 26 202015:53:40
15:54:08.004 -> 08/26/2020 15:53:40
15:54:08.038 -> RTC communications error = 2
15:54:08.072 -> RTC was not actively running, starting now
15:54:08.109 -> RTC is older than compile time! (Updating DateTime)
15:54:08.350 -> RTC communications error = 2
15:54:08.383 -> 01/01/2000 00:00:00
15:54:13.338 -> address didn't match 4
15:54:13.372 -> something didn't match, count = 4, gotten = 0
15:54:13.408 -> data read (0) = ""
15:54:18.340 -> RTC communications error = 2
15:54:18.374 -> 01/01/2000 00:00:00
15:54:23.348 -> address didn't match 4
15:54:23.381 -> something didn't match, count = 4, gotten = 0
15:54:23.414 -> data read (0) = ""
15:54:28.349 -> RTC communications error = 2
15:54:28.382 -> 01/01/2000 00:00:00
15:54:33.354 -> address didn't match 4
15:54:33.389 -> something didn't match, count = 4, gotten = 0
15:54:33.423 -> data read (0) = ""
15:54:38.362 -> RTC communications error = 2
15:54:38.396 -> 01/01/2000 00:00:00
15:54:43.358 -> address didn't match 4
15:54:43.391 -> something didn't match, count = 4, gotten = 0
15:54:43.425 -> data read (0) = ""
15:54:48.356 -> RTC communications error = 2
15:54:48.390 -> 01/01/2000 00:00:00
Luca Grosshennig
@lucagrosshennig
Oh I got it. it was my breadboard. It is broke
Michael Miller
@Makuna
The other details with Esp8266 to always keep your eyes on is that hardware features are usually stuck on specific pins.
Mal-Oldis
@Mal-Oldis
Just got this up and running on esp32. Nice. Wondering how to set and read the DOW?. Take it easy on me as this is mostly black art to me. Thanks
Michael Miller
@Makuna
From any example, use the RtcDateTime object and call DayOfWeek on it. It will return the day of week as uint8_t, the DayOfWeek enum is the common interpretation of that returned value.
Mal-Oldis
@Mal-Oldis
I struggle to get my head around C. I am a basic guy... Can you show me what that would look like in code? Thanks
I get a message class RtcDS3231 <TwoWire> has no member DayOfWeek . RtcDateTime doW = Rtc.DayOfWeek();
I really struggle with this. ANy help much appreciated
Michael Miller
@Makuna

You really will need to teach yourself C++ if any of this is going to make sense.
in the examples, you can see how it uses the RtcDataTime

void printDateTime(const RtcDateTime& dt)
{
    char datestring[20];

    snprintf_P(datestring, 
            countof(datestring),
            PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
            dt.Month(),
            dt.Day(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
    Serial.print(datestring);
}

DayOfWeek() is just another property of the data time.

Mal-Oldis
@Mal-Oldis
OK, thanks for that. I will try to get my head around it. I need to be able to set it of course and will work around existing examples. In example above is dt a structure?
Michael Miller
@Makuna
RtcDateTime is a class (class and struct are very similar in C++ but not exactly the same). dt is an instance of that the RtcDateTime class.
There is no need to set day of week (and you can't anyhow) as it is automatically calculated from all the other properties.
Mal-Oldis
@Mal-Oldis
DOW is register 3, b0-2 in the device. I guess calculations for DOW are done in libraries not in silicon? I think I might stick to the low level stuff and talk to the device directly through wire.h. My roots are in hard core ASM embedded design. Wrote my own I2C bit basing routines before those functions ended up in silicon. I spent 6 years making IC's. Will soldier on with C++ thanks again Michael.
Michael Miller
@Makuna
yes, calculated. There was a bug in the silicon on some of the early RTCs dealing with DOW and the calculation is easy enough. When you set time, it does still set the DOW (from the calculation) so alarms set for DOW still work.
Mal-Oldis
@Mal-Oldis
OK, Cheers for that. Thanks...
ruhibhatnagar
@ruhibhatnagar
hello all, i am making a project using ds3231 RTC and nodemcu, i am using this Makuna/Rtc library for RTC. In this project can i use more than 2 alarm functions ? actually i am using this 'DS3231AlarmOne alarm1' function and i want to use 5 more like this 'DS3231AlarmOne alarm1', i am a beginner please help ASAP.
Michael Miller
@Makuna
The DS3231 can only have two alarms active at one time, DS3231AlarmOne and DS3231AlarmTwo. You would have to implement a cascading queue: sort the alarm times, set the next alarm in the RTC, when it fires set the next alarm from the queue and continue.
ruhibhatnagar
@ruhibhatnagar
thank you sir for your kind attention and quick response, this will really help me
JuSerge
@JuSerge
afbeelding.png
When I run your program, I keep getting the same date. I've checked it and my device is connected correctly
JuSerge
@JuSerge
afbeelding.png
Now, it doesn't give the correct date
Do you know how to fix this?
Michael Miller
@Makuna
@JuSerge You didn't mention which sample you are running, or which RTC module you are using. Generally, this is due some communications issue as the specific wire interface doesn't provide communications error return and just returns random memory.
Michael Miller
@Makuna
The other issue that can cause this is a low battery. Some of units require a good battery to even function correctly even when powered.
JuSerge
@JuSerge
I was running the DS1302_simple, so my rtc module is the DS1302 I don't understand what you mean with this "Generally, this is due some communications issue as the specific wire interface doesn't communications error return and just returns random memory." (I am not really good at English)
JuSerge
@JuSerge
I tried another battery, now it just keeps saying the same date and time.
Michael Miller
@Makuna
@JuSerge So it is working for you now?
https://github.com/Makuna/Rtc/wiki/FAQ-%235
giacomo30196
@giacomo30196
Hi, first time in a chat like this, i'm using your library in a project of mine, it works flawlessly. I just need to retrieve the unix like timestamp and i don't know how. I looked in library's file, i found the "secondsfrom2000" variable which would be ok for me. However i'm not able to retrieve it from my sketch. Do you have any suggestion? Thank you for your time.
Michael Miller
@Makuna
@giacomo30196 I believe the unix time is actually more accurately defined as Epoch time. The RtcDateTime object has two methods to retrieve this, Epoch32Time() and Epoch64Time() that return either a uint32_t or uint64_t. You can also initialize a RtcDateTime object by the methods InitWithEpoch32Time(uint32_t time) and InitWithEpoch64Time(uint64_t time)
RajehTXD
@RajehTXD
Hey there, I am using the DS1302 RTC module, and i chose to use your library for the ease of use, I just want to know how I can stop it displaying the same date and time (Compile time) I tried both the "Simple" and Memory examples.
No worries I just figured it out ^_^,
RajehTXD
@RajehTXD
RtcDateTime now = Rtc.GetDateTime();
if (now < compiled) 
{
    Serial.println("RTC is older than compile time!  (Updating DateTime)");
    Rtc.SetDateTime(compiled);
}