I've been trying to bring my projects up to date with respect to using #include <Wire.h> vs #include <i2c_t3.h>. I thought I had everything completely worked out, but after converting my project from i2c_t3.h to Wire.h, it won't compile and produces errors like the following
Here's the relevant portions of the code (I've attached the entire program as a ZIP file)
After thinking about this for a while, it occurred to me that I may been using the #include<i2c_t3.h> style up to now, and maybe the #include <Wire.h> style doesn't incorporate the above identifiers. If this is so, how do you initialize Wire, Wire1, & Wire2?
I created a very short test program, as follows:
With #include <i2c_t3.h> style, I get the expected Wire.begin() style where I can use the 'I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT' identifiers. However, if I switch to the #include <Wire.h> style, the only parameter available for the Wire.begin() call is the target address. I looked for other Wire member functions using VS2022's 'auto-complete' feature, but didn't find anything useful.
I tried looking for examples using #include <Wire.h> for multiple I2C busses, but the examples included in the \teensy\avr\libraries\Wire\ tree are just the default single-bus ones that everyone has.
Am I on the right track thinking the 'I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT' stuff is all i2c_t3.h specific? If so, can anyone point me to some multiple bus examples using #include <Wire.h>?
TIA,
Frank
Code:
T35_WallE3_V5.ino: 603:48: error: 'I2C_PULLUP_EXT' was not declared in this scope
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT); \\MPU6050,IR_DET. MPU6050 has 4.7K pullups
Here's the relevant portions of the code (I've attached the entire program as a ZIP file)
Code:
#pragma region INCLUDES
#include <Wire.h>
#include "FlashTxx.h" // TLC/T3x/T4x flash primitives
#include <elapsedMillis.h>
//#include "MPU6050_6Axis_MotionApps_V6_12.h" //changed to this version 10/05/19
//#include "MPU6050_6Axis_MotionApps_V6_12.h" //01/18/22 changed to use the \I2CDevLib\Arduino\MPU6050\ version
#include "MPU6050_6Axis_MotionApps612.h" //01/18/22 changed to use the \I2CDevLib\Arduino\MPU6050\ version
#include "I2Cdev.h" //02/19/19: this includes SBWire.h
#include "I2C_Anything.h" //needed for sending float data over I2C
#include "I2C_Anything1.h" //01/16/22 added for Wire1 bus
#include <PID_v2.h> //new version 05/16/21
#include "timelib.h" //added 01/01/22 for charge monitoring support
#include "TeePrint.h" //added 01/04/22 to print to both ports in one line
#pragma endregion Includes
void setup()
{
#pragma region PIN INITIALIZATION
//init ALL pins to OUTPUT_LOW, then change as necessary
//01/08/22 - THIS MUST BE FIRST STEP IN SETUP() (ask me how i know!)
//InitAllPins();
pinMode(LED_BUILTIN, OUTPUT);
#pragma region Teensy VL53L0X Array Init
//11/15/20 force VL53L0X Teensy to reset whenever main controller does
pinMode(VL53L0X_TEENSY_RESET_PIN, OUTPUT);
digitalWrite(VL53L0X_TEENSY_RESET_PIN, LOW);
delay(50);
digitalWrite(VL53L0X_TEENSY_RESET_PIN, HIGH);
#pragma endregion Teensy VL53L0X Array Init
#pragma region Second Deck Pins
pinMode(RED_LASER_DIODE_PIN, OUTPUT);
pinMode(LIDAR_MODE_PIN, INPUT);
pinMode(VL53L0X_TEENSY_RESET_PIN, OUTPUT);
#pragma endregion Second Deck Pins
#pragma region Charge_Support_Pins
//current sensor pins
pinMode(RUN_CURR_PIN, INPUT); //02/24/19 now connected to 'Run Current' 1NA619 charge current sensor
digitalWrite(RUN_CURR_PIN, LOW); //turn off the internal pullup resistor
pinMode(TOT_CURR_PIN, INPUT);//02/24/19 now connected to 'Total Current' 1NA619 charge current sensor
digitalWrite(TOT_CURR_PIN, LOW); //turn off the internal pullup resistor
//Battery Voltage Monitor pin
pinMode(BATT_MON_PIN, INPUT);
digitalWrite(BATT_MON_PIN, LOW); //turn off the internal pullup resistor
//charge connect
pinMode(CHG_CONNECT_PIN, INPUT_PULLUP); //goes LOW when chg cable connected
digitalWrite(CHG_CONNECT_PIN, HIGH); //01/09/22 needed now that InitAllPins() forces it LOW
//charge connect status display pin (this will eventually be one of the LEDs on the rear LED panel)
pinMode(CHG_CONNECT_LED_PIN, OUTPUT); //12/16/20 lights LED when chg cable connected
digitalWrite(CHG_CONNECT_LED_PIN, HIGH); //01/09/22 needed now that InitAllPins() forces it LOW
//Charge status LED en/dis pins
pinMode(_60PCT_LED_PIN, OUTPUT);
pinMode(FIN_LED_PIN, OUTPUT);
pinMode(_80PCT_LED_PIN, OUTPUT);
pinMode(_40PCT_LED_PIN, OUTPUT);
pinMode(_20PCT_LED_PIN, OUTPUT);
#pragma endregion Charge_Support_Pins
#pragma region Motor_Pins
//motor pins
pinMode(InA_Left, OUTPUT);
pinMode(InB_Left, OUTPUT);
pinMode(Spd_Left, OUTPUT);
pinMode(InA_Right, OUTPUT);
pinMode(InB_Right, OUTPUT);
pinMode(Spd_Right, OUTPUT);
#pragma endregion Motor_Pins
#pragma endregion PIN INITIALIZATION
#pragma region SERIAL_PORTS
Serial.begin(115200);
delay(2000); //10/06/21 - just use fixed delay instead
Serial1.begin(115200); //used HC-05 'AT' commands to set this speed
delay(2000); //11/20/21 use fixed delay instead of waiting
//I2C bus
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT); //MPU6050,IR_DET. MPU6050 has 4.7K pullups
Wire1.begin(I2C_MASTER, 0x00, I2C_PINS_37_38, I2C_PULLUP_EXT, 400000);//VL53L0X Array
...
...
...
After thinking about this for a while, it occurred to me that I may been using the #include<i2c_t3.h> style up to now, and maybe the #include <Wire.h> style doesn't incorporate the above identifiers. If this is so, how do you initialize Wire, Wire1, & Wire2?
I created a very short test program, as follows:
Code:
/*
Name: T35_WireTest.ino
Created: 1/18/2022 7:09:09 PM
Author: NEWXPS15\paynt
*/
//#include <i2c_t3.h>
#include <Wire.h>
void setup()
{
Wire.begin();
Wire1.begin();
}
void loop()
{
}
With #include <i2c_t3.h> style, I get the expected Wire.begin() style where I can use the 'I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT' identifiers. However, if I switch to the #include <Wire.h> style, the only parameter available for the Wire.begin() call is the target address. I looked for other Wire member functions using VS2022's 'auto-complete' feature, but didn't find anything useful.
I tried looking for examples using #include <Wire.h> for multiple I2C busses, but the examples included in the \teensy\avr\libraries\Wire\ tree are just the default single-bus ones that everyone has.
Am I on the right track thinking the 'I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT' stuff is all i2c_t3.h specific? If so, can anyone point me to some multiple bus examples using #include <Wire.h>?
TIA,
Frank