Chat freely about anything...

User avatar
By johnbrady93
#55261 Hi all,

I am using a NodeMCU 0.9 and a BMP280 from Ebay. It has 6 connections, in the following order:

VCC - 3.3v voltage
GND - ground
SCL - clock, I assume
SDA - data, I assume, but not sure if in or out
CSB - chip select, I assume
SDO - data out, I think? Not sure.

In terms of hookup, I have voltage and ground hooked up to 3.3v and ground, and then have SCL plugged into GPIO14 (d5) and SDA plugged into GPIO12 (d6). SDO is plugged into GPIO13 (d7) but the code behaves the same regardless of this is plugged in or not. If CS is plugged into GPIO15 (d8) the board fails to boot.

I'm trying to use the BME280 library on the floating point firmware flashed to my board. (found here: https://nodemcu.readthedocs.io/en/maste ... es/bme280/) and the build is below:

modules: adc,bit,bme280,dht,encoder,file,gpio,http,i2c,mdns,mqtt,net,node,pcm,pwm,rtcmem,rtctime,sntp,spi,struct,tmr,u8g,uart,wifi,ws2801,ws2812
build built on: 2016-09-15 04:08
powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32)


I call bme280.init(6,5) which takes the pin for SDA and SCL. I then print the result of the initialization which returns 1, meaning a BMP280 was initialized successfully.

However, any time I try to get data, regardless of the function, it always returns nil. The documentation says this nil is returned when the readout is not successful.

1. Do I have my wiring set up correctly?
2. Is the code faulty? Should I try the dev branch or am I missing a package or something?

Below is the Ebay link to the BMP280 I purchased and linked is a picture of the backside, showing the pinout
http://www.ebay.com/itm/141975980328?_t ... EBIDX%3AIT
http://imgur.com/a/bh9Xa

Looking for any help people can provide! Thanks in advance!
User avatar
By KevinA
#55363 I was looking at the code in github but couldn't find any wiring information, where did you find your hookup?
I believe GPIO02 is I2C_SDA
From the BME280 PDF: A direct connection between CSB and VDDIO is required
You pull SDO DOWN for address 76.
If you have other I2C devices you need to handle the device select with GPIO bits.
I have not found where they define what the BME280 is, SPI or I2C.
Found it: The Github c source they are using 76 as the address so SDO must be tied to ground

I have found that the ESP8266 has a Master SPI which is used for the memory chip and a Slave SPI is not used but since the BME280 is a slave it will not work leaving only I2C.

Look at the source code and the BME280 data sheet.

Why are you using BME code for a BMP?
User avatar
By picstart
#55919 First interfaces are of two flavors software (aka bit banging) and hardware. Most often a software interface is blocking ( holds the code hostage until data is written or received)
SPI is a four wire device MISO MOSI CLK plus CS and of course you always need a Vcc and a GND connection.
I2C is a two wire interface SDA SCK and of course you always need a Vcc and a GND connection.
SPI is full duplex and is very fast but each SPI device needs its dedicated CS.
I2C is versatile since the addressing of the devices on the bus and the read or write is done using only SDA and SCK. I2C is half duplex.
For the esp8266 one SPI hardware interface is dedicated to the Flash memory that contains the code. The secondary SPI needs to be multiplexed via the port options registers
look at the pinMode( pinxx,function_X) feature in the esp8266 arduino IDE. With commercial arduino code this hardware level assignment is often buried in the code since
coders tend to bury all hardware related calls. I'm unsure as to why this style got started since it is the electrons that do the work and electrons inhabit hardware not software.
Nevertheless coders see code as supreme and often tend to ignore the electrons.
For the BMP280 software I2C is fast enough but for TFT displays it often is the cause of slow TFT response. SPI or a parallel interface is best for TFT displays.
As a wild guess for a SPI interface to the BMP280 I'd look at the CS pin since if it is not brought low the BMP280 is offline.