B4R Question How to initialize BMP280 (I2C)?

positrom2

Active Member
Licensed User
Longtime User
Trying to graph BMP280 data on the 1306 OLED (see my previous post).
First, Erel's fix for replacing float by double worked (compiles well now).
Second:
The 1306 OLED is initialized by ssd.InitializeI2C(d1pins.D6, 0x3c) with 3c its address.
How to initialize the BMP280 at address x77? There is no bmp.InitializeI2C.
Should both devices share the same I2C bus or should each one be connected to different pins?
 

positrom2

Active Member
Licensed User
Longtime User
Having connected both devices to D4,D5 on Nodemcu (with or without 5.6K resistors, no difference).
An I2C Scanner shows the correct addresses.
But the BMP is not initialized (log="Not") and the OLED displays random pixels on each reset.
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private bmp As Adafruit_BMP280
        Private ssd As AdafruitSSD1306
         Private d1pins As D1Pins
     Private vx = 3, vy = 3 As Int
     Private px, py As Int
     Private radius As Int = 3
     Private tmr As Timer
     Private p As Double
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
       ssd.InitializeI2C(d1pins.D6, 0x3c)
    bmp.Initialize
    If bmp.Initialize Then
    Log("Successful")
    Else
        Log("not")
    End If
    ssd.ClearDisplay
    ssd.Display
    ssd.ClearDisplay
    ssd.GFX.SetCursor(0, 0)
    ssd.GFX.ConfigureText(1, ssd.WHITE, False)
    ssd.GFX.DrawText("Date: ").DrawText(CRLF)
    tmr.Initialize("tmr_Tick", 1000)
    tmr.Enabled = False'True
End Sub
Private Sub tmr_Tick
....
 
Upvote 0

positrom2

Active Member
Licensed User
Longtime User
I missed to change the Adadruit_BMP_280.cpp for D4/D5.
With that the BMP is initialized, and everything seems to be ok.
(In the code above the ssd.Display also was missing).
Thank you.
 
Upvote 0
Top