I2C

There are two i2c buses on ScrachLink, i2c bus 0 and i2c bus 1.

Default:  scan all enabled i2c busses and print the config.

i2c;

Example Results: 

{i2c:0,id:[82]}{i2c:1}

i2c config info

Command Syntax:

i2c config info;

Purpose: Reports i2c bus configuration.

Example Report:

{i2c:0,enabled:1,sda:21,scl:22,speed:400000}
{i2c:1,enabled:0,sda:12,scl:13,speed:400000}

i2c config set

Command Syntax: “[ ]” means optional argument and “|” means OR 

i2c[0|1] config set [SDA SCL Speed];

Purpose:  set the i2c bus serial data and serial clock lines to specified esp32 pins at the specified clock speed.

Default: sets i2c bus 0 to sda 21 scl 22 speed 400k AND i2c bus 1 to sda 12 scl 13 speed 400k

Example 1:  set both i2c busses to defaults.

i2c config set;

Example 2:  set i2c bus 1 sda 12 scl 13 speed 400k AND set i2c bus 0 to sda 21 scl 22 speed 100k.

i2c1 config set 14 13 400000;
i2c0 config set 21 22 100000;

i2c config enable

Command Syntax:  “[ ]” means optional argument and “|” means OR 

i2c[0|1] config enable [yes|no];

Purpose:  enable or disable i2c buses

Default i2c bus: both buses.

Default enable: yes.

Example 1:  Enable both i2c bus 1 and i2c bus 2.

i2c config enable;

Example 2:  Turn off both i2c buses.

i2c config enable no;

Example 3:  Turn off i2c bus 1 and enable i2c bus 0.

i2c1 config enable no;
i2c0 config enable yes;

i2c scan

Command Syntax:  “[ ]” means optional argument and “|” means OR 

i2c[0|1] scan;

Purpose: Report what devices are visible to ScratchLink on i2c buses.

Default:  Scan both buses and report i2c config.

Example 1: Scan both buses for devices and report.

i2c scan;

Example 2: Report devices visible on i2c bus 1.

i2c1 scan;