Trying to connect both a BMP280 and a TMC2209 to an Arduino MEGA, can make them work separate but not together

Status
Not open for further replies.

wkinne

New Member
Title pretty much explains it. I can control a TMC2209 Stepper Motor controller or a BMP280 Barometric Pressure device, but when I hook both up to one MEGA if fails.
Help would be greatly appreciated.
The goal is to sample the barometric pressure, run a vacuum pump to bring the pressure down inside a vessel, then bring the pressure back to the sampled value and then run stepper motors with the TMC2209.


#include "SparkFunBME280.h"

//Stepper driver pin definitions
#define PIN_STEP_ENABLE 14
#define PIN_STEP1_DIRECTION 13
#define PIN_STEP1_STEP 12


BME280 mySensorA; //Uses default I2C address 0x77
BME280 mySensorB; //Uses I2C address 0x76 (jumper closed)

void setup()
{
//Configuer stepper driver pins as OUTPUTs
pinMode(PIN_STEP1_DIRECTION, OUTPUT);
pinMode(PIN_STEP1_STEP, OUTPUT);
pinMode(PIN_STEP_ENABLE, OUTPUT);

//ENABLE pin has to be pulled LOW for TMC2209
digitalWrite(PIN_STEP_ENABLE, LOW);

//Serial.begin(115200);

//Wire.begin();

mySensorA.setI2CAddress(0x76); //The default for the SparkFun Environmental Combo board is 0x77 (jumper open).
//If you close the jumper it is 0x76
//The I2C address must be set before .begin() otherwise the cal values will fail to load.

if(mySensorA.beginI2C() == false) Serial.println("Sensor A connect failed"); //if I remark out his line and the line like it for SensorB ( 2 lines down ) the stepper will run but I get no pressure //readings, I stopped getting pressure readings as soon as I added the code to operate the TMC2209

mySensorB.setI2CAddress(0x76); //Connect to a second sensor
if(mySensorB.beginI2C() == false) Serial.println("Sensor B connect failed");


Wire.begin();
Serial.begin(115200);

}

void loop()
{
//determine starting direction of Stepper
digitalWrite(PIN_STEP1_DIRECTION,HIGH);

// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 2000; x++) {
Serial.println(" Forword ");
digitalWrite(PIN_STEP1_STEP,HIGH);
delayMicroseconds(50);
digitalWrite(PIN_STEP1_STEP,LOW);
delayMicroseconds(50);
}
delay(1000); // One second delay

digitalWrite(PIN_STEP1_DIRECTION,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 2000; x++) {
Serial.println(" Reverse ");
digitalWrite(PIN_STEP1_STEP,HIGH);
delayMicroseconds(50);
digitalWrite(PIN_STEP1_STEP,LOW);
delayMicroseconds(50);
}
delay(1000);

Serial.print(" PressureA: ");
Serial.println(mySensorA.readFloatPressure(), 0);

//Serial.print(" PressureB: ");
//Serial.println(mySensorB.readFloatPressure(), 0);

Serial.println();

delay(500);
}
 
When you say "can't get them to work together" is that in software or hardware?

If you leave both connected, can you access either with different programs?

Mike.
Edit, reread you post - sounds like hardware problem - can you post a schematic?
 
I have made progress, the problem was I blew the BMP280 (BME280) and didn't realize it. I still have a long ways to go, but am getting closer.
Thanks all for your comments. It has been a while since I wrote code for an Arduino and will take a few more youtube videos to get me up to speed.
 
£1.33 each ?

Except that's probably the price from China (and takes 2-3 weeks to arrive) - ones sourced from the UK (and next day delivery) are much more expensive.

Personally I'd order multiple ones from China, and wait a couple of weeks.
 
Nope ! Your neck of the woods NG .. Overseal, South Derbyshire !

Never heard of it - and South Derbyshire isn't 'my neck of the woods'

We class South Derbyshire as 'southern softies' up here in North Derbyshire

However, I checked on https://wikishire.co.uk/map/#/centre=52.772,-1.196/zoom=10 and it says it's in Leicestershire?.

He's presumably buying them from China and selling them on - certainly his prices are pretty reasonable.
 
We class South Derbyshire as 'southern softies' up here in North Derbyshire

OIC, so you're a northern 'ardie, are you ? It's a good job you weren't around in Nelson's time !

If you look at the county boundary map, I guess it could depend on which side of the road you live on !

Either way, I've bought a few bits from this guy and never had an issue; as you say, he's probably buying from China and reselling, works for me !

MM
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…