Nanobaro - NMEA/USB barometric sensor, easy DIY electronics project

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
After having played a bit with NMEA 2000 communications last week (see Engine Room temp sensor thread) I read this thread with more interest and ordered a couple of BMP180 sensors.

I couldn't understand how you came to connect them to 5v since the first ones I found were all for 3.3v (with 3.6v max supply). I ordered anyway and since that's what the Teensy 3.2 (similar to an Arduino) runs on then they will be perfect. If anyone else has ordered some then I would suggest checking the permitted supply voltage before connecting to 5v.

Initial thoughts were that output to PGNs 130310 or 130311 could be quite easy but I see they're now marked as deprecated. I might have to look at what my displays will currently listen to and are capable of displaying.. Another project for when I find the time :)

If anyone is interested I'll update this post with any progress... but for starters, take a look at Timo's NMEA2000 library and I'll try and help where needed..
Timo lappalainen - NMEA2000
 

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
After having played a bit with NMEA 2000 communications last week (see Engine Room temp sensor thread) I read this thread with more interest and ordered a couple of BMP180 sensors.

I couldn't understand how you came to connect them to 5v since the first ones I found were all for 3.3v (with 3.6v max supply). I ordered anyway and since that's what the Teensy 3.2 (similar to an Arduino) runs on then they will be perfect. If anyone else has ordered some then I would suggest checking the permitted supply voltage before connecting to 5v.

Initial thoughts were that output to PGNs 130310 or 130311 could be quite easy but I see they're now marked as deprecated. I might have to look at what my displays will currently listen to and are capable of displaying.. Another project for when I find the time :)

If anyone is interested I'll update this post with any progress... but for starters, take a look at Timo's NMEA2000 library and I'll try and help where needed..
Timo lappalainen - NMEA2000

Hi Martin
I'm definitely interested in how you get on. I also came across this board which has an arduino and can bus built in:
http://www.hobbytronics.co.uk/leonardo-canbus

One thing I'm really interested in working out how to do is an ultrasonic fuel level sensor for a steel tank that mounts on the outside of the tank. Examples of a commercial one:

https://www.alibaba.com/product-det...2700.7724857.normalList.13.471f24dcuE8OUR&s=p
 

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
Ok.. my head is now hurting.
I've got the MDA sentence setup, but how do I connect the arduino nano to an NMEA input on the boat?
I presume that I can't just connect the data lines from the usb socket to it?
 

Yngmar

Well-known member
Joined
6 Dec 2012
Messages
3,064
Location
Gone cruising
Visit site
Ok.. my head is now hurting.
I've got the MDA sentence setup, but how do I connect the arduino nano to an NMEA input on the boat?
I presume that I can't just connect the data lines from the usb socket to it?

The USB socket outputs... USB protocol, so that would not work at all. But, as I said previously, the same serial data as on the USB-over-serial should also be on the serial pins of the Nano:

Should work without modifications. The Nano outputs the USB-Serial also as TTL level serial output at 4800 bps, see https://www.arduino.cc/reference/en/...cation/serial/

