adafruit / Adafruit-uRTC

MicroPython library for RTCs
MIT License
26 stars 8 forks source link

TypeError: unsupported types for __floordiv__: 'NoneType', 'int' #3

Closed SlowBro904 closed 7 years ago

SlowBro904 commented 7 years ago

Getting this error on an ESP-12E (NodeMCU 0.9) using either CircuitPython 0.9.5 for Huzzah or uPython (mainline) 1.8.7. Not sure how to proceed.

Adafruit CircuitPython 0.9.5 on 2017-04-14; ESP module with ESP8266
>>> import urtc                                                                   
>>>  
>>> from machine import I2C, Pin                                                                                
>>> 
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> rtc = urtc.DS3231(i2c)
>>> datetime = urtc.datetime_tuple(year=2017, month=4, day=21)
>>> rtc.datetime(datetime)
Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
  File "urtc.py", line 126, in datetime 
  File "urtc.py", line 77, in datetime 
  File "urtc.py", line 20, in _bin2bcd 
TypeError: unsupported types for __floordiv__: 'NoneType', 'int' 
>>> 
SlowBro904 commented 7 years ago

FYI reading the clock works.

>>> datetime = rtc.datetime()                                                                                                                         
>>> print(datetime.year)                                                                                                                              
2000                                                                                                                                                  
>>>   
tannewt commented 7 years ago

While this should theoretically work, its only been tested when providing all components of the datetime. Try providing them all including the time. They are year=None, month=None, day=None, weekday=None, hour=None, minute=None, second=None, millisecond=None