Hello everyone,
I've read lots of threads on here, but I've never posted a question myself. I've always been able to find the answer to something from someone else's question. Or at least it would point me in the right direction. But this time I'm really stuck.
I have 7 photo-resistors in an array. And I would like to read their values to estimate the position of objects obstructing light falling on them.
I found using the analog inputs on the microcontrollers themselves it was too noisy. So I decided to use off board ADCs instead (two ADS1115s). The readings are super stable, so I'm very impressed with that. The problem is the speed of the I2C data. I'd like to run at 60 frames per second (which is a very smooth gaming frame rate). That's 16 bits x 7 sensors x 60 per second (6,720 bits/s). This is well below the I2C specification. But I'm getting about 15 measurements per second at best. Sometimes less that this, depending on the setup (please see below).
I was working with a Nano 33 IoT, but then wondered if the speed of the device would make a difference, so I tried it on an ESP32. Virtually no difference. I know there are pull up resistors on the device, but I decided to add my own (two 5K resistors). No difference what so ever. I know the recommendation is 3K3 with 3.3V, but if 5K didn't do anything I can't see 3K3 changing the world.
I then started to suspect the Adafruit_ADS1X15.h library, So I tried ADS1115_WE by Wolfgang Ewold instead. It took more code, but produced similar results.
I then started to suspect the Wire library that they are both dependant on. I read on a different post that the Wire library worked fine with the ATmega processors. So I dug out an old Uno and tried it on that. No difference.
I even considered if I should start modifying libraries, but that seems a bit drastic. Surely these are standards that thousands of builders are using all the time?
Any suggestions would be gratefully received. Especially if I'm doing something silly and I could solve it easily.
Thanks.
Measurement_firmware_code.ino (1.25 KB)
