Difference between revisions of "USB-RTC"

From SB-Components Wiki

 
(24 intermediate revisions by the same user not shown)
Line 20: Line 20:
 
<li> Low-Power Consumption  </li>
 
<li> Low-Power Consumption  </li>
 
</br>
 
</br>
 +
 
=== Specifications ===
 
=== Specifications ===
 
<li> Accuracy ±2ppm from 0°C to +40°C </li>
 
<li> Accuracy ±2ppm from 0°C to +40°C </li>
Line 35: Line 36:
 
</div>
 
</div>
 
   <div class="large-4 column">
 
   <div class="large-4 column">
[[File:USB_RTC.png]]
+
[[File:USB_RTC.png|thumb|left|alt=Pico 1.14 LCD HAT| Buy it From : ''[https://shop.sb-components.co.uk/products/usb-rtc-for-raspberry-pi-1 Click Here]'']]
 
   </div>
 
   </div>
 
</div>
 
</div>
  
 
== Installation ==
 
== Installation ==
 +
 +
=== Raspberry Pi ===
 
==== Python ====
 
==== Python ====
 
* Install MCP2221 Library by running below command on terminal:
 
* Install MCP2221 Library by running below command on terminal:
<pre> pip3 install PyMCP2221A </pre>
+
<source lang="shell"> sudo pip3 install PyMCP2221A </source>
 
* Connect USB-RTC on USB Port of Raspberry Pi/Windows.
 
* Connect USB-RTC on USB Port of Raspberry Pi/Windows.
 
* Now clone/download USB-RTC Github Repository by running below command:
 
* Now clone/download USB-RTC Github Repository by running below command:
  
<pre> git clone https://github.com/sbcshop/USB-RTC.git </pre>
+
<source lang="shell"> git clone https://github.com/sbcshop/USB-RTC.git </source>
  
 
* Now enter downloaded folder from home/pi or by rnning below command:
 
* Now enter downloaded folder from home/pi or by rnning below command:
  
<pre> cd USB-RTC </pre>
+
<source lang="shell"> cd USB-RTC </source>
  
 
* Now run test.py file by running below command:
 
* Now run test.py file by running below command:
  
<pre> python3 test.py </pre>
+
<source lang="shell"> sudo python3 test.py </source>
 +
</br>
 +
* After running above command, you will get below output.
 +
[[File:USB_RTC_output_NEW.png]]
 +
 
 +
=== Windows ===
 +
==== Python ====
 +
* Install MCP2221 Library by running below command on terminal:
 +
<source lang="shell"> pip install PyMCP2221A </source>
 +
 
 +
* Connect USB-RTC on USB Port of Raspberry Pi/Windows.
 +
 
 +
* Now clone/download USB-RTC Github Repository of USB RTC:
 +
 
 +
<source lang="shell"> https://github.com/sbcshop/USB-RTC </source>
 +
 
 +
* Open the downloaded folder and run test.py file in any python supported ide.
 +
* You will get the below output after running the file.
 +
 
 +
[[File:USB_RTC_output_win.PNG | 600 px]]
 +
 
 +
==== Functions ====
 +
 
 +
* To modify Date & Time, you have to change the last value of each line in the hexadecimal form inside def SetTime(address):
 +
For Example :
 +
<source lang="python">
 +
#sec min hour week day month year
 +
NowTime = [0x00,0x00,0x18,0x04,0x12,0x08,0x15]  #Edit this line to set RTC Date and Time
 +
</source>
 +
 
 +
* To read time, you can call "ds3231ReadTime()" Function
 +
 
 +
* To read the internal temperature of USB-RTC, uncomment below the line by removing ''' from start and end of the line :
 +
<source lang="python">
 +
'''Celsius = getTemp(address)
 +
Fahrenheit = 9.0/5.0 * Celsius + 32
 +
print (Fahrenheit, "*F /", Celsius, "*C") '''
 +
</source>
  
 
== Resources ==
 
== Resources ==
 +
* [https://cdn.shopify.com/s/files/1/1217/2104/files/MCP2221-Datasheet.pdf  MCP2221 Datasheet]
 +
 +
'''Blogs'''
 +
 +
* [https://shop.sb-components.co.uk/blogs/posts/complete-guide-to-setup-automatic-time-with-usb-rtc '''Complete guide to setup automatic time of RPi with USB RTC''']

Latest revision as of 09:52, 1 November 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

  • Temperature-compensated crystal oscillator
  • DS3231 advanced processor
  • MCP2221
  • I2C/SMBus supported clock and data lines
  • User-selectable via jumper cable for 3.3V or 5V level output (up to 500 mA)
  • Four GPIO lines that are configurable for GPIO Operations
  • Pins for Serial(UART) Communication
  • Supports full-speed USB (12 Mb/s)
  • 64-byte Transmit
  • 64-byte Receive
  • USB 2.0 Compliant
  • Low-Power Consumption

  • Specifications

  • Accuracy ±2ppm from 0°C to +40°C
  • Accuracy ±3.5ppm from -40°C to +85°C
  • Battery Backup Input for Continuous Timekeeping
  • Operating Temperature Ranges Commercial: 0°C to +70°C Industrial: -40°C to +85°C
  • Low-Power Consumption
  • Real-Time Clock Counts Seconds, Minutes, Hours, Day, Date, Month, and Year with Leap Year Compensation Valid Up to 2100
  • Two Time-of-Day Alarms
  • Programmable Square-Wave Output
  • Fast (400kHz) I2C Interface
  • 3.3V Operation
  • Digital Temp Sensor Output: ±3°C Accuracy
  • Pico 1.14 LCD HAT
    Buy it From : Click Here

    Installation

    Raspberry Pi

    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


    • After running above command, you will get below output.

    USB RTC output NEW.png

    Windows

    Python

    • Install MCP2221 Library by running below command on terminal:
    pip install PyMCP2221A
    • Connect USB-RTC on USB Port of Raspberry Pi/Windows.
    • Now clone/download USB-RTC Github Repository of USB RTC:
    https://github.com/sbcshop/USB-RTC
    • Open the downloaded folder and run test.py file in any python supported ide.
    • You will get the below output after running the file.

    USB RTC output win.PNG

    Functions

    • To modify Date & Time, you have to change the last value of each line in the hexadecimal form inside def SetTime(address):

    For Example :

    #sec min hour week day month year
    NowTime = [0x00,0x00,0x18,0x04,0x12,0x08,0x15]  #Edit this line to set RTC Date and Time
    • To read time, you can call "ds3231ReadTime()" 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") '''

    Resources

    Blogs