Hi All,
I am hoping for some guidance, I have been trying to get two ADS1115 modules working on the 2nd I2C bus of a Teensy 3.1 and am running out of talent and I can't find any tutorials!
I have tried the Adafruit libary and got it working on a breadboard with one ADC on default wire.h with I2C0, but this I cannot get going on the 2nd I2c bus. I believe this is because the standard wire lib only works on SCL0/SDA0
Moving on from that I have tried the i2cdevlib/Arduino/ADS1115 which seems a better lib and has features I would like to use but again does not seem to let me use the 2nd bus. Using the I2C_t3 lib I think is the answer
but do not know how to get there. I am trying to use the wire1 as wire0 will be used for coms to another Teensy 3.1, basically offloading processing time onto a secondary MCU to allow the main MCU to do other things.
I found this, https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/I2Cdev/I2Cdev.h seems to say added support i2c_t3 for Teensy3.1, but the comment is, Don't do anything special for Teensy, just use regular Arduino Wire lib, I don't understand this! I tried looking in the ADS1115.h & I2Cdev.h file to see if i can force it to use i2c_t3 but could not work it out also I felt like I was in very deep water! so I ask you guys as I am rather stuck here
Apologies for the code it is not cleaned up or working! I'm using Arduino IDE 1.6.9
[ CODE]
/*
* trying to use i2cdevlib & i2c_t3
https://github.com/nox771/i2c_t3/blob/master/README.md //Teensy I2C libary
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
0x00 = CPU 2 master (to coms with ADC's)
0x48 = ADC 1
0x4B = ADC 2
0x66 = CPU 2 slave (to coms with CPU 1)
*/
//#include <i2c_t3.h>
#include <ADS1115.h>
ADS1115 adc0(ADS1115_DEFAULT_ADDRESS); // construct an ads1115 instance (adc1, at address 0x49)
ADS1115 adc1(ADS1115_ADDRESS_ADDR_SCL); // construct an ads1115 instance (adc2, at address 0x49)
long 1Pressure=0;
long 2Pressure=0;
long 3Pressure=0;
long 4Pressure=0;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ADC 1115");
//Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
//Wire.begin();
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, 400000);
//Wire.begin(I2C_SLAVE, 0x66, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
//Wire.setDefaultTimeout(200000); // 200ms
adc0.initialize(); // initialize ADS1115 16 bit A/D chip
adc1.initialize(); // initialize ADS1115 16 bit A/D chip
Serial.println("Testing adc0..");
Serial.println(adc0.testConnection() ? "adc0 connection successful" : "adc0 connection failed");
Serial.println("Testing adc1..");
Serial.println(adc1.testConnection() ? "adc1 connection successful" : "adc1 connection failed");
//adc0.showConfigRegister(); //turn on the SERIAL_DEBUG in the ADS1115.h file
//adc1.showConfigRegister(); //turn on the SERIAL_DEBUG in the ADS1115.h file
adc0.setRate(ADS1115_RATE_860); //sample rate
adc1.setRate(ADS1115_RATE_860); //sample rate
adc0.setMode(ADS1115_MODE_CONTINUOUS); //do continuous sampling
adc1.setMode(ADS1115_MODE_CONTINUOUS); //do continuous sampling
adc0.setGain(ADS1115_PGA_0P256); //Set the gain (PGA) +/- 0.256v, 16x gain
adc1.setGain(ADS1115_PGA_0P256); //Set the gain (PGA) +/- 0.256v, 16x gain
}
void loop() {
1Pressure=adc0.getConversionP0N1(); //sets the mux and gets a reading.
2Pressure=adc0.getConversionP2N3(); //sets the mux and gets a reading.
3Pressure=adc1.getConversionP0N1(); //sets the mux and gets a reading.
4Pressure=adc1.getConversionP2N3(); //sets the mux and gets a reading.
Serial.print("1 = "); Serial.println(1Pressure);
Serial.print("2 = "); Serial.println(2Pressure);
Serial.print("3 = "); Serial.println(3Pressure);
Serial.print("4 = "); Serial.println(4Pressure);
Serial.println();
delay(500);
}
[ /CODE]
Error is:
Teensy_ADC_pressure_sensor_test_V05:33: error: 'I2C_MASTER' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, 400000);
This tells me the i2c_t3 is not being used and wire.h does not like the commands
Any help would be appreciated
I am hoping for some guidance, I have been trying to get two ADS1115 modules working on the 2nd I2C bus of a Teensy 3.1 and am running out of talent and I can't find any tutorials!
I have tried the Adafruit libary and got it working on a breadboard with one ADC on default wire.h with I2C0, but this I cannot get going on the 2nd I2c bus. I believe this is because the standard wire lib only works on SCL0/SDA0
Moving on from that I have tried the i2cdevlib/Arduino/ADS1115 which seems a better lib and has features I would like to use but again does not seem to let me use the 2nd bus. Using the I2C_t3 lib I think is the answer
but do not know how to get there. I am trying to use the wire1 as wire0 will be used for coms to another Teensy 3.1, basically offloading processing time onto a secondary MCU to allow the main MCU to do other things.
I found this, https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/I2Cdev/I2Cdev.h seems to say added support i2c_t3 for Teensy3.1, but the comment is, Don't do anything special for Teensy, just use regular Arduino Wire lib, I don't understand this! I tried looking in the ADS1115.h & I2Cdev.h file to see if i can force it to use i2c_t3 but could not work it out also I felt like I was in very deep water! so I ask you guys as I am rather stuck here
Apologies for the code it is not cleaned up or working! I'm using Arduino IDE 1.6.9
[ CODE]
/*
* trying to use i2cdevlib & i2c_t3
https://github.com/nox771/i2c_t3/blob/master/README.md //Teensy I2C libary
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
0x00 = CPU 2 master (to coms with ADC's)
0x48 = ADC 1
0x4B = ADC 2
0x66 = CPU 2 slave (to coms with CPU 1)
*/
//#include <i2c_t3.h>
#include <ADS1115.h>
ADS1115 adc0(ADS1115_DEFAULT_ADDRESS); // construct an ads1115 instance (adc1, at address 0x49)
ADS1115 adc1(ADS1115_ADDRESS_ADDR_SCL); // construct an ads1115 instance (adc2, at address 0x49)
long 1Pressure=0;
long 2Pressure=0;
long 3Pressure=0;
long 4Pressure=0;
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("ADC 1115");
//Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
//Wire.begin();
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, 400000);
//Wire.begin(I2C_SLAVE, 0x66, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
//Wire.setDefaultTimeout(200000); // 200ms
adc0.initialize(); // initialize ADS1115 16 bit A/D chip
adc1.initialize(); // initialize ADS1115 16 bit A/D chip
Serial.println("Testing adc0..");
Serial.println(adc0.testConnection() ? "adc0 connection successful" : "adc0 connection failed");
Serial.println("Testing adc1..");
Serial.println(adc1.testConnection() ? "adc1 connection successful" : "adc1 connection failed");
//adc0.showConfigRegister(); //turn on the SERIAL_DEBUG in the ADS1115.h file
//adc1.showConfigRegister(); //turn on the SERIAL_DEBUG in the ADS1115.h file
adc0.setRate(ADS1115_RATE_860); //sample rate
adc1.setRate(ADS1115_RATE_860); //sample rate
adc0.setMode(ADS1115_MODE_CONTINUOUS); //do continuous sampling
adc1.setMode(ADS1115_MODE_CONTINUOUS); //do continuous sampling
adc0.setGain(ADS1115_PGA_0P256); //Set the gain (PGA) +/- 0.256v, 16x gain
adc1.setGain(ADS1115_PGA_0P256); //Set the gain (PGA) +/- 0.256v, 16x gain
}
void loop() {
1Pressure=adc0.getConversionP0N1(); //sets the mux and gets a reading.
2Pressure=adc0.getConversionP2N3(); //sets the mux and gets a reading.
3Pressure=adc1.getConversionP0N1(); //sets the mux and gets a reading.
4Pressure=adc1.getConversionP2N3(); //sets the mux and gets a reading.
Serial.print("1 = "); Serial.println(1Pressure);
Serial.print("2 = "); Serial.println(2Pressure);
Serial.print("3 = "); Serial.println(3Pressure);
Serial.print("4 = "); Serial.println(4Pressure);
Serial.println();
delay(500);
}
[ /CODE]
Error is:
Teensy_ADC_pressure_sensor_test_V05:33: error: 'I2C_MASTER' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_29_30, I2C_PULLUP_INT, 400000);
This tells me the i2c_t3 is not being used and wire.h does not like the commands
Any help would be appreciated