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

    M5Paper I2C

    Modules
    m5paper i2c-por
    3
    19
    20.7k
    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.
    • P
      Powersoft
      last edited by

      I Use the Arduino I2C finder. This is the result of the scan

      Scanning...
      I2C device found at address 0x44  !
      I2C device found at address 0x50  !
      I2C device found at address 0x51  !
      I2C device found at address 0x5D  !
      done
      

      When I connect de DDS with address 0x31 the same output!
      Tried this with several I2C devices. Without result.

      This is the Arduino program of the I2C scanner I used.

      #include <M5EPD.h>
      #include <Wire.h>
      
      void setup()
      {
        M5.begin();
        Wire.begin();
        
      
        Serial.begin(115200);
        Serial.println("\nI2C Scanner");
      }
      
      
      void loop()
      {
        byte error, address;
        int nDevices;
      
        Serial.println("Scanning...");
      
        nDevices = 0;
        for(address = 1; address < 127; address++ ) 
        {
          // The i2c_scanner uses the return value of
          // the Write.endTransmisstion to see if
          // a device did acknowledge to the address.
          Wire.beginTransmission(address);
          error = Wire.endTransmission();
      
          if (error == 0)
          {
            Serial.print("I2C device found at address 0x");
            if (address<16) 
              Serial.print("0");
            Serial.print(address,HEX);
            Serial.println("  !");
      
            nDevices++;
          }
          else if (error==4) 
          {
            Serial.print("Unknow error at address 0x");
            if (address<16) 
              Serial.print("0");
            Serial.println(address,HEX);
          }    
        }
        if (nDevices == 0)
          Serial.println("No I2C devices found\n");
        else
          Serial.println("done\n");
      
        delay(5000);           // wait 5 seconds for next scan
      }
      
      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        Ahh, I'm not sure about arduino as I'm working on documenting UIFlow.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        P 1 Reply Last reply Reply Quote 0
        • P
          Powersoft
          last edited by

          I think sommething is wrong with my bord. Have tested some I2C devices on my M5Stack-Fire, all working great, but non is working with the M5Paper. All connected to the standard cable. This is verry verry disipointed!

          1 Reply Last reply Reply Quote 0
          • P
            Powersoft @ajb2k3
            last edited by

            @ajb2k3 is UIFlow working on the M5Paper?

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

              Hello @Powersoft

              M5Stack (Fire, Gray, Base etc.) use the same GPIOs for the internal I2C and I2C on Port A. In contrast M5Paper, as well as M5Core2, use different GPIOs for internal and external I2C, eg. for M5Paper GPIO21 / GPIO22 and GPIO 25 / GPIO 32 are used. That is the reason the scanner code you've posted only lists internal I2C devices.

              Here is an I2C scanner which scans both internal and external I2C:

              #include <M5EPD.h>
              
              // I2C (internal) - SDA: 21, SCL: 22
              // I2C (external - Port A) - SDA: 25, SCL: 32
              
              void setup()
              {
                M5.begin();
                Wire1.begin(25, 32);
              }
              
              void loop()
              {
                int address;
                int error;
              
                Serial.println("Scanning internal I2C");
                for(address = 1; address < 127; address++)
                {
                  Wire.beginTransmission(address);
                  error = Wire.endTransmission();
                  if(error == 0)
                  {
                    Serial.println(address, HEX);
                  }
                  delay(10);
                }
                delay(500);
              
                Serial.println("Scanning external I2C (PortA)");
                for(address = 1; address < 127; address++)
                {
                  Wire1.beginTransmission(address);
                  error = Wire1.endTransmission();
                  if(error == 0)
                  {
                    Serial.println(address, HEX);
                  }
                  delay(10);
                }
                delay(5000);
              }
              

              BTW: you can find the information about the GPIOs used on PortA when you look at the sticker on the back of M5Paper.

              Cheers
              Felix

              P.S. Yes, an Alpha version of UIFlow for M5Paper is available.

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

              P 1 Reply Last reply Reply Quote 0
              • P
                Powersoft @felmue
                last edited by

                @felmue Thank you Felix. What strikes me now is that the original I2C address 0x30 has been changed to 0x58. Does this mean that I have to edit the original LIB of Adafruit?
                Or is there a trick to keep using the address 0x30?
                Cheers
                Jan

                1 Reply Last reply Reply Quote 0
                • P
                  Powersoft
                  last edited by

                  Felix,
                  Sorry, I made a mistake. The address the scanner sees is 0x58, which is correct. The address of the SGP30 is also 0x58.

                  Still, the test program will not run!

                  #include <M5EPD.h>
                  #include <Wire.h>
                  #include "Adafruit_SGP30.h"
                  
                  Adafruit_SGP30 sgp;
                  
                  void setup() {
                    M5.begin();
                    Serial.println("\n\n=====SGP30 test====");
                  
                    if (! sgp.begin()){
                      Serial.println("Sensor not found ...........");
                      while (1);
                    }
                    Serial.print("Found SGP30 serial #");
                    Serial.print(sgp.serialnumber[0], HEX);
                    Serial.print(sgp.serialnumber[1], HEX);
                    Serial.println(sgp.serialnumber[2], HEX);
                  }
                  
                  void loop()
                  {
                  }
                  

                  This is my message now:

                  21:20:51.388 -> 
                  21:20:51.388 -> 
                  21:20:51.388 -> =====SGP30 test====
                  21:20:51.388 -> Sensor not found ...........
                  

                  Hope you can help me out, because this is for me a general problem.
                  Wont connect several I2C devices to the M5Paper.

                  Cheers,
                  Jan

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

                    Hello @Powersoft

                    the two I2C use Wire (internal) and Wire1 (external). By default the Adafruit library uses Wire, but for M5Paper we want it to use Wire1. Luckily the sgp.begin() function allows to overwrite the default.

                    Try something like this (untested):

                      M5.begin(); // initialises internal I2C (uses Wire)
                      Wire1.begin(25, 32); // initialises external I2C (uses Wire1)
                      Serial.println("\n\n=====SGP30 test====");
                    
                      if (! sgp.begin(&Wire1)){
                    

                    Hope this works.

                    Cheers
                    Felix

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

                    1 Reply Last reply Reply Quote 0
                    • P
                      Powersoft
                      last edited by

                      Felix, I've tried it and for this device it is working. But when I try it with a BMP280 it is not working. I think it is depending on the header of the program.
                      I will investigate this further.

                      Cheers,
                      Jan

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

                        Hello @Powersoft

                        thank you for reporting back. I am glad it works - well, at least for this device.

                        And yes, not all libraries allow for the Wire/Wire1 parameter to be supplied via begin() function call. There are a lot of libraries which have Wire hard coded. In such a case you can modify your local copy of the library to your needs.

                        Thanks
                        Felix

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

                        P 1 Reply Last reply Reply Quote 0
                        • P
                          Powersoft @felmue
                          last edited by

                          @felmue
                          Is there a principal difference in the I2C approach between the M5Paper and the CORE2?

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

                            Hello @Powersoft

                            yes and no. They both use a different set of GPIOs for internal and external I2C (unlike M5Stack Fire, Gray, etc., which use the same).

                            However M5Paper uses Wire for the internal I2C and Wire1 for external I2C. M5Core2 does it the other way round and uses Wire1 for internal I2C and Wire for external I2C.

                            When M5Core2 came out I thought the assignment makes a lot of sense since a lot of external libraries have Wire hard coded (as I mentioned already) so on M5Core2 those libraries can be used without modification.

                            Why on M5Paper the M5Stack engineers decided to use it the other way round is anyones guess. If I had to guess it was a different engineer preparing M5Paper than M5Core2, but that is my personal opinion alone.

                            The other thing is that M5Core2 always initialises Wire1 and Wire can be initialised via a parameter in M5.begin() whereas on M5Paper only Wire is initialised always by default.

                            Other than that I don't think there are any other differences regarding I2C of this two devices.

                            Thanks
                            Felix

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

                            1 Reply Last reply Reply Quote 0
                            • P
                              Powersoft
                              last edited by

                              I will stop to interface I2C devices to the M5Paper.
                              Tried to make a connection with various devices, no positive results so far. It is a pity that they have taken this path. Now a number of devices are no longer usable for me on the M5Paper.

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

                                Hello @Powersoft

                                I am sorry to hear that. I found that sometimes it is helpful to take a break, work on something different for a while and then come back with fresh ideas.

                                Best of luck!
                                Felix

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

                                1 Reply Last reply Reply Quote 0
                                • P
                                  Powersoft
                                  last edited by

                                  Today I rewrote the routines for the BMP280 and BME280 for a single device.
                                  Simple include the source into the main program, and call it.
                                  This is now working as I wont. It takes a afternoon of work!
                                  Now put the finishing touches on the BMP280/BME280.

                                  Would it make sense to post them on the forum when they are ready?

                                  Cheers
                                  Jan

                                  ajb2k3A 1 Reply Last reply Reply Quote 0
                                  • ajb2k3A
                                    ajb2k3 @Powersoft
                                    last edited by

                                    @powersoft said in M5Paper I2C:

                                    Today I rewrote the routines for the BMP280 and BME280 for a single device.
                                    Simple include the source into the main program, and call it.
                                    This is now working as I wont. It takes a afternoon of work!
                                    Now put the finishing touches on the BMP280/BME280.

                                    Would it make sense to post them on the forum when they are ready?

                                    Cheers
                                    Jan

                                    Hi @Powersoft sorry for the absence, ive had some issues to deal with.
                                    nice work finding the issue.
                                    Create a project in the project forum and post your code and solution in there.

                                    UIFlow, so easy an adult can learn it!
                                    If I don't know it, be patient!
                                    I've ether not learned it or am too drunk to remember it!
                                    Author of the WIP UIFlow Handbook!
                                    M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                                    1 Reply Last reply Reply Quote 0
                                    • ajb2k3A
                                      ajb2k3
                                      last edited by

                                      @powersoft said in M5Paper I2C:

                                      Today I rewrote the routines for the BMP280 and BME280 for a single device.
                                      Simple include the source into the main program, and call it.
                                      This is now working as I wont. It takes a afternoon of work!
                                      Now put the finishing touches on the BMP280/BME280.

                                      Would it make sense to post them on the forum when they are ready?

                                      Cheers
                                      Jan

                                      Hi @Powersoft sorry for the absence, ive had some issues to deal with.
                                      nice work finding the issue.
                                      Create a project in the project forum and post your code and solution in there.

                                      UIFlow, so easy an adult can learn it!
                                      If I don't know it, be patient!
                                      I've ether not learned it or am too drunk to remember it!
                                      Author of the WIP UIFlow Handbook!
                                      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

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