Stefan
Stefan

Reputation: 31

BMP280 Temperature reading 0x000FFFF0

I have a BMP280 (GYBMP280 datasheet) connected to a Raspberry Pi 3 using the IC2 interface (address 0x76). The GYBMP280 is connected to the 3.3V (Pin 1).

The Pressure readings seem to be fine - it fluctuates ever so slightly as expected.

However, the Temperature reading is always [255,255,0] = 0x000FFFF0. I confirmed with an infrared thermometer that my sensor has a reasonable temperature (about 70F) which is well within the detection range.

I have distilled down the libraries I plan to use into a brief test program that just initializes the GYBMP280 and reads the appropriate registers, see below.

Page 24 of the Bosch Data Sheet shows the memory map.

Am I doing something wrong or is the module defect?

import smbus
import time

# Get I2C bus
bus = smbus.SMBus(1)

# BMP280 address, 0x76(118)
# Select Control measurement register, 0xF4(244)
# 0x27(39) Normal mode, Pressure and Temperature Oversampling rate = 1
bus.write_byte_data(0x76, 0xF4, 0x27) # 0b11 + (0b001 << 2) + (0b001 << 5)


# BMP280 address, 0x76(118)
# Select Configuration register, 0xF5(245)
# 0xA0(00) Stand_by time = 1000 ms
bus.write_byte_data(0x76, 0xF5, 0xA0)
time.sleep(0.5)

# BMP280 address, 0x76(118)
# Read data back from 0xF7(247), 8 bytes
# Pressure MSB, Pressure LSB, Pressure xLSB, Temperature MSB, Temperature LSB Temperature xLSB
data = bus.read_i2c_block_data(0x76, 0xF7, 6)
print(data) # OUTPUT: [102, 217,0, 255, 255,0], Press: [102,217,0] Temp: [255,255,0]

# Extract Pressure and Temperature
adc_p = (data[0]<<16 | data[1]<<8 | data[2]) >> 4
adc_t = (data[3]<<16 | data[4]<<8 | data[5]) >> 4
print("press=0x{0:08X}".format(adc_p)) #press = 0x00066D90
print("temp= 0x{0:08X}".format(adc_t)) #temp  = 0x000FFFF0

Upvotes: 1

Views: 387

Answers (0)

Related Questions