ADC module of UNO Q is not working!

I have compiled and uploaded the following sketch in UNO Q under Arduino IDE 2.3.7. Unfortunately, nothing is appearing in the Serial Monitor. I have double checked the Bd and they are the same in both the sketch and the Bd box of Serial Monitor.

void setup() 
{
  Serial.begin(115200);
  while (!Serial)
    ;  // wait for Serial Monitor
}

void loop() 
{
  int adcValue = analogRead(A0);  
  float voltage = (3.3 / 1023.0)*adcValue;  // 3.3V reference
  Serial.print("ADC = ");
  Serial.print(adcValue, 1);
  Serial.println(" V");

  delay(1000);
}

What a silly mistake am I making? Or does the board need some software updating? I can run Blink sketch from IDE and Blink LED app from App Lab without any issue.

Dividing by 1023, and not 1024.

OK! I have changed 1023.0 to 1024.0, and still noting is apparing on Serial Monitor.

Yes! I have done silly mistake which is that I have not gone through the UNO Q User Manual according to which the sketch should be like this: (Now, the ADC is working good!)

#include <Arduino_RouterBridge.h>

void setup() 
{
  Monitor.begin(115200);
}

void loop() 
{
  int adcValue = analogRead(A0);  
  float voltage = (3.3 / 1023.0)*adcValue;  // 3.3V reference
  Monitor.print("ADC = ");
  Monitor.print(voltage, 1);
  Monitor.println(" V");

  delay(1000);
}

Output: (test volt: 3.3 V ---- 2.2k --- A0 ----- 2.2k -----GND)

ADC = 1.7 V
ADC = 1.7 V
ADC = 1.7 V
ADC = 1.7 V
ADC = 1.7 V
ADC = 1.7 V

I would be glad if someone explains why the Monitor object is needed in place of Serial object and the necessity of the Arduino-RouterBridge.h Library file.

At this point, the experienced developer would have tried the most basic “Hello World!” sketch, before arriving at the conclusion that the ADC is not working.

1 Like

Yes!
The thread title could have been like this:
Data from UNO Q's ADC module are not appearing on Serial Monitor

The simplest explanation is this requirement results from the hardware of the Uno Q. Serial connects to the pins on the uno header and monitor routes through the bridge and is relayed by the MPU to either USB or WiFi depending on the current connection (or to a local terminal in SBC mode presumably). In a word, flexibility. Only the MPU can serve this flexibility.

1 Like

Writing to Serial works fine on the Uno Q. Serial is the STM32u585 UART connected to pins 0 Rx and 1 Tx. The other UART connected to the QRB processor is Serial1/Monitor/RouterBridge. Using RouterBridge is optional.

This is a valid hello.ino program on Uno Q.

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hello");
  delay(1000);
}

To see the output connect a USB serial cable to GND, 0 Rx, and 1 Tx. Plug the USB end into Uno Q via a USB hub.

In my case, using a DSD Tech SH-U09C5 jumpered for 3.3V logic levels, the serial port appears on Linux as /dev/ttyUSB0.

In the hello directory with hello.ino add sketch.yaml with default arduino-cli parameters. This saves repeating the parameters on every command.

profiles:
  default:
    fqbn: arduino:zephyr:unoq
    platforms:
      - platform: arduino:zephyr
    libraries:
default_profile: default
default_port: /dev/ttyUSB0
default_port_config:
  baudrate: 115200

The following appears in the terminal window for compile, upload, and monitor. I use arduino-cli instead of App Lab when building non App Lab Arduino code.

arduino@UnoKyu:~/hello$ ls
hello.ino  sketch.yaml
arduino@UnoKyu:~/hello$ arduino-cli compile
Sketch uses 1524 bytes (0%) of program storage space. Maximum is 1966080 bytes.
Global variables use 472 bytes (0%) of dynamic memory, leaving 523152 bytes for local variables. Maximum is 523624 bytes.

Note upload uses SWD so it does not use /dev/ttyHS1 or /dev/ttyUSB0.

