I^2C and differing project Arduino boards

Hi Guys,

I am perplexed all probably due to ignorance however I will explain my conundrum and hope that there is a simple remedy in my inability to run I2C on a number of Arduino Boards. The program in question which I believe to be an aside, is that of a BMP180 sketch

I can get just one of my boards to work using its I2C (I^2C) pinouts/ports,
they are listed below in:
Quantity; IDE; Manufacturer/Seller; Pin Numbers(if necessary); I2C pins used:

Working:
1No. Arduino - Arduino ATMega2560 using pinouts 20-21

I can not get to work:
2No. Arduino - BangGood 32 pin Uno using pin-outs 18 - 19 (A4 - A5)
1No. Arduino - Don't know 28 pin Uno using pin-outs 18 - 19 (A4 - A5)
2No. Arduino - BangGood Duemilinove using pin-outs 18 - 19 (A4 - A5) Brilliant every day development Bd; usually programmed into a MiniPro for production.
2No. Arduino - Amazon Pro-Mini AT328 using pin-outs unnumbered (A4 - A5) [using two LH., pad/ports above those depicted on the outer edges]
2No. Arduino - ChilliTronix Pro-Mini AT328 using pin-outs unnumbered (A4 - A5) [using two LH., pad/ports above those depicted on the outer edges]

Hope you can help, possible sardonic reference to my suppliers, if necessary, will be honorably recognised.

All the above boards run exactly to their schemas in for example a simple blink program I wrote myself to simulate the Morse Flashing of V for victory built as a differ to simple blink in order to recognise correct loading.

The only differ in programming and running comes with the MinPro boards which are programmed by
way of an independent CH430 programmer. I have tried to include all information thought necessary but I know there will be something missing, if so please ask.

ChrisPSR

Tried using digital pins instead of analog?

I have no idea...but worth a try as the only one that has worked for you seems to be on digital pins?

Check that you haven't got scl and sda reversed - Also, check that the i2c lines are at Vcc when idle.

I'd also try adding external pullups, if other methods don't work...

Johnny010:
Tried using digital pins instead of analog?

I have no idea...but worth a try as the only one that has worked for you seems to be on digital pins?

As I understand it the I2C method of transmission uses particular dedicated pins however I stand to be corrected. Those for the ATMega 2560 are specified by Arduino as pins 20 & 21

Thanks so far,
Chris S.

ChrisPSR:
As I understand it thed pinse I2C method of transmission uses particular dedicated pins however I stand to be corrected.

Thanks so far,
Chris S.

Nope, you're right, there is only one set of pins that can be used for I2C. On Uno-style boards where there's a separate pair of them, they're connected to A4/A5. I think Johnny010 was confused.

DrAzzy:
Check that you haven't got scl and sda reversed - Also, check that the i2c lines are at Vcc when idle.

I'd also try adding external pullups, if other methods don't work...

Are you saying the the two cables when in quiescence provide Vcc or one provides Vcc while the other provides 0V, if so can you please say which is what?, thanks. I have seen impedance refuted by notable authorities elsewhere and as I'm using 3.3V after programming at 5V, I see little use for protection. However once again if a definitive opinion can be provided, I'll take it

ChrisPSR

When the system is on, but not trying to use I2C, if you measure the voltage on either of the I2C data lines (SCL, SDA), they should be at Vcc (thanks to the pullup resistors). If they are not, that indicates that either there's a problem with the pullups, or one of the devices is holding one of these lines low (as they will sometimes do in event of certain error conditions, depending on the device).

I have seen impedance refuted by notable authorities elsewhere and as I'm using 3.3V after programming at 5V, I see little use for protection

Not a clue what you're talking about? Missing context? Wrong words?

DrAzzy:
When the system is on, but not trying to use I2C, if you measure the voltage on either of the I2C data lines (SCL, SDA), they should be at Vcc (thanks to the pullup resistors). If they are not, that indicates that either there's a problem with the pullups, or one of the devices is holding one of these lines low (as they will sometimes do in event of certain error conditions, depending on the device).

Not a clue what you're talking about? Missing context? Wrong words?

Presumably you refer to the following to which I further explain in red where I think you may have referred to:
I have seen impedance (resistance) refuted (there use negated) by notable authorities elsewhere (on Arduino Forums) and as I'm using (outputting) 3.3V after programming at 5V, I see little use for protection (by resistance).

The vaultage on each Duemilinove AT328 pin is as follows:
In quiescence:
SDA A4 4.821V
SCL A5 0.320V

Program running but measurements are taken after being halted by program stating "BMP180 init fail"
SDA A4 4.810V
SCL A5 0.301V
The program halts so quickly after being halted that there is absolutely no time in which to take measurements while the program runs. Apologies.

I sincerely apologise for the English used. It is not my best topic.

