🤖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 @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