B4R Question [SOLVED] MCP23017 (via SG-IO-E017) not working..please help

giggetto71

Active Member
Licensed User
Longtime User
Hi,
I am trying to use the I2C expansion MCP23017 chip using the board shown below with a WeMos D1 mini.
I know that it should have 0x20 default I2C address but I tried to scan anyway just to check if the device is working. Wiring is quite simple. I am powering the device connecting the Vcc and Gnd to the respective WeMos pins (I tried both the 3.3Vdc and 5Vdc for power) and I have connected the SCL pin of the device to the D1 pin of WeMos and the SDA to D2 which I am pretty sure should be correct (I tried both pulling up SDA and SCL via 4.7Kohm to 3.3Vdc but nothing changed).
What could I be possibly doing wrong?
Anyone has experience with this board?
thanks

To scan I am using this code, but the number of devices is always 0 and the scan fails to identify the I2C address of the device

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   
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Wire.Initialize
  
    Dim ii As Int
    For ii = 0 To 10
        'Try 10 times
       Scanning
    Next
  
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)
        Delay(20)
        RunNative("icwireendtransmisson", Null)
        Delay(20)
        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

SG-IO-E017.jpg
 
Last edited:

giggetto71

Active Member
Licensed User
Longtime User
found it....as often...just a soldering issue...one day maybe I will become a better at soldering...who knows...:-(
 
Upvote 0
Top