I'm trying to detect air bubbles in water pipes and want to use an FDC2114 Capacitive Sensor. For my project I need to get at least 6000 SPS out of the FDC. I tried to use an Arduino Mini Pro 3,3V as well as an Raspberry Pi B+, but I never get close to this point, even if the theoretical maximum of the chip is 13,3kSPS.
I use 4,7kOhm Pullups and clock frequency is set to 400kHz.
On the Raspberry, I measured the time which passed while filling an list of 10.000 Samples: 8361704µs/10.000Samples --> 836µs/Sample --> 1196 SPS
Measuring the time with time.time() results in the given 8361704µs, while time.clock() results in 1379672µs, which means that the CPU is waiting for apprx. 7 seconds. htop is also showing process status D.
strace writes ioctl(3, _IOC(0, 0x07, 0x20, 0x00), 0xbeacaa8c) = 0, which seems to be the key why the communication is that slow, but I don't have a clue how to interpret these lines. Why is the Communication that slow, espeacially on the Raspberry which should have enough power to receive this amount of data?
#! /usr/bin/env python3 import smbus import time #I2C-Adress and Register of FDC2114 address = 0x2a DATA3 = 0x06 #Open I2C-Bus FDC = smbus.SMBus(1) end_time1 = time.time() start_time1 = time.time() #Configuration of FDC2114 FDC.write_i2c_block_data(address, 0x0B, [0x00, 0x64]) #RCOUNT_CH3, See Table 20 (Data sheet) FDC.write_i2c_block_data(address, 0x13, [0x00, 0x32]) #SETTLECOUNT_CH3, See Table 28 (Data sheet) FDC.write_i2c_block_data(address, 0x17, [0x10, 0x01]) #CLOCK_DIVIDERS_CH3, See Table 32 (Data sheet) FDC.write_i2c_block_data(address, 0x19, [0x38, 0x00]) #ERROR_CONFIG, See Table 37 (Data sheet) FDC.write_i2c_block_data(address, 0x1B, [0x02, 0x0D]) #MUX_CONFIG, See Table 39 (Data sheet) FDC.write_i2c_block_data(address, 0x21, [0x60, 0x00]) #DRIVE_CURRENT_CH3, See Table 41 (Data sheet) FDC.write_i2c_block_data(address, 0x1A, [0xD6, 0x81]) #CONFIG, See Table 38 (Data sheet), MUST be written LAST #Function for reading Register def readData(reg): data =  for i in range(10000): read = FDC.read_i2c_block_data(address, reg, 2) data.append(read & 15) data[i] = data[i] << 8 data[i] += read return data #Read and print Register, Time Measurement while True: timedelta1 = end_time1 - start_time1 start_time1 = time.time() start_time = time.time() print(readData(DATA3)) end_time = time.time() timedelta = end_time - start_time print(timedelta) print(timedelta1) end_time1 = time.time()