B4R Question ESP8266 and I2C Address Scanner

BaGRoS

Active Member
Licensed User
Longtime User

Attachments

  • B4R.jpg
    B4R.jpg
    455 KB · Views: 317

BaGRoS

Active Member
Licensed User
Longtime User
Always when I click "connect" button from logger.

Before I have this message too, and I change language to English. But now only this one.
 
Upvote 0

BaGRoS

Active Member
Licensed User
Longtime User
I change code to
B4X:
#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region


Sub Process_Globals
    Public Serial1 As Serial
    Public Wire As WireMaster
    Private wireerror As Byte = 0
    Private deviceaddress As Byte
    Private tmr As Timer
   
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Delay(500)
    Wire.Initialize
    Log("App start")
   
    tmr.Initialize("tmr_Tick", 2000)
    tmr.Enabled = True
   
    Log("Start after 2 sec...")
   
End Sub

Sub tmr_Tick
    Scanning
End Sub

Private Sub Scanning
    Private bc As ByteConverter
    Dim b(1) As Byte
    Dim devices As Int

    Log("Scanning started...")
    devices = 0
    For i = 0 To 127
        deviceaddress = i
        RunNative("icwirebegintransmisson", deviceaddress)
        RunNative("icwireendtransmisson", Null)
        b(0) = deviceaddress
        If wireerror = 0 Then
            Log("I2C device found at address: 0x", bc.HexFromBytes(b), " (", deviceaddress, ")")
            devices = devices + 1
        End If
        If wireerror = 4 Then
            Log("I2C device unknown at address: 0x", bc.HexFromBytes(b), " (", deviceaddress, ")")
        End If
    Next
    If (devices = 0) Then
        Log("No I2C devices.")
    End If
    Log("Scanning completed.")
End Sub

#if C
#include <Wire.h>
void icwirebegintransmisson (B4R::Object* o) {
  Wire.beginTransmission(b4r_main::_deviceaddress);
}

void icwireendtransmisson (B4R::Object* o) {
  b4r_main::_wireerror = Wire.endTransmission();
}
#End if

and...
From d:\1\ working, but from d:\_B4R\Test011_I2C scaner_WeMOS\ not working.
Screen: B4R.jpg look at down/right corner. My laptop have to big screen or what?

I found problem, SPACE! I change for under space d:\_B4R\Test011_I2C_scaner_WeMOS\ and working now.
 
Upvote 0
Top