Greetings MB community!
I started last night making the mods for my (IR version) starter tank. To the original configuration, I added a MeCompass, MeTFT and MeWifi. I also added the pan/tilt servo kit to give the ultrasonic sensor some flexibility.
I started out testing each piece by loading the test sketches from the examples. The only modifications I made to them were to change port numbers, if needed. The compass worked great in the test script, displaying to the serial monitor the heading with no issues.
I then copied the necessary lines to my sketch. Right away, instead of getting past the “initializing i2c devices…” line, it hangs right there. The first line in the sketch was the call to initialize the TFT. So, I tried commenting out that line. Runs perfect.
I’ve heard stories of other sensors messing up the compass, so I’ve mounted it high above the board. At the bottom of the mount, I do have the TFT. I tried disconnecting the TFT from power with no effect, as long as the call exists to initialize it, the compass will not return from the Compass.begin call. If I comment out the TFT initialization, the compass returns to working fine. Even if the power is left on to the TFT.
In short, if I comment out the line initializing the TFT, the compass initializes and begins to send headings (though obviously in this script, just once - in the example sketch, it continues to send and change as I rotate the bot) . If I leave the line in, the compass simply blinks the blue led. The serial monitor stops at the “initializing i2c devices…” line. Nothing continues.
So can the TFT and compass live together on the same bot? Is the fact that the TFT uses serial communication causing the issue? Any mods you all might see that allows them to work together?
Above setup():
MeSerial mySerial(PORT_3); //connects TFT to Port3
MeUltrasonicSensor ultraSensor(PORT_4); //connects ultrasonic sensor (on tilt/pan) to Port4
MeWifi wifi(PORT_5); //connects MeWifi to Port5
MePort ptPort(PORT_6); //connects MePort to Port6
Servo panservo; //create servo object to control pan servo
int16_t servo1pin = ptPort.pin1();//attaches pan servo to slot1
Servo tiltservo;
int16_t servo2pin = ptPort.pin2(); //attaches tilt servo to slot2
MeCompass Compass(PORT_8); //attaches the MeCompass to Port8
void setup()
{
Serial.begin(9600);
Serial.println(“Initializing I2C devices…”);
Compass.begin();
Serial.println(“Testing device connections…”);
Serial.println(Compass.testConnection() ? “HMC5883L connection successful” : “HMC5883L connection failed”);
GetCompassHdg(); //gets compass heading and prints to serial monitor
panservo.attach(servo1pin); // attaches the servo on servopin1
tiltservo.attach(servo2pin);
}