• First of all, I am assuming the BMP280 can work with the module BMP085, just like the BMP180 did..?

    Here is how I connected it, D1 and D2, GND and 3V

    I am trying to use the code from this page:
    https://www.espruino.com/BMP085

    I2C1.setup({scl:D2,sda:D1});
    var bmp = require("BMP085").connect(I2C1);
    setInterval(function() {
      bmp.getPressure(function(d) {
        console.log("Pressure: " + d.pressure + " Pa");
        console.log("Temperature: " + d.temperature + " C");
      });
    }, 1000);
    

    The console gives me a range of errors though.

    I am using the standalone IDE, judging by the load time it gets the module from the 'require' statement just fine. I also put the module in the module directory, no difference.

    Any idea what I am doing wrong? Thanks..

    Here is the console output:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    >Uncaught InternalError: I2C Write Error 33281
     at line 1 col 23
    this.i2c.writeTo(119,a),this.i2c.readFrom(119,1)[0];
                          ^
    in function "read8" called from line 1 col 99
    ...oss=3);var b=this.read8(208);if(b!=85)return console.log('Ba...
                                  ^
    in function "BMP085" called from line 1 col 15
    new BMP085(a,b);
                  ^
    in function "connect" called from line 1 col 41
    var bmp = require("BMP085").connect(I2C1);
                                            ^
    =undefined
    Uncaught Error: Field or method "getPressure" does not already exist, and can't create it on undefined
     at line 1 col 4
    bmp.getPressure(function(d) {
       ^
    in function called from system
    Uncaught Error: Field or method "getPressure" does not already exist, and can't create it on undefined
     at line 1 col 4
    bmp.getPressure(function(d) {
       ^
    in function called from system
    Uncaught Error: Field or method "getPressure" does not already exist, and can't create it on undefined
     at line 1 col 4
    bmp.getPressure(function(d) {
       ^
    in function called from system
    Uncaught Error: Field or method "getPressure" does not already exist, and can't create it on undefined
     at line 1 col 4
    bmp.getPressure(function(d) {
       ^
    
  • Some people are saying that for the BMP280 compared to the BMP180/085, the I2C ADDRESS changed from 0x77 to 0x76.

    a forum post:
    https://github.com/adafruit/Adafruit_BME280_Library/issues/15

    But I changed all the 0x77 in the BMP085.js to 0x76, but no change, same error except the 119 becomes 118;

    Uncaught InternalError: I2C Write Error 33281
    at line 1 col 23
    this.i2c.writeTo(119,a),this.i2c.readFrom(119,1)[0];

  • The Datasheet can be found at:
    https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-18.pdf

    Look at the section on I2C
    If SDO is tied to ground the slave address is 0x76
    If SDO is tied to Vcc the slave address is 0x77
    I don't have either a Puck or the BMP chip, so I hope this helps. If not maybe someone else can help.

  • Saw the datasheet, thanks. I tried all possible variations connecting the SDO to either Vcc or ground, no change in the error message so far.

  • Conecting it like this..

    with SDO to ground for the default address 0x76, CSB to 3v so I2C gets selected..

    Still same error message

  • only just found the BMP280 module :)
    https://www.espruino.com/BMP280#line=3,3,7,7,11,11

    If only I could delete a whole conversation...

  • :D I was reading through this and thinking I'm sure we had something for BMP280...

    And it all works fine now?

  • unfortunately, it still doesn't want to play ball...

    The espruino BMP280 page has this configuration:

    Device Pin Espruino
    1 (GND) GND
    8 (VCore) 3.3
    3 (SDI) B9(I2C1 SDA)
    4 (SCK) B8(I2C1 SCL)
    2(CSB) 3.3
    5(SDO) GND
    6(Vio) 3.3

    I have SDA on D1 and SCL on D2
    I have SBO on D28 and CSB on D29

    Then in the code I put D28 to GND and D29 to 3.3v
    The I2C pins need to be pulled up, not sure if I am doing that correctly.

    The code on the BMP280 page requires the BME280 module, I changed that into BMP280, assuming that is a mistake.

    digitalWrite(D28,0);
    digitalWrite(D29,1);
    
    pinMode(D1, "input_pullup");
    pinMode(D2, "input_pullup");
    
    I2C1.setup({scl:D2,sda:D1});
    var bme = require("BMP280").connect(I2C1);
    console.log(bme.getData());
    

    When running I get this error, not being able to write to the address..

    > >
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    >Uncaught InternalError: I2C Write Error 33281
     at line 1 col 20
    a.writeTo(118,[b,e])
                       ^
    in function "write" called from line 1 col 43
    ...s.write=c;this.write(244,39);this.write(245,160);this.readCo...
                                  ^
    in function "f" called from line 1 col 101
    ...(b,e){a.writeTo(118,[b,e])})
                                  ^
    in function "connect" called from line 1 col 41
    var bme = require("BMP280").connect(I2C1);
                                            ^
    Uncaught Error: Field or method "getData" does not already exist, and can't create it on undefined
     at line 1 col 16
    console.log(bme.getData());
                   ^
    =undefined
    > 
    
  • Does your module have pullup resistors on it? I2C needs them to work.

    However, you could try software I2C:

    var i2c = new I2C();
    i2c.setup({scl:D2,sda:D1});
    var bme = require("BMP280").connect(i2c);
    console.log(bme.getData());
    

    Software I2C can use the chip's internal pullups, so might be able to work without external ones.

  • i am using a Puck.js
    That definitely did the trick, great! Guess I will have to read up on why.

    So I don't need to do the pinMode lines?

    I am getting a reading, but somehow they don't change. I have had a sensor with a similar chip before and they normally are very sensitive. Am I missing something?

    var i2c = new I2C();
    i2c.setup({scl:D2,sda:D1});
    var bme = require("BMP280").connect(i2c);
    console.log(bme.getData());
    
    setInterval("console.log(bme.getData())",1000);
    
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    >{ "temp": -0.00000017881, "pressure": 0.01541300212 }
    =undefined
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": 0.00312499999, "pressure": 500.01877148359 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    >reset();
    =undefined
    
  • By the module having pullup resistors, I meant the actual BMP280 :)

    You won't need pinMode, no... it's done automatically by software I2C.

    Honestly I'm not sure why it wouldn't be changing - it could be something to do with the way it is initialised in https://github.com/espruino/EspruinoDocs/blob/master/devices/BMP280.js - are you used to looking around in the datasheets. I guess they might give you some clue...

  • Apologies for being the (relative) moron here :), quite a learning curve..

    I am looking at the datasheet, not spotting clues.
    https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-18.pdf

    could it be reading from the wrong address still?

  • i get the same numbers even without anything connected :(

  • You don't seem to have set up the SDA and CSB lines in the code above... could that be it?

    Also, I might be a bit wary of using D28/D29 - they're used as the Puck.js serial interface wires if Puck.js powers up with D29 pulled high. While you can override them with pinMode or digitalWrite, before that happens Puck.js will be using up more power than normal because it'll be running the serial port hardware all the time.

  • The code, with
    D30 at 0 connected to SDO and
    D31 at 1 connected to CSB.

    digitalWrite(D30,0);
    digitalWrite(D31,1);
    
    var i2c = new I2C();
    i2c.setup({scl:D2,sda:D1});
    var bme = require("BMP280").connect(i2c);
    console.log(bme.getData());
    setInterval("console.log(bme.getData())",1000);
    

    giving me the same figures as if nothing was connected:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    >{ "temp": -0.00000017881, "pressure": 0.01541300212 }
    =undefined
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    { "temp": -0.00000017881, "pressure": 0.01541300212 }
    >reset();
    =undefined
    

    I don't see where I am different from the BMP280 module page ...

    I was checking with a buzzer and i do see that the beep coming from 3v and GND off the Puck is a lot stronger than the D30 D31 combination, kinda weak.. but that may be normal

  • Well, I said I was a beginner.

    When you stick a pin in the Puck it makes a proper connection. But with the BMP280 it makes no connection at all. Or worse, some do and some don't.

    Getting myself a proper board to fiddle, and soldering on pins is probably not a bad idea either :)

    Thanks for the help anyway, much appreciated.

  • Argh - yes... looking at the pics the wires were in so far I assumed that you'd soldered them! I really wish someone would make some nice PCB-PCB patch wires that made proper contact, but I haven't seen any :(

    That's the annoying thing with embedded electronics - you never know if it's a software ort hardware problem :)

    So have you got it working now then?

  • All working very well, thanks.

    The bmp280 is very sensitive to air pressure, nice.

  • might as well remove this thread, misinformation from my side, looks like me thinking out loud :)

  • I'd like to keep it, if that's ok? There's still some pretty helpful stuff in there - especially if people google for certain error messages like the 33281 one :)

  • no problem :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Connecting the BMP280 barometric sensor to the Puck, lots of ERROR messages..

Posted by Avatar for user79451 @user79451

Actions