Reading Data
After configuring the sensor via I2C, the pins will retain the stored output mode in the next power cycle. You can then disconnect the sensor from the I2C port and connect it to the appropriate port type based on your configuration. The process for reading data from the control or expansion hub in the new mode is outlined below.
Digital Reads
In the configuration screen, go to "Digital Devices," select "Digital Device," and name your digital pins. After activating the config, the following code can be used to read the digital values:
Analog Reads
In the configuration screen, go to "Analog Inputs," select "Analog Input," and name your analog pin. After activating the config, the following code can be used to read the analog value:
Scaling Analog Voltage
The voltage from analog reads will always be in the range 0-3.3, but we can turn this into a useful form by scaling it to represent our data.
HSV Hue Value
Distance in mm
Bulk Reading
Individual digital/analog port reads still take time, but by utilizing bulk reads one can read every single non-i2c port on a hub in only 3-4ms. Here is the gm0 page on implementing bulk reads: https://gm0.org/en/latest/docs/software/tutorials/bulk-reads.html
Last updated