Welcome to 8-Channel Tracking Module repository
I2C method
Raspberry Pi - I2C Method
Raspberry Pi - I2C MethodExperimental preparationExperimental purposeExperimental wiringExperimental steps and phenomenaExperimental source code
Experimental preparation
Raspberry Pi motherboard
8-channel line patrol module
Several Dupont cables
The Raspberry Pi board needs to download the I2C communication source code provided in the document, and the Raspberry Pi system needs to open the i2c communication interface through raspi-config
Experimental purpose
The content of this experiment is mainly to use the Raspberry Pi main control to receive the data of the 8-channel line patrol module through I2C.
Experimental wiring
| Raspberry Pi | 8-channel line patrol module |
|---|---|
| SCL | SCL |
| SDA | SDA |
| 5v | 5v |
| GND | GND |
As shown in the figure:

Experimental steps and phenomena
After connecting the wires, run the script:
python3 IR_I2C.py
Experimental source code
xxxxxxxxxx#Reading Datawhile True: time.sleep(0.5) #500ms data = read_from_i2c(0x30) #print("i2cdata:"+str(data)) x1 = str((data>>7)&0x01) x2 = str((data>>6)&0x01) x3 = str((data>>5)&0x01) x4 = str((data>>4)&0x01) x5 = str((data>>3)&0x01) x6 = str((data>>2)&0x01) x7 = str((data>>1)&0x01) x8 = str((data>>0)&0x01) print("x1:"+x1+" x2:"+x2+" x3:"+x3+" x4:"+x4+" x5:"+x5+" x6:"+x6+" x7:"+x7+" x8:"+x8) The main function of the source code is very simple. It reads the probe pins of 8-way line patrol through I2C and prints them out.