Hope you can help

The clock line is held low, it'll never work like that. But why is the clock line low?

Make a sketch that just does Wire.begin() and doesn't try to do any communication, and see if SCL still stays low, or whether it gets unhappy and holds SCL low only when you try to talk to it.

I've actually seen BMP180s (in one of those cheap modules) running off 3.3v ground the clock line like that, though; I've never figured out why. It would consistently work on the desk, 100% of the time with all 4 BMP180's I used, but when I put everything together, it'd hold the clock line low as soon as I tried to talk to it. I was never able to figure out exactly what was making it break.

Hi,
You have got the gnds of the arduino and the BMP180 connected.

What BMP180 board do you have?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Its strange that it doesn't work on UNO and clones yet does on mega.

Tom..... :slight_smile:

Tom,

Not used to doing this so I hope I get it right.

Program

</********* Title: Barometer.ino **********/
/*Working with: Arduino Mega

  • Author: including #inclusive's Bosch Sensortec
  • & modified by HCS
  • Date: 16th October 2015
  • This Program is held in my "Sketchbook"
  • The DHT Program is held in "Libraries".
  • The FULL program will be in "Sketchbook"
  • using Barometer as the Principal Title
  • Pins will be Barometer A4&5. DHT21 using A2
  • The principle program is to be bare boned to basics.
  • Included will be dusk to dawn Intruder lighting.
  • driven by a SH300.
    */

#include <SFE_BMP180.h>
#include <Wire.h>

// You will need to create an SFE_BMP180 object, here called "pressure":

SFE_BMP180 pressure;

#define ALTITUDE 38.0 /* Altitude of 39, Sandacre Road
Manchester, England,UK. In m's*/
void setup()
{
Serial.begin(9600);
Serial.println("REBOOT");

// Initialize the sensor (it is important to get calibration values stored on the device).

if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.

Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever.
}
}

void loop()
{
char status;
double T,P,p0,a;

// Loop here getting pressure readings every 10 seconds.

// If you want sea-level-compensated pressure, as used in weather reports,
// you will need to know the altitude at which your measurements are taken.
// We're using a constant called ALTITUDE in this sketch:

Serial.println();
Serial.print("Provided altitude = ");
Serial.print(ALTITUDE,0);
Serial.print(" meters, ");
Serial.print(ALTITUDE*3.28084,0);
Serial.println(" feet");

// This measures altitude, and not pressure, you will instead need
// So provide a known baseline pressure. This is shown at the end of the sketch.

// Scipts state: You must first get a temperature measurement to perform a pressure reading.

// So start a temperature measurement:
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed temperature measurement:
// Note that the measurement is stored in the variable T.
// Function returns 1 if successful, 0 if failure.

status = pressure.getTemperature(T);
if (status != 0)
{
// Print out the measurement:
Serial.print("temperature: ");
Serial.print(T,2);
Serial.print(" deg C, ");
Serial.print((9.0/5.0)*T+32.0,2);
Serial.println(" deg F");

// Start a pressure measurement:
// The parameter is the oversampling setting, from 0 to 3 (highest res, longest wait).
// If request is successful, the number of ms to wait is returned.
// If request is unsuccessful, 0 is returned.

status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

// Retrieve the completed pressure measurement:
// Note that the measurement is stored in the variable P.
// Note also that the function requires the previous temperature measurement (T).
// (If temperature is stable, you can do one temperature measurement for a number of pressure measurements.)
// Function returns 1 if successful, 0 if failure.

status = pressure.getPressure(P,T);
if (status != 0)
{
// Print out the measurement:
Serial.print("absolute pressure: ");
Serial.print(P,2);
Serial.print(" mb, ");
Serial.print(P*0.0295333727,2);
Serial.println(" inHg");

// The pressure sensor returns abolute pressure, which varies with altitude.
// To remove the effects of altitude, use the sealevel function and your current altitude.
// This number is commonly used in weather reports.
// Parameters: P = absolute pressure in mb, ALTITUDE = current altitude in m.
// Result: p0 = sea-level compensated pressure in mb

// I'm at 38 meters above sea level so:
p0 = pressure.sealevel(P,ALTITUDE);
Serial.print("relative (sea-level) pressure: ");
Serial.print(p0,2);
Serial.print(" mb, ");
Serial.print(p0*0.0295333727,2);
Serial.println(" inHg");

// On the other hand, if you want to determine your altitude from the pressure reading,
// use the altitude function along with a baseline pressure (sea-level or other).
// Parameters: P = absolute pressure in mb, p0 = baseline pressure in mb.
// Result: a = altitude in m.

a = pressure.altitude(P,p0);
Serial.print("Computed altitude: ");
Serial.print(a,0);
Serial.print(" meters, ");
Serial.print(a*3.28084,0);
Serial.println(" feet");
}
else Serial.println("Error retrieving pressure measurement\n");
}
else Serial.println("Error starting pressure measurement\n");
}
else Serial.println("Error retrieving temperature measurement\n");
}
else Serial.println("Error starting temperature measurement\n");

