Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Figaro CDM7160 continuous I2C read w/busy PIN (Python)
#!/usr/bin/env python
from smbus2 import SMBus, SMBusWrapper, i2c_msg
import time
import RPi.GPIO as GPIO
INPUT_PIN = 8 #The BUSY pin.
def inputLow(channel):
with SMBusWrapper(1) as bus:
#set the device to continuous read
bus.write_byte(0x69, 0x1, 0x6)
#read back 0x1
byte1 = bus.read_byte(0x69,0)
#read 0x2
status = bus.read_byte(0x69,0)
#read 0x3
low_byte = bus.read_byte(0x69,0)
#read 0x4
high_byte = bus.read_byte(0x69,0)
reading = (high_byte * 256) + low_byte
print("c02 reading: " + str(reading))
def read_loop():
while True:
if __name__ == "__main__":
#set inputLow to fire when the busy pin drops to low.
GPIO.add_event_detect(INPUT_PIN, GPIO.FALLING, callback=inputLow, bouncetime=200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.