arduino@UnoKyu:~/hello$ arduino-cli upload
Open On-Chip Debugger 0.12.0+dev-ge6a2c12f4 (2025-05-22-15:51)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
clock_config
/tmp/remoteocd/sketch.elf-zsk.bin
Info : Linux GPIOD JTAG/SWD bitbang driver (libgpiod v2)
Info : Note: The adapter "linuxgpiod" doesn't support configurable speed
Info : SWD DPIDR 0x0be12477
Info : [stm32u5.ap0] Examination succeed
Info : [stm32u5.cpu] Cortex-M33 r0p4 processor detected
Info : [stm32u5.cpu] target has 8 breakpoints, 4 watchpoints
Info : [stm32u5.cpu] Examination succeed
Info : [stm32u5.ap0] gdb port disabled
Info : [stm32u5.cpu] starting gdb server on 3333
Info : Listening on port 3333 for gdb connections
CPU in Non-Secure state
[stm32u5.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x41000000 pc: 0x08019392 psp: 0x2002ccf8
Info : device idcode = 0x30076482 (STM32U57/U58xx - Rev U : 0x3007)
Info : TZEN = 0 : TrustZone disabled by option bytes
Info : RDP level 0 (0xAA)
Info : flash size = 2048 KiB
Info : flash mode : dual-bank
Info : Padding image section 0 at 0x080f1d74 with 12 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x080f1d80 .. 0x080f1fff
shutdown command invoked
New upload port: /dev/ttyUSB0 (serial)

Serial port monitor.

arduino@UnoKyu:~/hello$ arduino-cli monitor
Monitor port settings:
  baudrate=115200
  bits=8
  dtr=on
  parity=none
  rts=on
  stop_bits=1

Connecting to /dev/ttyUSB0. Press CTRL-C to exit.

Hello
Hello
Hello
Hello

Using arduino-cli results in a fast compile/test cycle for tasks like testing i2c code to use Wire1 instead of Wire. Using Serial can also be useful when using App Lab because debug goes out Serial instead of Monitor (Serial1). Excessive Monitor.print can clog up Serial1 and delay other bridge traffic.

1 Like

From your post this is my understanding:

1. Data from A0-pin of MCU goes to MPU over the router bridge.

2. Data from MPU goes to the USB-C connector and then to the PC. The USB signal is transformed into asynchronous serial format using virtual COM port and then appears on the ASCII type OutputBox of the classic Serial Monitor (now it is Serial Console) of the Arduino IDE.

3. The activitie of Step-1, 2 are perfomed when the user includes the following codes in the Aduino sketch.

Monitor.begin();
Monitor.print();

4. Do you know if it is the UART or I2C or SPI or USB network that the router bridge uses?

5. AI says that there is no need to enter Bd into Monitor.begin() function. Data transfer takes place at the possible maximum speed. My question is:

Say, the router bridge uses SPI network. Does the MCU not writing data into this port at a known speed (bits/sec)?

5. Is it UART0 or UART1 or UART2 which is available at DPin-0/1 of the header of the board? I would like to communicate with UNO R3's software UART port using level shifter.

7. During uploading using IDE, data goes to the MPU and then the MPU's bootloader based programmer negotiates with bootloader based programmer of MCU for onward writing into flash/RAM of MCU as desired. Does this make sense? My earlier conceptual diagram is revised and presented below (Fig-1).


Figure-1:

UART

Yes. It is 115200 baud:

Use the Serial object in your sketch code to communicate via the UART interface on these pins.

Here is an overview of the process:

  1. The development tool (Arduino IDE or Arduino App Lab) compiles the sketch program.
  2. The development tool runs the remoteocd tool:
    https://github.com/arduino/ArduinoCore-zephyr/blob/0.53.0/platform.txt#L268-L289
  3. remoteocd determines the communication channel to the Linux machine on the UNO Q:
    • Local: remoteocd is running on the Linux machine of the UNO Q.
    • ADB: remoteocd is running on a host PC connected to the UNO Q via a USB cable.
    • SSH: remoteocd is running on a host PC connected to the UNO Q via a network connection.
  4. If running on a host PC, remoteocd transfers (using either Android Debug Bridge or ssh) the compiled sketch binary and appropriate OpenOCD configuration file over the communication channel to the UNO Q's Linux machine.
  5. remoteocd invokes the OpenOCD uploader tool on the UNO Q's Linux machine.
  6. OpenOCD uploads the compiled sketch binary to the UNO Q's MCU.

You can see the specific commands that are invoked by enabling the "Verbose output during: upload" preference in Arduino IDE, uploading a sketch to the UNO Q, then examining the content of the black console window at the bottom of the Arduino IDE window after the upload finishes.

2 Likes

I am very happy to read your reply, as it has helped me revise my concepts and understanding.

1 Like