File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import  busio 
2+ import  board 
3+ from  adafruit_bus_device .i2c_device  import  I2CDevice 
4+ 
5+ DEVICE_ADDRESS  =  0x68  # device address of DS3231 board 
6+ A_DEVICE_REGISTER  =  0x0E  # device id register on the DS3231 board 
7+ 
8+ # The follow is for I2C communications 
9+ comm_port  =  busio .I2C (board .SCL , board .SDA )
10+ device  =  I2CDevice (comm_port , DEVICE_ADDRESS )
11+ 
12+ with  device  as  bus_device :
13+     bus_device .write (bytes ([A_DEVICE_REGISTER ]))
14+     result  =  bytearray (1 )
15+     bus_device .readinto (result )
16+ 
17+ print ('' .join ('{:02x}' .format (x ) for  x  in  result ))
Original file line number Diff line number Diff line change 1+ import  busio 
2+ import  board 
3+ import  digitalio 
4+ from  adafruit_bus_device .spi_device  import  SPIDevice 
5+ 
6+ DEVICE_ADDRESS  =  0x68  # device address of BMP280 board 
7+ A_DEVICE_REGISTER  =  0xD0  # device id register on the BMP280 board 
8+ 
9+ # The follow is for SPI communications 
10+ cs  =  digitalio .DigitalInOut (board .A2 )
11+ comm_port  =  busio .SPI (board .SCK , MOSI = board .MOSI , MISO = board .MISO )
12+ device  =  SPIDevice (comm_port , cs )
13+ 
14+ #pylint: disable-msg=no-member 
15+ with  device  as  bus_device :
16+     bus_device .write (bytes ([A_DEVICE_REGISTER ]))
17+     result  =  bytearray (1 )
18+     bus_device .readinto (result )
19+ 
20+ print ('' .join ('{:02x}' .format (x ) for  x  in  result ))
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments