Hi,
this is an example of using the Real Time Clock DS1302 (from sunfounder).
There are two versions:
1. Manual: Set the time manual befor uploading. After uploading the time is logged every seconds by a timer.
2. Commands: Various commands are accepted via the serial line (using Asyncstream):
2016.06.2 First Version
this is an example of using the Real Time Clock DS1302 (from sunfounder).
There are two versions:
1. Manual: Set the time manual befor uploading. After uploading the time is logged every seconds by a timer.
2. Commands: Various commands are accepted via the serial line (using Asyncstream):
- set: Set the RTC time year, month , dayofmonth , hour , minute , second , dayofweek
- get: Get the RTC timeformat YYYY-mon-dayofweek hour:minute:second dayofweekname
- getbytes: Get the RTC time as an array of bytes with year, month , dayofmonth , hour , minute , second , dayofweek
- start / stop: Start & Stop Logging
B4X:
DS1302 ---- Arduino (Wirecolor)
SCL ------- 7 yellow
SDA ------- 6 brown
RST ------- 5 white
VCC ------- 3.3v red
GND ------- GND black
2016.06.2 First Version
- The DS1302 library is included. Copy to the Arduino IDE Libraries in folder ds1302.
- The code uses Inline C with ds1302.h included.
- Have not been successful with the attempt to wrap the library DS1302, therefor solved using Inline C.
- A type is used for the timestamp.
- Overall, must say, was not easy to get started - several wrapping attemps not successful, then finding best way to handle timestamp went back and forth ... but anyhow this is now working fine.
- Next: when the I2C LCD arrives will amend with a clock.
- Source code attached and documented.
- New library rDS1302 wrapping DS1302.
- Build two versions Manual and Commands using the rDS1302 Library.
- Attachment updated which contains:
- Example using Inline C with the DS1302 Library (rtcds1302-inlinec-command, rtcds1302-inlinec-manual).
- Example using the wrapped library rDS1302 (rtcds1302-lib-command, rtcds1302-lib-manual).
- Examples tested with an Arduino UNO and Sunfounder DS1302.
- The new rDS1302 is in the attachment folder Library rDS1302.
Attachments
Last edited: