Navigation

    M5Stack Community

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

    SteveM

    @SteveM

    0
    Reputation
    4
    Posts
    499
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    SteveM Follow

    Posts made by SteveM

    • Can't add data to existing SD file

      Hi,
      I have ported my datalogging program from Arduino Mega to the M5Stack Core 2 for AWS.
      It all is now working as I expected except for one behavior.
      On the Arduino, I could open an existing file on SD card and append data to the end of the file.
      On the M5Stack, I can create, open, write to, and close a file on the SD card.
      But when I re-open this file and write more data, it overwrites the existing data in the file.
      It appears the FILE_WRITE specifier is allowing write access but is not moving the file pointer to its end...not sure why not?
      Can anyone suggest what I am doing wrong or provide a workaround?
      Thanks!

      The relevant portion of my test code is below; apologies if it comes through with weird formatting:

      if (!SD.begin(4,SPI,40000000)) { // ******M5 CS line is GPIO4
      Serial.println("initialization failed!");
      while (1);
      }
      Serial.println("initialization done.");

      // open the file. note that only one file can be open at a time,
      // so you have to close this one before opening another.

      NewFile = SD.open("/TRIAL.TXT",FILE_WRITE);  
      char message1[64]="This is just a test";  // 64 byte array
      char message2[64]="It seems to be working so far!";
      

      // delay(5000);
      // if the file opened okay, write to it:
      if (NewFile) {
      NewFile.println(message1);
      NewFile.println(message2);

      // close the file:
      NewFile.close();
      

      } else {
      // if the file didn't open, print an error:
      Serial.println("error initially opening test.txt");
      }

      // Now try reopening file and writing more data into it

       delay(100);
       NewFile = SD.open("/TRIAL.TXT",FILE_WRITE);  //*******Reopen for more writing
       NewFile.println("Trying to add this additional line");
       NewFile.close();
       delay(100);
      posted in Core2 for AWS
      S
      SteveM
    • RE: AWS is unresponsive after Arduino upload

      Felix,
      OK, that works.
      It prints to the LCD and I get output on the serial monitor.
      Thanks for your assistance!
      Regards,
      Steve

      posted in Core2 for AWS
      S
      SteveM
    • RE: AWS is unresponsive after Arduino upload

      Thanks for the good ideas!
      In fact, I had initially loaded the M5Stack library, not the M5Core2 one.
      I have since corrected this.
      I do not see any activity in the serial monitor.

      Below is the test program I uploaded.
      I now am getting a compiler error:
      'class M5Core2' has no member named 'Power'.
      Any suggestions on what's wrong now?

      #include <M5Core2.h>

      /* After M5Core is started or reset
      the program in the setUp () function will be run, and this part will only be run once.
      After M5Core is started or reset, it will start to execute the program in the setup() function, and this part will only be executed once. /
      void setup(){
      M5.begin(); //Init M5Core. Initialize M5Core
      M5.Power.begin(); //Init Power module. Initialize the power module
      /
      Power chip connected to gpio21, gpio22, I2C device
      Set battery charging voltage and current
      If used battery, please call this function in your project */
      M5.Lcd.print("Hello World"); // Print text on the screen (string) Print text on the screen (string)
      }

      /* After the program in setup() runs, it runs the program in loop()
      The loop() function is an infinite loop in which the program runs repeatedly
      After the program in the setup() function is executed, the program in the loop() function will be executed
      The loop() function is an endless loop, in which the program will continue to run repeatedly */
      void loop() {

      }

      posted in Core2 for AWS
      S
      SteveM
    • AWS is unresponsive after Arduino upload

      Hi, I am new to M5Stack use and I hope to port my existing Arduino code to the Core 2 AWS I just bought. It started up OK when first plugged into my PC and I was able to set the time. But after I compiled and uploaded the suggested test program (print "Hello World"), the screen froze and did not display this text. I powered unit off but now it is unresponsive and it won't do anything.

      Any suggestions on what to try next?

      posted in Core2 for AWS
      S
      SteveM