TypeError: Empty argument list. DS3231 Module



  • Dear Sir,

    Iam using Module DS3231 RTC module on Onion Omega 2s Board

    When i execute the command i2cdetect-y 0. It shows device address 0x68,0x57.

    My requirement is store any string or value in EEPROM/Memory and read the value from same address and prints the same on terminal.

    I created two file EEPROM.py & testMemory.py

    EEPROM.py

    from datetime import datetime                                                                                                      
    from OmegaExpansion import onionI2C                                                                                                
    
    import time                                                                                                                        
                                                                                                                                       
    
                                                                                                                                       
    class SDL_DS3231():                                                                                                                
        _REG_SECONDS = 0x00                                                                                                            
        _REG_MINUTES = 0x01                                                                                                            
        _REG_HOURS = 0x02                                                                                                              
        _REG_DAY = 0x03                                                                                                                
        _REG_DATE = 0x04                                                                                                               
        _REG_MONTH = 0x05                                                                                                              
        _REG_YEAR = 0x06                                                                                                               
        _REG_CONTROL = 0x07                                                                                                            
    
    
    
        ###########################                                                                                                    
        # DS3231 Code                                                                                                                  
        ###########################                                                                                                    
        def __init__(self, twi=0, addr=0x68, at24c32_addr=0x57):                                                                       
            # self._bus = smbus.SMBus(twi)                                                                                             
            self._i2c = onionI2C.OnionI2C(twi)                                                                                         
            self._addr = addr                                                                                                          
            self._at24c32_addr = at24c32_addr                                                                                          
    
                                                                                                                                       
    
        ###########################                                                                                                    
        # AT24C32 Code                                                                                                                 
        ###########################                                                                                                    
    
        # def set_current_AT24C32_address(self,address):                                                                               
        #  a0=address%256;                                                                                                             
        #  a1=address/256;                                                                                                             
        #  self._bus.write_i2c_block_data(self._at24c32_addr,a1,[a0])                                                                  
    
    
        def read_AT24C32_byte(self, address):                                                                                          
            #print "i2c_address =0x%x eepromaddress = 0x%x  " % (self._at24c32_addr, address)                                          
    
            # self.set_current_AT24C32_address(address)                                                                                
            # return self._bus.read_byte(self._at24c32_addr)                                                                           
            return self._i2c.readBytes(self._at24c32_addr, address, 1)                                                                 
    
    
        def write_AT24C32_byte(self, address, value):                                                                                  
            #print "i2c_address =0x%x eepromaddress = 0x%x value = 0x%x %i " % (self._at24c32_addr, address, value, value)             
            # a1=address/256;                                                                                                          
            # a0=address%256;                                                                                                          
            # self._bus.write_i2c_block_data(self._at24c32_addr,a1,[a0, value])                                                        
            self._i2c.writeBytes(self._at24c32_addr,address,value)                                                                     
            time.sleep(0.20)                                         
    

    testMemory.py

    import time                                                                                                                        
    import datetime,pytz                                                                                                               
    import EEPROM                                                                                                                      
    
    
    
                                                                                                                                       
    start_time = datetime.datetime.utcnow()                                                                                            
    
    ds3231 = EEPROM.SDL_DS3231(0, 0x68)                                                                                                
    
    
    while True:                                                                                                                                                                                                                  
        ds3231.write_AT24C32_byte(0x00,16)             # Ex: 16 is the value i want to store.                                                                                
        ds3231.read_AT24C32_byte(0x00)                                                                                                 
                                                                                                                                       
        time.sleep(5)       
    

    But when i tried to execute the code. I get an error

    2020-08-09 21:23:43.002174+05:30                                                                                                   
    Traceback (most recent call last):                                                                                                 
      File "testMemory.py", line 21, in <module>                                                                                       
        ds3231.write_AT24C32_byte(0x00,16)                                                                                             
      File "/mnt/mmcblk0p1/RTC/EEPROM.py", line 51, in write_AT24C32_byte                                                              
        self._i2c.writeBytes(self._at24c32_addr,address,value)                                                                         
    TypeError: Empty argument list.
    

    Code i get from https://github.com/jorgegarciadev/RTC_SDL_DS3231

    Please help me to come out of this error.

    Thank you for your attention to this matter

    Thanks & Regards
    Nagendra



  • @Nagendra-yedem
    I'm afraid the commands of Onion I2C Python Module are not able to interpret a 2 byte / 16 bit wide register address.
    In these command readBytes(devAddr, addr, size), writeByte(devAddr, addr, value), writeBytes(devAddr, addr, values) 'addr' can be only 1 byte.



Looks like your connection to Community was lost, please wait while we try to reconnect.