Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Steve1
    S
    • Continue chat with Steve1
    • Start new chat with Steve1
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    Steve1

    @Steve1

    0
    Reputation
    3
    Posts
    307
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Steve1 Follow

    Posts made by Steve1

    • Ultrasonic range finder unit not working.

      I recently bought an "M5Stack Ultrasonic Unit (RCWL-9600) Distance Sensor I2C Grove" and cannot get it to work at all. I have tens of M5Stack units and always start of by using the sample codes from the Wiki. Unfortuately neither the UI Flow code nor the Arduino code from the Wiki work in the case of the ultrasonic range finder. With the UI Flow code the sensor is recognized as being connected to I2C but delivers the distance of 7958.04mm and never changes. With the Arduino code the distance is always around the 500mm mark no matter how far away the obstruction is.

      Do I have a faulty unit or are there known issues with this unit?

      posted in Units
      S
      Steve1
    • RE: Using IR Remote sensor with PbHub

      Thanks, but I still cannot read the Serial.read() from "porthub.hub_a_read_value(HUB_ADDR[2]);"

      posted in General
      S
      Steve1
    • Using IR Remote sensor with PbHub

      I have been exprimenting with using sensors on an M5Stack fire via a PaHub and a PbHub. Here is simple working example for a button module:
      *// Important! Set Tools-PSRAM to Disabled otherwise M5Stack display hangs.

      #include <Wire.h>
      #include "ClosedCube_TCA9548A.h"
      #include <M5Stack.h>
      #define PaHub_I2C_ADDRESS 0x70
      ClosedCube::Wired::TCA9548A tca9548a;
      #include "porthub.h"

      #define X_OFFSET 10
      #define Y_OFFSET 18

      PortHub porthub;
      uint8_t HUB_ADDR[6] = {HUB1_ADDR, HUB2_ADDR, HUB3_ADDR, HUB4_ADDR, HUB5_ADDR, HUB6_ADDR};

      void setup() {

      M5.begin();
      M5.Power.begin();
      delay(50);
      Serial.begin(115200); // Initialize serial communications with the PC
      Wire.begin(); // Initialize I2C
      uint8_t returnCode = 0;
      uint8_t channel = 0;
      tca9548a.address(PaHub_I2C_ADDRESS);
      returnCode = tca9548a.selectChannel(channel);
      Serial.print("returnCode = ");
      Serial.println(returnCode);
      //Wire.beginTransmission(channel);
      //returnCode = Wire.endTransmission();

      M5.Lcd.clear(BLACK);
      M5.Lcd.setTextColor(YELLOW);
      M5.Lcd.setTextSize(2);
      M5.Lcd.setCursor(30, 0); M5.Lcd.println("Button/Hub example");
      Serial.println("Button/Hub example: ");
      M5.Lcd.setTextColor(WHITE);
      }

      /*
      Description: Read the button status of BUTTON Unit and display it on the screen
      */
      #include <M5Stack.h>

      int last_value_A = 0;
      int cur_value_A = 0;
      int last_value_B = 0;
      int cur_value_B = 0;

      void loop() {
      cur_value_A = porthub.hub_d_read_value_A(HUB_ADDR[2]);// read the value of A-BUTTON
      cur_value_B = porthub.hub_d_read_value_B(HUB_ADDR[2]);// read the value of B-BUTTON

      M5.Lcd.setCursor(0, 25); M5.Lcd.print("Status A: ");
      M5.Lcd.setCursor(0, 45); M5.Lcd.print("Value A: ");
      M5.Lcd.setCursor(0, 65); M5.Lcd.print("Status B: ");
      M5.Lcd.setCursor(0, 85); M5.Lcd.print("Value B: ");
      if (cur_value_A != last_value_A) {
      Serial.print("A = ");
      Serial.print(cur_value_A);
      M5.Lcd.fillRect(110, 25, 100, 25, BLACK);
      M5.Lcd.fillRect(95, 45, 100, 25, BLACK);
      if (cur_value_A == 0) {
      M5.Lcd.setCursor(110, 25); M5.Lcd.print("pressed"); // display the status
      M5.Lcd.setCursor(95, 45); M5.Lcd.print("0");
      Serial.println("Button Status: pressed");
      Serial.println(" value: 0");
      }
      else {
      M5.Lcd.setCursor(110, 25); M5.Lcd.print("released"); // display the status
      M5.Lcd.setCursor(95, 45); M5.Lcd.print("1");
      Serial.println("Button Status: released");
      Serial.println(" value: 1");
      }

      last_value_A = cur_value_A;
      

      }

      if (cur_value_B != last_value_B) {
      Serial.print("B = ");
      Serial.print(cur_value_B);
      M5.Lcd.fillRect(110, 65, 100, 25, BLACK);
      M5.Lcd.fillRect(95, 85, 100, 25, BLACK);

      if (cur_value_B == 0) {
        M5.Lcd.setCursor(110, 65); M5.Lcd.print("pressed"); // display the status
        M5.Lcd.setCursor(95, 85); M5.Lcd.print("0");
        Serial.println("Button Status: pressed");
        Serial.println("       value:  0");
      }
      else {
        M5.Lcd.setCursor(110, 65); M5.Lcd.print("released"); // display the status
        M5.Lcd.setCursor(95, 85); M5.Lcd.print("1");
        Serial.println("Button Status: released");
        Serial.println("       value:  1");
      }
      
      last_value_B = cur_value_B;
      

      }
      M5.update();
      }*

      I have got several simple M5Stack sensors working this way. I canor however get the IR Remote module to work even just via the PbHub. The problem is that when connected directly the sketch normally reads pin 36 by including "int IR_RECEIVE_PIN = 36;" in the sketch. But my problem is how to do this via the PbHub? I have tried "int IR_RECEIVE_PIN="porthub.hub_a_read_value(HUB_ADDR[i2):" and other commands from porthub.h but then the address is read only once.

      How can I use PbHub and porthub.h to acheive the same effect I get from connecting directly to pin 36?

      posted in General
      S
      Steve1