🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    PbHub 1.1 on STAMPLC - Couldn't find Pbhub on PortA

    PRODUCTS
    2
    2
    22
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bensonwhlee
      last edited by

      I am using STAMPLC and have all function included the PWR485 are normal. However, I purchase a PbHub to use as a extended input for buttons. I cannot connect the PbHub on PortA or PortC on STAMPLC.
      I follow the sample code as follow in setup:
      #include "M5UnitPbHub.h"
      M5UnitPbHub pbhub;
      void setup() {
      Serial.begin(115200);
      if (!pbhub.begin(&Wire, UNIT_PBHUB_I2C_ADDR, 2, 1, 400000U)) {
      Serial.println("Couldn't find Pbhub");
      while (1) delay(1);
      }
      }

      void loop() {
      Serial.printf("ch:%d adc:%d\r\n", 0 , pbhub.analogRead(0));
      delay(1);
      }

      The following is the response on Serial Monitor:
      Couldn't find Pbhub

      E (1982) i2c.master: I2C transaction unexpected nack detected
      E (1983) i2c.master: s_i2c_synchronous_transaction(924): I2C transaction failed
      E (1984) i2c.master: i2c_master_multi_buffer_transmit(1186): I2C transaction failed

      Wirings and functions are correct, G1 and G2 can get analogue and digital data I/O as normal. Any hints to solve the problem. I have write a simple I2C scanner program on Port A G2, G1 pin, there was response from Address 0x61, but Pbhub library cannot read data from Pbhub

      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF
        felmue @bensonwhlee
        last edited by felmue

        Hello @bensonwhlee

        I think you need to use the M5StamPLC library together with M5Unified and M5GFX libraries for it to work properly.

        Please find an example here which works for me.

        Edit: if you don't need M5StamPLC specific functions then it should be sufficient to add the following line to your setup code:

        Wire.begin(2, 1, 400000U);
        

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • First post
          Last post