@teastain Thanks Teastain! I was looking into some esp-now examples but it was a bit of a struggle trying to figure out what is supposed to work. (A lot of examples and a lot of wrong ways to implement esp-now). Your code gave me the jump I needed. I was able to adapt your code to read Rfid tags and get cross talk happening! Thanks again!
Abraxas
@Abraxas
So I decided to go into the field of mechatronics. What I didn’t realize was that it wasn’t a field, it was a wild frontier. The more I explore the wilder it gets and the more I realize there is more out there than I could possibly comprehend. I’ve met many people out on this frontier. Some have been out here longer than others. And I have to say, it’s a real treat to sit down, share ideas, and learn from all of them!
Best posts made by Abraxas
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
-
RE: Stepper motor module clarification needed
I look forward to hearing about your hacking ideas. Best of luck :)
Latest posts made by Abraxas
-
RE: M5 AtomS3 Lite And Arduino Serial Monitor
@felmue thank you for making me aware of that thread! The information contained within worked like a charm!
-
M5 AtomS3 Lite And Arduino Serial Monitor
So, I'm not sure what is going on or if I'm doing something wrong here, but I'm looking to troubleshoot an M5 AtomS3 Lite (via USB) using the Arduino's built in serial monitor on my Mac.
I have some simple code shown below to test the serial monitor output but no data is being displayed despite a successful upload and run by the M5 AtomS3 Lite. Any help or suggestions here would be great.
#include "M5AtomS3.h" void setup() { AtomS3.begin(true); AtomS3.dis.setBrightness(100); AtomS3.dis.drawpix(0x0000ff); AtomS3.update(); Serial.println("Click BtnA to Test"); } void loop() { AtomS3.update(); if (AtomS3.BtnA.wasPressed()) { AtomS3.dis.drawpix(0xff0000); AtomS3.update(); Serial.println("Pressed"); } if (AtomS3.BtnA.wasReleased()) { AtomS3.dis.drawpix(0x00ff00); AtomS3.update(); Serial.println("Released"); } }
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
@teastain Thanks Teastain! I was looking into some esp-now examples but it was a bit of a struggle trying to figure out what is supposed to work. (A lot of examples and a lot of wrong ways to implement esp-now). Your code gave me the jump I needed. I was able to adapt your code to read Rfid tags and get cross talk happening! Thanks again!
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
@teastain said in M5Dial's External Port A I2C Capability or Lack Thereof:
ESP_NOW
No, mostly because I did not know this protocol existed. This looks like it could be a promising avenue. Thanks for the suggestion Teastain!
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
@felmue said in M5Dial's External Port A I2C Capability or Lack Thereof:
here
Your assumption is correct. From my understanding of I2C, it seems like an I2C bus should be able to support multiple masters on the same bus. And it should be possible to have a master receive information as long as it is not busy sending information.
With that said, it was busy with the RFID peripheral so maybe that's the problem or I could be entirely mistaken all together on how I2C works. You've given me some documents to digest as well. So I'll get back to you with a new configuration hopefully soon. Thanks!
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
@felmue Yes, I did hit an issue. I looked at your code but it seems to be looking at what's on the bus but the bus is not experiencing any real data traffic because the peripherals are not being used. I'm not really sure that it can be used as a true test of both internal and external bus capabilities.
Below is some code I modified using M5stack's RFID example and added I2C communication.// Libraries to include #include "M5Dial.h" // Set up and initialize constants and variables const byte MY_ADDRESS = 0x12; const byte SLAVE_ADDRESS = 0x13; String uid = ""; String oldUid = ""; void setup() { // Initialize dial rfid and screen auto cfg = M5.config(); M5Dial.begin(cfg, false, true); M5Dial.Display.setTextColor(GREEN); M5Dial.Display.setTextDatum(middle_center); M5Dial.Display.setTextFont(&fonts::Orbitron_Light_32); M5Dial.Display.setTextSize(1); M5Dial.Display.drawString("RFID Card", M5Dial.Display.width() / 2, M5Dial.Display.height() / 2); // Set up I2C address and recieve transmission event handling Wire.begin (MY_ADDRESS); Wire.onReceive (receiveEvent); } void loop() { // Find out if a card is available for reading if(M5Dial.Rfid.PICC_IsNewCardPresent() && M5Dial.Rfid.PICC_ReadCardSerial()) { uint8_t piccType = M5Dial.Rfid.PICC_GetType(M5Dial.Rfid.uid.sak); // Check to see if PICC is Classic MIFARE type if(piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) { M5Dial.Display.clear(); M5Dial.Display.drawString("no support", M5Dial.Display.width() / 2, M5Dial.Display.height() / 2); return; // bad card - loop done } // else get UID data uid = ""; for(byte i = 0; i < M5Dial.Rfid.uid.size; i++) { uid += String(M5Dial.Rfid.uid.uidByte[i], HEX); } // And output stored UID data to the screen if its a different card from the card scanned previously. if(uid != oldUid) { M5Dial.Display.clear(); M5Dial.Speaker.tone(8000, 20); M5Dial.Display.drawString(M5Dial.Rfid.PICC_GetTypeName(piccType), M5Dial.Display.width() / 2, M5Dial.Display.height() / 2 - 30); M5Dial.Display.drawString("card id:", M5Dial.Display.width() / 2, M5Dial.Display.height() / 2); M5Dial.Display.drawString(uid, M5Dial.Display.width() / 2, M5Dial.Display.height() / 2 + 30); oldUid = uid; // Also send uid data to microcontroller Wire.beginTransmission(SLAVE_ADDRESS); Wire.write(uid.c_str()); Wire.endTransmission(); } } } // recieve and display UID data from another M5Dial void receiveEvent(int tSize) { uid = ""; for(int i = 0; i < tSize; i++) { uid += Wire.read(); } M5Dial.Display.clear(); M5Dial.Speaker.tone(8000, 20); M5Dial.Display.drawString("card id:", M5Dial.Display.width() / 2, M5Dial.Display.height() / 2); M5Dial.Display.drawString(uid, M5Dial.Display.width() / 2, M5Dial.Display.height() / 2 + 30); oldUid = uid; }
The code above can be copied over to another M5Dial and the addressing is just swapped. Theoretically it should work but when one dial receives RFID card data the other does not display this information. I think that it is transmitting this information but on the interior bus not the external bus. To fix this I added a line to my setup code to include the external I2C bus shown below:
Wire.begin (13, 15);
However that seemed to kill RFID functionality. And this is where I currently sit, hence the questions and comments above hoping for some help.
-
RE: M5Dial's External Port A I2C Capability or Lack Thereof
@robski Not a bad idea but UART is located on pins G43 and G44 which are not broken out (Port B is G1 and G2). I might be able to use the USB C port but that's just a hassle and a half as far as prototyping, debugging, and expansion is concerned.
-
M5Dial's External Port A I2C Capability or Lack Thereof
I was pretty excited to see an external I2C port (G13 - SDA & G15 - SCL) on the M5dial since it seems to act more like a self-contained smart sensor than a microcontroller. I figured this I2C port could potentially allow it to communicate with another micro-controller/computer allowing it to relay quite a bit of information along. However, I'm not really seeing a way to initialize and use this port for this purpose. Am I missing something here? I know the dial has an internal I2C port (G11 - SDA & G12 - SCL) being used to read RFID, touch screen, and RTC functions. Does this interfere with having a second I2C bus open?
-
RE: Error Reading from an SD card
@M5Stack After looking at your comment again I figured out what you were trying to tell me (Took me a while to figure it out). I forgot to tell the M5Stack where to look for the text file using /sd/file_name. That took care of the error. Still am unable to print what I want to the screen but at least I'm one step closer.
-
RE: Error Reading from an SD card
Hi M5Stack,
Thanks for your answer but this really doesn't help me. I'm trying to create a database so that I can cherry pick the information I want to show the user based on their inputs. The code you sent me takes all data and throws it up on the screen regardless of whether the user asked for that information or not. Here is a small example using python:SD card file data:
Python code:
Python output:
The M5stack does have the ability to parse out information from a list of list, I know because I tested it, but I'm having trouble reading the file from an SD card and creating a list of lists (basically an in memory ready data base.) The reason for the SD card is because this information changes depending on the project. Changing information on an SD card (or switch SD cards) is a lot easier than programming information straight to the M5stack.
Also based on your answer where is fs.close()? Does the M5stack automatically do this or is the file left open while the program is running. If the file is left open while the program is running, how do you mitigate file corruption when loss of power to the M5Stack occurs?