delay(5000); // Pause for 5 seconds.

}

ChrisPSR

On the one that is working on, fi you have it powered of 3.3v or 5?

Which breakout board are you using? There are several designs

The program halts so quickly after being halted that there is absolutely no time in which to take measurements while the program runs. Apologies.

  1. Add some Serial.print("STOP HERE");for(;;); ( translation for this stupid editor for( semicolon semicolon) semicolon ) to force the program to halt where YOU want it to halt so you can see how far the code actually does something (useful) before it halts in unknown place.
  2. Check your I2C device HARDWARE address - it may be defaulted / hidden in pressure.begin() - I did not see it in code.
  3. Your SPI / I2C MUST have pullups depending on PHYSICAL makeup of the bus, not just "let's try this value ".
    Keep in mind that SOME SPI /I2C devices HAVE pullups build in.
    If you have X devices on the bus, all with pullups , you have to adjust for that - remove ( if possible ) some.
  4. Invest few "quids" (?) on I2C LCD and you have a way to easy verify operation of your I2C bus.
  5. MOST I2C devices do not care about 3.3V or 5V . They will tolerate / work OK with either supply, but when in doubt , verify the spec for sure.

Good luck.

Vaclav:
2. Check your I2C device HARDWARE address - it may be defaulted / hidden in pressure.begin() - I did not see it in code.
3. Your SPI / I2C MUST have pullups depending on PHYSICAL makeup of the bus, not just "let's try this value ".
Keep in mind that SOME SPI /I2C devices HAVE pullups build in.
If you have X devices on the bus, all with pullups , you have to adjust for that - remove ( if possible ) some.

  1. BMP180/085 don't have alt-address, so it's appropriate for the libraries to hardcode that.
  2. SPI does not need pullups, only I2C. Most breakout boards have a pair of 10k pullups; the exact value is not critical (1k~10k overall resistance between SDA/SCL and Vcc), and modules typically use 10k because that's unlikely to cause problems when you put several devices onto the bus, but enough for it to work. Running at higher bus speeds, or with lots of devices or long wires, the pullup values get more important.

Vaclav, [nobbc] will allow you to type a for(;;); loop correctly. Note that this tag must be closed properly. It won't automatically add [/nobbc] like it will with other tags.:wink:

Hi,
What are the pinouts of the pcb?
Do the specs say that it will be okay on 5V?

Tom......... :slight_smile:

MorganS:
Vaclav, [nobbc] will allow you to type a for(;;); loop correctly. Note that this tag must be closed properly. It won't automatically add [/nobbc] like it will with other tags.:wink:

Can you tell me where I add this option?
Thanks

Vaclav:
Can you tell me where I add this option?
Thanks

In your previous post, where you complain about the editor. Edit it to add the tags and it will take away that smiley where you wrote semicolon-closebracket.

MorganS:
In your previous post, where you complain about the editor. Edit it to add the

 tags and it will take away that smiley where you wrote semicolon-closebracket.

[/quote]
O yea, as long as I know WHERE to add the tags and have no clue what the nobbs stands for , I'll be fine.
I'll do anything to improve the editor , after all , I am a consumer and it is expected from me .
It would be silly for "team Arduino" to do that.

DrAzzy:
2) BMP180/085 don't have alt-address, so it's appropriate for the libraries to hardcode that.
3) SPI does not need pullups, only I2C. Most breakout boards have a pair of 10k pullups; the exact value is not critical (1k~10k overall resistance between SDA/SCL and Vcc), and modules typically use 10k because that's unlikely to cause problems when you put several devices onto the bus, but enough for it to work. Running at higher bus speeds, or with lots of devices or long wires, the pullup values get more important.

Given all your help, your notion on voltages has given me and idea to try firing on 12 volts (RAW on MiniPro) and just firing the BMP180 on 3.3Volts as I accidentally found that I cannot program the MiniPro with less than 5 Volts and am thinking that if I give full revs as it were and l let the on-board V regs do their work it might just enable the I2C's on various boards.

Don't know whether you have noticed but in the pic of the BMP180 (I'll include it here once more) there is to my mind clearly a 662K V reg, But if I attempt to run the BMP180 at 5V there is that quaint nif in the air that tells you something is getting a bit hot under the collar. Also there are I think pullups there to be seen. What do you thik or know please?

Chris
PS. I've started to build the circuit but have run into trouble with domestic procedures. I'll let you know, if I may, when the schema is up and running.

Chris

BMP180.jpg