Exemplo n.º 1
0
import I2C
import I2C.sensors

i2c = I2C.BusI2C('COM2')
i2c.bus.setSpeed(2000)  # you can set i2c speed adapted to your hardware
sonde = I2C.sensors.LM75('Room 1', i2c)
print("T =  %02.03f C" % sonde.getTemperature())
Exemplo n.º 2
0
                log.error("LM75 protocol error")
                time.sleep(0.1)

    def getTemperature(self, wait=True):
        if self.pauseBackground:
            while wait and self.temperature == None:
                time.sleep(0.1)
        else:
            self.temperature = self.measure()
        return self.temperature

    def close(self):
        #del (self.i2c)
        pass


#---------------------------------------------------------------------------

if __name__ == '__main__':

    logging.basicConfig()
    log = logging.getLogger("I2C")
    log.setLevel(logging.DEBUG)
    log.info("----- I2C sensors test ---------")

    i2cBus = I2C.BusI2C('LPT1')
    sonde = LM75('Room 1', i2cBus)
    for i in range(10):
        log.debug("T =  %02.03f C" % sonde.getTemperature())
        time.sleep(1)