Does Arduino UNO Q provide an API for reading and writing Flash?

I am using the MCU of UNO Q to control sensors, and I want to store some important sensor data in flash so that it won't be lost in case of power loss. Does the official provide corresponding API?

You may try the following options:
1. Using EEPROM.h Libray to emulate MCU's flash as non-volatile memory.
2. Send senson data o MPU over router bridge for storing into eMMC memory.


can not find EEPROM.h,What should I do?

I have also tried option-1 of post #2; but, I could not make it work. It might be that @KurtE know how to use Zephyr to store data into flash of MCU.

Now, you may try Option-2.

Do you know of any function API that can store data in the eMMC of the MPU?

I am giving you an app below that writes ADC0 value of MCU into eMMC. MPU reads back the value and sends to MCU. If you want, I can provide you a simplfied version of the script.


Figure-1:
Sketch:

#include <Arduino_RouterBridge.h>

String fileContent = "";
bool status = false;
unsigned long prMillis = millis();

void setup() 
{
  Bridge.begin();
  Monitor.begin();
  delay(5000);
} 
   
void loop() 
{
  int adcValue = analogRead(A0);
  Bridge.call("log_sample_to_emmc", 1, adcValue);// i + 1, adcValue);
  
  do
  {
    RpcCall rpc = Bridge.call("read_adc_file");
    status = rpc.result(fileContent);
  }
  while(status != true && millis() - prMillis < 5000);
  if(status == true )
  {
    status = false;
    Monitor.println(fileContent);
  } 
  else 
  {
    Monitor.println("Error: Failed to read file from eMMC.");
  }
  delay(3000);
}

Script:

import time
import os
from arduino.app_utils import *

# File path located directly on the MPU's eMMC storage
FILE_PATH = "/home/arduino/adc.txt"

def log_sample_to_emmc(sample_num, value):
    print("Writing data into eMMC")
    # Generate timestamp formatted as: YYYY-MM-DD HH:MM:SS
    timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
    log_line = f"[{timestamp}] Sample #{sample_num}: Value = {value}\n"
    print(log_line)
    
    # On the first sample, clear any previous file data
    mode = "w" if sample_num == 1 else "a"
    
    try:
        with open(FILE_PATH, mode) as f:
            f.write(log_line)
            #print("Data writing ok");
        return True
    except Exception as e:
        print(f"Error writing to eMMC: {e}")
        return False

def read_adc_file():
    print("Reading data from eMMC")
    if not os.path.exists(FILE_PATH):
        #print("Error")
        return "Error: File does not exist yet."
    
    try:
        with open(FILE_PATH, "r") as f:
            #print("No error")
            fContent = f.read()
            print(fContent)
            return fContent #f.read()
    except Exception as e:
        return f"Error reading file from eMMC: {e}"

def main():
    # Register the functions so the C++ sketch can call them
    Bridge.provide("log_sample_to_emmc", log_sample_to_emmc)
    Bridge.provide("read_adc_file", read_adc_file)
    
    print("Python MPU Service Started. Waiting for MCU requests...")
    
    # Keep the script running to listen for RPC commands
    while True:
        time.sleep(1)

if __name__ == "__main__":
    main()

Output:
Python Console: (with A0 at 3.3V)

[2026-09-13 15:22:00] Sample #1: Value = 1022
Writing data into eMMC
[2026-09-13 15:22:03] Sample #1: Value = 1023
Reading data from eMMC
[2026-09-13 15:22:03] Sample #1: Value = 1023
Writing data into eMMC
[2026-09-13 15:22:06] Sample #1: Value = 1023
Reading data from eMMC

Seral Monitor: (with A0 at 3.3V)

[2026-09-13 15:21:15] Sample #1: Value = 1023

[2026-09-13 15:21:18] Sample #1: Value = 1023

[2026-09-13 15:21:21] Sample #1: Value = 1022

You are welcome to ask questions on the sketch and script to Gemini and me.

Thank you very much.

You are welcome.

We can use EEPROM.h librray of UNO R3 to emulate some part of flash of ESP8266 to work as non-volatile EEPROM. Can we do similar thing for the MCU of UNO Q? Perhaps not unless we take the help of Zephyr RTOS.

Quick side notes:

a) The Teensy boards, uses part of the flash memory to store logical EEPROM stuff, but I don't think that will work with the Q.

b) With the ArduinoCore-zephyr GIGA boards, they have it setup be able to use part of the flash storage as a FileSystem. With this on the GIGA, I have code where I read/write a
JSON file to the /storage/ partition, however I tried running one of the Storage sketches
on the Q and it failed to link. Also the storage examples are not included in the Arduino Q boards examples for boards, so I don't believe that Arduino enabled it within Zephyr.
Could they? Not sure, I know they can for the ST77h7 boards, but...

c) You could connect up an SPI based SD card reader to the Q pins and read/write stuff using the SDFat github project.

d) Do as @GolamMostafa suggested, which is to communicate with the MPU and have it store stuff in the file system.

Good luck

It is always a pleasure to hear from you.

Note that this file is stored in the filesystem of the Docker container in which the Python script of the App runs. This does work, but it may not be the best approach depending on what is meant by "persistently". The Docker containers aren't expected to contain any essential data, so any containers not currently in use may be deleted in order to free up disk space (as is done if you run arduino-app-cli system cleanup). If that happens, the data stored in the container's file system will be lost.

The container is configured so that it has a volume at /app bound to the App folder on the host machine. This means that if your Python script instead writes data to a file under the /app path of the container. For example:

FILE_PATH = "/app/adc.txt"

that data will be saved to a file in the App's folder on the host machine's filesystem. That will result in the file persisting even if the App's container is deleted.

Having access to the data file from the host machine may also be useful in cases where you wish to be able to examine the contents directly, or work with the file in another application (e.g., a spreadsheet program).

I am running my app with this line: FILE_PATH = "/app/adc.txt"

I have opened Linux Terminal and at present, the prompt is in this directory: /home/arduino.

I want to chnage my directory to app and check the presence of adc/.txt file. How do I do it?

The /app folder inside the container is bound to the folder of the App on the host machine. So the location of adc.txt will depend on the location of the App.

For example, if I have an App named "Foo Bar", then the file will be at this path on the host machine's filesystem:

/home/arduino/ArduinoApps/foo-bar/adc.txt

You should also see the file adc.txt in the "Files" panel of Arduino App Lab when you open the App in that application.

The above works for me.

The above also works for me.

I could not reach at /app folder!

Yeah, if you wanted to see the file at /app/adc.txt you would need to run the App's container with a pseudo-TTY allocated to allow you to use the shell from the container: