45 fprintf(stderr,
"Unable to open I2C bus: %s\n", strerror(errno));
49 const float cfact = 7.88842;
51 opts.
pga = ADS1015_CONFIG_PGA_4096MV;
54 float ch0 =
i2c_ads1015_read_mux(handle, ADS1015_ADDR_DEFAULT, ADS1015_CONFIG_MUX_SINGLE_0, &opts);
55 float ch1 =
i2c_ads1015_read_mux(handle, ADS1015_ADDR_DEFAULT, ADS1015_CONFIG_MUX_SINGLE_1, &opts) * cfact;
56 float ch2 =
i2c_ads1015_read_mux(handle, ADS1015_ADDR_DEFAULT, ADS1015_CONFIG_MUX_SINGLE_2, &opts) * cfact;
57 float ch3 =
i2c_ads1015_read_mux(handle, ADS1015_ADDR_DEFAULT, ADS1015_CONFIG_MUX_SINGLE_3, &opts) * cfact;
63 fprintf(stdout,
"Single shot conversion on all mux options:\n");
65 fprintf(stdout,
"Channel 0:\t%+.3f mV\n", ch0);
66 fprintf(stdout,
"Channel 1:\t%+.3f mV\n", ch1);
67 fprintf(stdout,
"Channel 2:\t%+.3f mV\n", ch2);
68 fprintf(stdout,
"Channel 3:\t%+.3f mV\n", ch3);
70 fprintf(stdout,
"Ch1 - Ch3:\t%+.3f mV\n", delta_1_3);
71 fprintf(stdout,
"Ch2 - Ch3:\t%+.3f mV\n", delta_2_3);
int i2c_openConnection(const char *bus)
Set up a connection to the specified bus.
void i2c_closeConnection(int handle)
Close existing connection.
float i2c_ads1015_read_mux(const int busHandle, const int devAddr, const uint16_t mux, const i2c_ads1015_options *opts)
Generic ADS1015 read function.
float i2c_ads1015_read_diff_ch2_ch3(const int busHandle, const int devAddr, const void *opts)
Get differential voltage measurement between channels 2 and 3.
float i2c_ads1015_read_diff_ch1_ch3(const int busHandle, const int devAddr, const void *opts)
Get differential voltage measurement between channels 1 and 3.