M5Paper I2C
-
When I check the I2C bus with the I2C scanner I see 4 items, looks like to be correct. Received yesterday the DDS Unit, its communicates via I2C address 0x31. When I connected it to the M5Paper the I2C scanner is not detected the DDS. Checked it with the M5Stack-Fire no problems to detect. Also tied is it with an other I2C device with the same results. Sommeting wrong with this port?
-
What code are you using for the scanner?
Just run a test on mine using this code
And getting a working scan. -
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 }
-
Ahh, I'm not sure about arduino as I'm working on documenting UIFlow.
-
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!
-
@ajb2k3 is UIFlow working on the M5Paper?
-
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
FelixP.S. Yes, an Alpha version of UIFlow for M5Paper is available.
-
@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 -
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 -
Hello @Powersoft
the two I2C use
Wire
(internal) andWire1
(external). By default the Adafruit library usesWire
, but for M5Paper we want it to useWire1
. Luckily thesgp.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 -
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 -
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 viabegin()
function call. There are a lot of libraries which haveWire
hard coded. In such a case you can modify your local copy of the library to your needs.Thanks
Felix -
@felmue
Is there a principal difference in the I2C approach between the M5Paper and the CORE2? -
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 andWire1
for external I2C. M5Core2 does it the other way round and usesWire1
for internal I2C andWire
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
andWire
can be initialised via a parameter inM5.begin()
whereas on M5Paper onlyWire
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 -
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. -
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 -
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 -
@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
JanHi @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. -
@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
JanHi @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.