Difference between revisions of "USB-RTC"
From SB-Components Wiki
Line 67: | Line 67: | ||
* To read the internal temperature of USB-RTC, uncomment below the line by removing ''' from start and end of the line : | * To read the internal temperature of USB-RTC, uncomment below the line by removing ''' from start and end of the line : | ||
<source lang="python"> | <source lang="python"> | ||
+ | '''Celsius = getTemp(address) | ||
Fahrenheit = 9.0/5.0 * Celsius + 32 | Fahrenheit = 9.0/5.0 * Celsius + 32 | ||
− | print (Fahrenheit, "*F /", Celsius, "*C") | + | print (Fahrenheit, "*F /", Celsius, "*C") ''' |
</source> | </source> | ||
== Resources == | == Resources == | ||
[https://cdn.shopify.com/s/files/1/1217/2104/files/MCP2221-Datasheet.pdf| MCP2221 Datasheet] | [https://cdn.shopify.com/s/files/1/1217/2104/files/MCP2221-Datasheet.pdf| MCP2221 Datasheet] |
Revision as of 11:51, 19 June 2021
USB RTC
USB RTC is an open source real time clock device that comprises MCP2221, a USB-to-UART/I2C serial converter, which enables USB connectivity, in the processes that include a USB, UART(Serial), GPIO, and I2C interfaces. It runs on Hi-tech DS3231 RTC chip, an accurate I2C, runs the USB RTC with extremely high efficiency at a low cost. USB RTC for Raspberry Pi has cross platform support which makes it enable to work on different platforms like Windows, MAC, etc.
Features
Specifications
Installation
Python
- Install MCP2221 Library by running below command on terminal:
sudo pip3 install PyMCP2221A
- Connect USB-RTC on USB Port of Raspberry Pi/Windows.
- Now clone/download USB-RTC Github Repository by running below command:
git clone https://github.com/sbcshop/USB-RTC.git
- Now enter downloaded folder from home/pi or by rnning below command:
cd USB-RTC
- Now run test.py file by running below command:
sudo python3 test.py
Functions
- To modify Date & Time, you have to change the last value of each line in hexadecimal form inside def SetTime(address):
For Example :
bus.write_byte_data(0x68, 0x00, 0x02) # set seconds and start clock , it will set second value as 02 second after executing SetTime(address) function.
- To read time, you can call "ReadTime(address)" Function
- To read the internal temperature of USB-RTC, uncomment below the line by removing from start and end of the line :
'''Celsius = getTemp(address) Fahrenheit = 9.0/5.0 * Celsius + 32 print (Fahrenheit, "*F /", Celsius, "*C") '''