Don't Just Guess your I2C Pull-up Values

Measure and Calculate Them

This is a small Arduino UNO sketch we wrote for tinyLiDAR but I think it may have a wider appeal. Hope you find it useful. tinyLiDAR is basically an I2C slave sensor device that was designed to be paralleled for robotics applications, etc. There are 2 user replaceable I2C pull-up resistors on the corner of each board and hence users have the question - what values should we be using for these pull-ups? The sketch below should help answer this question. Typically designers end up using low default value resistors and/or values calculated from guesstimates of their bus capacitance. Our sketch actually measures the I2C bus wire capacitance and gives a decent recommendation for what resistor values to use. Higher values will help lower power dissipation in your design. To run it, you have to connect any two adjacent wires from your 4 wire I2C "bus" into the A0 and A4 pins on the UNO. The other side of this bus will not be connected to anything for the measurements. You then type in the number of tinyLiDAR boards you will be running in parallel and press ENTER. The sketch will then measure the capacitance of your wiring and suggest pull-up resistor values based on the number of boards you will be using. You can use this code with any I2C device, of course, since it only measures the capacitance of your passive wiring. Just set the variable "tinyLiDAR_capacitance" to zero when doing this. No extra hardware is required to run this sketch. The theory of operation is summarized in the comments section. fyi - tinyLiDAR is a gereral purpose laser distance sensor board that we have currently in a crowdfunding campaign. The board simplifies access to the VL53L0X chip and gives better performance than a software only approach. Enjoy the sketch and be sure to check out our campaign soon on Indiegogo if you like this kind of stuff.