Look up the pinout for your Nano. You just need the transmit one (TxD), and ground of course. These are TTL level, so you may need a level shifter, but no harm trying (in this direction - very much harm if you put 12V on the Arduino RxD - but that's not something you need here). Also your NMEA device's input must be able to cope with RS232, not RS442 (differential), but most do that. Look up the pins and give it a go.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,209
Location
Hopefully somewhere warm
Visit site
Look up the pinout for your Nano. You just need the transmit one (TxD), and ground of course. These are TTL level, so you may need a level shifter, but no harm trying (in this direction - very much harm if you put 12V on the Arduino RxD - but that's not something you need here). Also your NMEA device's input must be able to cope with RS232, not RS442 (differential), but most do that. Look up the pins and give it a go.

Bear in mind TTL logic is inverted to RS232, software serial allows you to pick a pin and invert the logic >

https://www.arduino.cc/en/Reference/SoftwareSerialConstructor

(PS - Or really bite the bullet and get a raspberry pi, then send/receive everything over wifi with an ESP8266 straight into signalk :cool: )
 
Last edited:

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
Hi Martin
I'm definitely interested in how you get on. I also came across this board which has an arduino and can bus built in:
http://www.hobbytronics.co.uk/leonardo-canbus

One thing I'm really interested in working out how to do is an ultrasonic fuel level sensor for a steel tank that mounts on the outside of the tank. Examples of a commercial one:

https://www.alibaba.com/product-det...2700.7724857.normalList.13.471f24dcuE8OUR&s=p

Regarding the Canbus interface, I actually moved from Arduino Nano to the Teensy for the NMEA2000 projects. The Teensy 3.2 in the link below runs quicker, has more memory and uses the same Arduino programmer and .ino files that you are already used to using.

skpang.co.uk teensy-canbus-breakout-board-include-teensy-32
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
Hi Martin
I'm definitely interested in how you get on. I also came across this board which has an arduino and can bus built in:
http://www.hobbytronics.co.uk/leonardo-canbus

One thing I'm really interested in working out how to do is an ultrasonic fuel level sensor for a steel tank that mounts on the outside of the tank. Examples of a commercial one:

https://www.alibaba.com/product-det...2700.7724857.normalList.13.471f24dcuE8OUR&s=p

Tried to check up on the output from that sensor... but then decided to search for a few UK Ultrasonic level sensors..

Just found one on the TekTanks website that says it has a 0-5v output and is even available as a 0-190ohm resistive output.

I reckon the 0-5v output would be good and with a resistor voltage divider you'd be able to connect it direct to the Teensy/CanBus board..

www.tek-tanks.com BEP marine Ultrasonic Sender

Looks like a useful sender.. Unfortunately I recently put in a Wema sender. Perhaps we ought to start a NMEA2000 fuel level thread
 

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
Tried to check up on the output from that sensor... but then decided to search for a few UK Ultrasonic level sensors..

Just found one on the TekTanks website that says it has a 0-5v output and is even available as a 0-190ohm resistive output.

I reckon the 0-5v output would be good and with a resistor voltage divider you'd be able to connect it direct to the Teensy/CanBus board..

www.tek-tanks.com BEP marine Ultrasonic Sender

Looks like a useful sender.. Unfortunately I recently put in a Wema sender. Perhaps we ought to start a NMEA2000 fuel level thread

Ouch... that sensor is expensive. Cheaper to get the whole kit from China!
 

st599

Well-known member
Joined
9 Jan 2006
Messages
7,241
Visit site
I've made a thing. It's a very low cost barometric sensor that outputs NMEA 0183 barometric pressure (and temperature) sentences on a USB-serial interface (should be trivial to modify with an actual serial output, if you need that). Plug it into a computer with OpenCPN and you get a barograph (barometric pressure over time). Components should cost under £10 and you only need to solder together 4 wires and do a simple firmware upload. Maybe stick it in a plastic box.

If you're interested, I've written about it here and made the source code and instructions available for free.

If you used a NodeMCU ESP8266, can OpenCPN receive NMEA sentences via TCP over WiFi?

Also, there seems to be a newer sensor in that range that also does humidity.
 

rgarside

Active member
Joined
24 May 2009
Messages
492
Location
East Coast
Visit site
It sounds as though Martin has canbus worked out for NMEA 2000. I have seen some items by Vas on the motor boat forum that suggest he has found out a lot about NMEA 2000 and canbus - including suitable libraries for Arduino / Tiny.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,209
Location
Hopefully somewhere warm
Visit site
If you used a NodeMCU ESP8266, can OpenCPN receive NMEA sentences via TCP over WiFi?

Yes, but you need something to create a wifi network to send the data over. Windows might well be able to do this, never tried, or the esp8266 can create a network for the machine running opencpn could connect to that. Another option would be use a mobile phone to create the network.
Then the dashboard should see various NMEA sentences, I use MWT, MDA & XDR for watertemp, airtemp & barometer. These get automatically added to the logbook plugin as well.
 

pagoda

Active member
Joined
19 May 2008
Messages
2,227
Location
Scotland
Visit site
Got our B&G Vulcan reading Barometric Pressure and Temperature from a BMP280 operating under a Teensy3.2.
It took a while to get the NMEA2K part working but I simply used some of Timo's code and bolted on the BMP280 driver underneath it.
Some voltage dividers next to get some analogue data in.:)

(also- if you are adding a new CAN device -make sure it isn't fitted with a 120 OHM Terminator resistor( or use something like 1K OHM which will not interfere with your existing network), WHERE you already have one on EACH END of your network.)
 
Last edited:

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
Got our B&G Vulcan reading Barometric Pressure and Temperature from a BMP280 operating under a Teensy3.2.
It took a while to get the NMEA2K part working but I simply used some of Timo's code and bolted on the BMP280 driver underneath it.
Some voltage dividers next to get some analogue data in.:)

(also- if you are adding a new CAN device -make sure it isn't fitted with a 120 OHM Terminator resistor( or use something like 1K OHM which will not interfere with your existing network), WHERE you already have one on EACH END of your network.)

HI, would you mind sharing your code, this is exactly what I'm, planning to do :)
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
After struggling to get temperature out of the cheap eBay BMP180 boards last week I bought another couple of BMP180 boards from a different supplier and the code then worked first time.

The first boards would respond with pressure but without the temperature readings, correct compensation calculations were not going to be possible.

Temperature needs a value written to the board, and then a reading taken from the board 4.5ms later..

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP180-DS000-12.pdf

I just wasn't getting anything valid.

The BMP boards that were not really responding were the small ones with just 3 pins and recognisable by having a single large hole drilled in the PCB.

The working ones have five pins, a small 5v -> 3.3v regulator on board and have two large holes drilled in them.

Both appeared to have a Bosch BMP180 on board but writing stamped on the non-working ones was barely recognisable.. strange..
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
/*
Teensy 3.2 with Canbus development board from SKPang
Licensed under the GNU General Public License v3.0

NMEA2000 conversions thanks to Timo at https://github.com/ttlappalainen/NMEA2000

BarometerBMP180_to_NMEA2000_mj5

In order to power from NMEA2000 and have USB serial connected, cut the physical link between pads under USB connector.

BMP180 Hardware connections:

- (GND) to GND
+ (VDD) to 3.3V on Teensy

When using development board, easiest connection is to solder to SDA1/SCL1 on underside of Teensy 3.2 board
SDA1 SCL1
A18(29) A19(30) and use code with Wire1

If SDA0/SCL0 are used then change code to Wire
SDA0 SCL0
A4(18) A5(19) Wire

(WARNING: do not connect + to 5V or the sensor will be damaged unless you have BMP180 with 5v to 3.3v regulator)
*/

#include <Wire.h>

//Address of the BMP180
#define _i2cAddress 0x77

//Registers
#define _Register_CONTROL 0xF4
#define _Register_RESULT 0xF6

//Commands
#define _COMMAND_TEMPERATURE 0x2E
#define _COMMAND_PRESSURE 0xF4

#define _ONE_BYTE 1
#define _TWO_BYTES 2
#define _THREE_BYTES 3

//------------------------------

int16_t AC1,AC2,AC3,VB1,VB2,MB,MC,MD;
uint16_t AC4,AC5,AC6;

double c5,c6,mc,md;
double xx0,xx1,xx2;
double yy0,yy1,yy2;
double p0,p1,p2;

float PRESSURE;

double P,T;

//------------------------------
//Define NMEA2000 stuff
#include <SPI.h>

#include <mcp_can.h>
#include <mcp_can_dfs.h>

#include <NMEA2000_mcp.h>

#include <ActisenseReader.h>
#include <N2kCANMsg.h>
#include <N2kDef.h>
#include <N2kDeviceList.h>
#include <N2kGroupFunction.h>
#include <N2kGroupFunctionDefaultHandlers.h>
#include <N2kMessages.h>
#include <N2kMessagesEnumToStr.h>
#include <N2kMsg.h>
#include <N2kStream.h>
#include <NMEA2000.h>
#include <NMEA2000_CAN.h> // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <NMEA2000_CompilerDefns.h>

#include <FlexCAN.h>
#include <NMEA2000_teensy.h>

#include <Arduino.h>



// List here messages your device will transmit.
// const unsigned long TransmitMessages[] PROGMEM={130310L,130311L,130312L,0};

// Barometric pressure and temperature sensor MJ
const unsigned long TransmitMessages[] PROGMEM={130311L,130311L,130312L,0};
// END NMEA2000 definitions
//------------------------------

void setup()
{
Serial.begin(9600);
delay(100);

// Set Product information
NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
100, // Manufacturer's product code
"BMP180 Barometer MJ", // Manufacturer's Model ID
"MJ v5 (22-10-2018)", // Manufacturer's Software version code
"Teensy 3.2" // Manufacturer's Model version
);
// Set device information
NMEA2000.SetDeviceInformation(112234, // Unique number. Use e.g. Serial number.
140, // Device function=Temperature. See codes on http://www.nmea.org/Assets/20120726 nmea 2000 class & function codes v 2.00.pdf
75, // Device class=Sensor Communication Interface. See codes on http://www.nmea.org/Assets/20120726 nmea 2000 class & function codes v 2.00.pdf
2041 // Just choosen free from code list on http://www.nmea.org/Assets/20121020 nmea 2000 registration list.pdf
);
// Uncomment 2 rows below to see, what device will send to bus. Use e.g. OpenSkipper or Actisense NMEA Reader
// Serial.begin(115200);
// NMEA2000.SetForwardStream(&Serial);
// If you want to use simple ascii monitor like Arduino Serial Monitor, uncomment next line
//NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.

// If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);
//NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
// Here we tell library, which PGNs we transmit
NMEA2000.ExtendTransmitMessages(TransmitMessages);
NMEA2000.Open();

begin();

delay(100);

}

void loop()
{
// Serial.print(getPressure());
// Serial.println(" mb");

delay(5);

T = getTemperature();
Serial.print(T);
Serial.println(" T value");

delay(5);

P = getPressure();
Serial.print(P);
Serial.println(" P value");

SendN2kBMP180Pressure();
NMEA2000.ParseMessages();

delay(900); //Under a second
// delay(5000); //Five seconds
// delay(15000); //Fifteen seconds
// delay(300000); //Five minutes

}

void begin(){

//Initialise the pressure library
double c3,c4,b1;

//Start the wire library
Wire1.begin();

//Read the BMP180 factory settings
if (readInt(0xAA,AC1) &&
readInt(0xAC,AC2) &&
readInt(0xAE,AC3) &&
readUInt(0xB0,AC4) &&
readUInt(0xB2,AC5) &&
readUInt(0xB4,AC6) &&
readInt(0xB6,VB1) &&
readInt(0xB8,VB2) &&
readInt(0xBA,MB) &&
readInt(0xBC,MC) &&
readInt(0xBE,MD))
{
// Calculate calibration polynomials

c3 = 160.0 * pow(2,-15) * AC3;
c4 = pow(10,-3) * pow(2,-15) * AC4;
b1 = pow(160,2) * pow(2,-30) * VB1;
c5 = (pow(2,-15) / 160) * AC5;
c6 = AC6;

mc = (pow(2,11) / pow(160,2)) * MC;
md = MD / 160.0;

xx0 = AC1;
xx1 = 160.0 * pow(2,-13) * AC2;
xx2 = pow(160,2) * pow(2,-25) * VB2;

yy0 = c4 * pow(2,15);
yy1 = c4 * c3;
yy2 = c4 * b1;

p0 = (3791.0 - 8.0) / 1600.0;
p1 = 1.0 - 7357.0 * pow(2,-20);
p2 = 3038.0 * 100.0 * pow(2,-36);

}
}

char readInt(char registerAddress, int16_t &value)
{
// Read a signed integer from device

unsigned char byteHigh;
unsigned char byteLow;

// Begin communication with BMP180
Wire1.beginTransmission(_i2cAddress);

// Tell register you want some data
Wire1.write(registerAddress);

//If false, endTransmission() sends a restart message after transmission. The bus will not be released,
//which prevents another master device from transmitting between messages. This allows one master device
//to send multiple transmissions while in control. The default value is true.
int nackCatcher = Wire1.endTransmission(false);

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Request 2 bytes from BMP180
Wire1.requestFrom(_i2cAddress , _TWO_BYTES);

// Wait for the bytes to arrive
while(Wire1.available() < _TWO_BYTES);

// Read the values
byteHigh = Wire1.read();
byteLow = Wire1.read();

value = (((int16_t)byteHigh <<8) + (int16_t)byteLow);

// Return true as ok
return(1);
}

char readUInt(char registerAddress, uint16_t &value)
{
// Read an unsigned integer from device

unsigned char byteHigh;
unsigned char byteLow;

// Begin communication with BMP180
Wire1.beginTransmission(_i2cAddress);

// Tell register you want some data
Wire1.write(registerAddress);

//If false, endTransmission() sends a restart message after transmission. The bus will not be released,
//which prevents another master device from transmitting between messages. This allows one master device
//to send multiple transmissions while in control. The default value is true.
int nackCatcher = Wire1.endTransmission(false);

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Request 2 bytes from BMP180
Wire1.requestFrom(_i2cAddress , _TWO_BYTES);

// Wait for the bytes to arrive
while(Wire1.available() < _TWO_BYTES);

// Read the values
byteHigh = Wire1.read();
byteLow = Wire1.read();

value = (((uint16_t)byteHigh <<8) + (uint16_t)byteLow);

// Return true as ok
return(1);
}

char startTemperature()
{
// Begin communication with BMP180
Wire1.beginTransmission(_i2cAddress);

// Tell register an instruction
Wire1.write(_Register_CONTROL);
Wire1.write(_COMMAND_TEMPERATURE);

//End transmission and release the bus. The default value is true.
int nackCatcher = Wire1.endTransmission();

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Return true as ok
return(1);
}

char getTemperature(double &T)
{
unsigned char byteHigh;
unsigned char byteLow;
double tu, a;

// Wait for the measurement to complete:
delay(5);

// Begin communication with BMP180
Wire1.beginTransmission(_i2cAddress);

// Tell register you want some data
Wire1.write(_Register_RESULT);

//If false, endTransmission() sends a restart message after transmission. The bus will not be released,
//which prevents another master device from transmitting between messages. This allows one master device
//to send multiple transmissions while in control. The default value is true.
int nackCatcher = Wire1.endTransmission(false);

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Request 2 bytes from BMP180
Wire1.requestFrom(_i2cAddress , _TWO_BYTES);

// Wait for the bytes to arrive
while(Wire1.available() < _TWO_BYTES);

// Read the values
byteHigh = Wire1.read();
byteLow = Wire1.read();

// Calculate the temperature
tu = (byteHigh << 8) + byteLow;
a = c5 * (tu - c6);
T = a + (mc / (a + md));

// Return true as ok
return(T);
}

char startPressure()
{
// Begin a pressure reading.
Wire1.beginTransmission(_i2cAddress);

// Tell register an instruction
Wire1.write(_Register_CONTROL);
Wire1.write(_COMMAND_PRESSURE);

//End transmission and release the bus. The default value is true.
int nackCatcher = Wire1.endTransmission();

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Return true as ok
return(1);
}


char getPressure(double &P, double &T)
{
unsigned char byteHigh;
unsigned char byteMid;
unsigned char byteLow;
double pu,s,x,y,z;

// Wait for the measurement to complete:
delay(26);

// Begin communication with BMP180
Wire1.beginTransmission(_i2cAddress);

// Tell register you want some data
Wire1.write(_Register_RESULT);

//If false, endTransmission() sends a restart message after transmission. The bus will not be released,
//which prevents another master device from transmitting between messages. This allows one master device
//to send multiple transmissions while in control. The default value is true.
int nackCatcher = Wire1.endTransmission();

// Return if we have a connection problem
if (nackCatcher != 0) {return 0;}

// Request 3 bytes from BMP180
Wire1.requestFrom(_i2cAddress , _THREE_BYTES);

// Wait for the bytes to arrive
while(Wire1.available() < _THREE_BYTES);

// Read the values
byteHigh = Wire1.read();
byteMid = Wire1.read();
byteLow = Wire1.read();

// Calculate absolute pressure in mbars.
pu = (byteHigh * 256.0) + byteMid + (byteLow/256.0);

s = T - 25.0;
x = (xx2 * pow(s,2)) + (xx1 * s) + xx0;
y = (yy2 * pow(s,2)) + (yy1 * s) + yy0;
z = (pu - x) / y;
P = (p2 * pow(z,2)) + (p1 * z) + p0;

return(P);
}

double getTemperature()
{
double T;

if (startTemperature() != 0)
{
if (getTemperature(T) != 0)
{
return(T);
}
}
return(0);
}

double getPressure()
{
double P,T;

if (startTemperature() != 0)
{
if (getTemperature(T) != 0)
{
if (startPressure() != 0)
{
if (getPressure(P,T) != 0)
{
return(P);
}
}
}
}
return(0);
}




void SendN2kBMP180Pressure() {
//double Level = 0;

// static unsigned long TempUpdated=millis();
tN2kMsg N2kMsg;


// if ( TempUpdated+TempUpdatePeriod<millis()) {

// TempUpdated=millis();
// SetN2kFluidLevel(N2kMsg,1,N2kft_Fuel,75,100);
// SetN2kPressure(N2kMsg,0,2,N2kps_Atmospheric,mBarToPascal(1024));


SetN2kOutsideEnvironmentalParameters(N2kMsg, 1, 0, CToKelvin(T));
NMEA2000.SendMsg(N2kMsg);

SetN2kEnvironmentalParameters(N2kMsg, 1, N2kts_MainCabinTemperature, CToKelvin(T), N2khs_InsideHumidity, 0, mBarToPascal(P));
NMEA2000.SendMsg(N2kMsg);

SetN2kTemperature(N2kMsg, 1, 1, N2kts_MainCabinTemperature, CToKelvin(T), CToKelvin(T));
NMEA2000.SendMsg(N2kMsg);

Serial.print(T+273.15);
Serial.println(" T sent to NMEA2000");

Serial.print(P);
Serial.println(" P sent to NMEA2000");


// Serial.print(millis()); Serial.println(", Temperature send ready");
// }

}
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
Code put together in a bit of a rush, as always..

Had to play about a bit with the PGNs. The GMI10 that I tested on seemed to take Barometric pressure in one PGN but needed temperature in another.

Not sure which brought the temperature up. When I have time I'll see which was needed.

Can test on the B&G Zeus later but at some point will need to use the later PGNs since these PGNs are deprecated.
https://www.nmea.org/Assets/20151026%20nmea%202000%20pgn_website_description_list.pdf
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,209
Location
Hopefully somewhere warm
Visit site
After struggling to get temperature out of the cheap eBay BMP180 boards last week I bought another couple of BMP180 boards from a different supplier and the code then worked first time.
.

Just for reference, to get a BMP280 talking to an ESP8266 i had to connect SDO to 3.3v

Also, little forum tip - if you put code inside code tags then it's in a scrollable window so doesn't take up so much post space

Code:

arduino-due-bmp280-i2c.jpg
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
Ah. Looks like PIN6 (SDO) on your BM280 board determines the i2c bus address for the device.

Useful to be able to change if you need to put two sensors on the same i2c bus.

If SDO connects to GND, the address is 0x76, if it connects to VDDIO, the address is 0x77.


Thanks for the scroll bar tip!
 

Martin_J

Well-known member
Joined
19 Apr 2006
Messages
4,258
Location
Portsmouth, UK
Visit site
Regarding the issues with the cheaper BMP180 boards.. The software did appear to be talking to them quite happily.

I was able to read all the calibration data from them and also read the uncompensated barometric pressure. It was just the temperature that didn't appear to work.

I put in waits of 4ms, 5ms, 50ms then nearly every delay within reason after the send. I was close to putting the oscilloscope on the bus to see what was happening when the new boards arrived.. Problem overcome :)
 
Top