# Basic example of UNO Q: Analog volt. to WebUI problem

**URL:** <https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723>\
**Category:** UNO Q\
**Created:** [February 8, 2026, 1:01pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723 "2026-02-08T13:01:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stvgr\_dev](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stvgr_dev/32/1257922_2.png) [@stvgr\_dev](https://forum.arduino.cc/u/stvgr_dev)\
**Post date:** [February 8, 2026, 1:01pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/1 "2026-02-08T13:01:50Z")

</div>

I try to make a very basic app that reads an analog voltage to be displayed in WebUI (and a LCD, if connected). Everything seems to wrk well exept that the value don't show in the WebUI.  
UNO-Q 2MB, windows

 ![WebUI](https://europe1.discourse-cdn.com/arduino/original/4X/4/6/f/46f53564875e3ca1a6783d194212b8c9441a178c.png)

```arduino
/*
    Sketch: Analog input to WebUI
    
    (LCD connected via voltage level translation 3,3V to 5V)
*/

// include the library code:
#include <LiquidCrystal.h>
#include <Arduino_RouterBridge.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 7, en = 6, d4 = 1, d5 = 5, d6 = 2, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int rw = 10;

int ext_input_A = 9; // isolated input rom shield 5V
int D2_LED = 12; // isolated output to shield 5V: D2-LED
int D3_LED = 11; // isolated output to shield 5V: D3_LED

boolean LCD_on_ext_A = false; // default as LOW when LCD shield is not connected

const float V_REF = 3.3; // 3,3V for UNO-Q inputs
const float R_BITS = 10.0; // number of bits ADC-resolution
const float ADC_STEPS = (1 << int(R_BITS)) - 1; // Number of steps (2^R_BITS - 1)

int sensorValueDigital = 0; // binary/digital value
float quotient = 0.0; // floating point number with integer and decimal part
int intPart = 0; // the integer part of conversion from binary to decimal value from ADC: A0
float decimal_part = 0.0;
int desimal_as_int = 0;

void setup() {
  // put your setup code here, to run once:

  Bridge.begin();
  Monitor.begin();

  pinMode(rw, OUTPUT);
  digitalWrite(rw, LOW);

  pinMode(ext_input_A, INPUT);
  LCD_on_ext_A = digitalRead(ext_input_A);

  if (LCD_on_ext_A == true) { // LCD shield connected?
    // ---------------LCD 40x2 setup --------------------
    lcd.begin(40, 2);
    delay(3000); // wait for LCD to start up
    lcd.setCursor(0, 0);
    delay(50);
    lcd.print("UNO-Q: Analog voltage from A0, ");
    delay(30);
    lcd.print(int(R_BITS));
    delay(30);
    lcd.print(" bits: ");
    delay(50);
    //Monitor.println("LCD is connected. ");
  }

  pinMode(D2_LED, OUTPUT); // (leds can be used for extra info)
  digitalWrite(D2_LED, LOW); // shield-5V: D2-LED off
  pinMode(D3_LED, OUTPUT);
  digitalWrite(D3_LED, LOW); // shield-5V: D3-LED off
}

void loop() {
  // main code run repeatedly:
  delay(5000);
  digitalWrite(D2_LED, HIGH); // shield-5V: D2-LED ON
  sensorValueDigital = analogRead(A0);

  // asynchronous notification
  Bridge.notify("sensor_data", sensorValueDigital); // send binary value to main.py
  Monitor.print("ADC bin value: ");
  Monitor.println(sensorValueDigital); // check the value in Serial Monitor

  if (LCD_on_ext_A == true) {
    printOut_LCD(); // convert and print to LCD
  }
  digitalWrite(D2_LED, LOW); // shield-5V: D2-LED off
  delay(2000);
}

// convert the binary value to two integer numbers separated by a decimal point
// and print to LCD
void printOut_LCD() {
  quotient = (sensorValueDigital / ADC_STEPS) * V_REF; // floating point number with integer and decimal part
  intPart = (sensorValueDigital / ADC_STEPS) * V_REF; // the integer part of the conversion
  decimal_part = quotient - intPart; // the decimal part of the conversion
  desimal_as_int = decimal_part * 1000; // move the decimal point; keeping three digits, and convert to integer
  lcd.setCursor(0, 1);
  delay(50);
  lcd.print(" "); // delete previous content in row
  delay(30);
  lcd.setCursor(0, 1);
  delay(50);
  lcd.print(intPart); // integer part: (x,---)
  delay(30);
  lcd.print(",");
  delay(30);
  if (desimal_as_int < 10) {
    lcd.print("00");
    delay(30);
    lcd.print(desimal_as_int); // thousandths: (-,00x)
    delay(30);
  } else if (desimal_as_int < 100) {
    lcd.print("0");
    delay(30);
    lcd.print(desimal_as_int); // hundredths and thousandths: (-,0xx)
    delay(30);
  } else {
    lcd.print(desimal_as_int); // tenths, hundredths and thousandths: (-,xxx)
    delay(30);
  }
  lcd.print(" Volt");
  delay(3);
}

```

python:

```arduino
import time

from arduino.app_utils import App, Bridge
from arduino.app_bricks.web_ui import WebUI

# initialize WebUI
web_ui = WebUI()

print("Hello world!")

def sensor_data_callback(value):
  # Prosess the data if needed
  print(f"Received from sketch: ", {value})
  # Send the data to the web UI using the same key/event name
  web_ui.send_message('sensor_data_update', value)

# Register the callback function with the Bridge
Bridge.provide("sensor_data", sensor_data_callback)

def loop():
    time.sleep(1)

App.run(user_loop=loop)
# See: https://docs.arduino.cc/software/app-lab/tutorials/getting-started/#app-run

```

app.js:

```arduino

let errorContainer;

/*
 * Socket initialization. We need it to communicate with the server
 * <script src="app.js"></script>
 */
const socket = io(`http://${window.location.host}`); // Initialize socket.io connection

// Start the application
document.addEventListener('DOMContentLoaded', () => {
    errorContainer = document.getElementById('error-container');
    initSocketIO();
    });

function initSocketIO() {
  socket.on('connect', () => {
      if (errorContainer) {
          errorContainer.style.display = 'none';
          errorContainer.textContent = '';
      }
  });

  socket.on('sensor_data_update', (value) => {
    updateValue(value);
  });
  
  socket.on('disconnect', () => {
    if (errorContainer) {
      errorContainer.textContent = 'Connection to the board lost. Please check the connection.';
      errorContainer.style.display = 'block';
    }
  });
};

function updateValue(bin_value) {
  console.log("Received binary value: ", bin_value);
  document.getElementById("my-text-box").textContent = bin_value;
  //valueTxtBox.textContent = status;
}

```

index.html:

```arduino
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Analog input to web UI</title>
</head>
<body>
    <h1>Binary code value: <span id="my-text-box">n/a</span></h1>
    <script src="libs/socket.io.min.js"></script>
    <script src="app.js"></script>
</body>
</html>

```

 ![python monitor](https://europe1.discourse-cdn.com/arduino/original/4X/5/6/a/56ad258e5a35c31f1ad11e9984d8cda56e547858.png)

 ![Bricks, libs, files](https://europe1.discourse-cdn.com/arduino/original/4X/1/4/e/14ec89dada62afc2d6ce15d48ef8c64b593b75aa.png)

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [February 8, 2026, 1:28pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/2 "2026-02-08T13:28:22Z")

</div>

I have run your app in my App Lab 0.4.0 and it works well. I have connected 3.3/2 = 1.65 V at A0-pin and the UI shows the following which seems to be alright:  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/e/8/7/e87c13a3aa2952ccbe1d074ff06cfb1e1fd023ed.png)  
==\> (1023/3.3) x 3.3/2 = 512

---

<div class="post-metadata">

**Author:** ![stvgr\_dev](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stvgr_dev/32/1257922_2.png) [@stvgr\_dev](https://forum.arduino.cc/u/stvgr_dev)\
**Post date:** [February 8, 2026, 1:32pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/3 "2026-02-08T13:32:29Z")

</div>

Thank you for helping. Could I have a problem because of the browser; Microsoft Edge Beta?

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [February 8, 2026, 2:07pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/4 "2026-02-08T14:07:05Z")

</div>

> [@stvgr\_dev](#):
>
> Could I have a problem because of the browser; Microsoft Edge Beta?

What is your setup?

My setup:  
IBMPC WIN10  
App Lab 0.4.0  
UNO Q

I have copied an app from the examples of App Lab and then have deleted sketch, python, js, html. After that I have just copied your codes from #1 into the appropriate locations of the editor and then have clicked on the RUN button. Your app is working!

---

<div class="post-metadata">

**Author:** ![stvgr\_dev](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stvgr_dev/32/1257922_2.png) [@stvgr\_dev](https://forum.arduino.cc/u/stvgr_dev)\
**Post date:** [February 8, 2026, 2:32pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/5 "2026-02-08T14:32:22Z")

</div>

A miracle has happened!!!  
I tried to do like you: deleted all content in a app copy and pasted my code instead and now it works.  
Thank you a lot! I have struggeled with this for weeks...

---

<div class="post-metadata">

**Author:** ![GolamMostafa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/golammostafa/32/239011_2.png) [@GolamMostafa](https://forum.arduino.cc/u/GolamMostafa)\
**Post date:** [February 8, 2026, 3:35pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/6 "2026-02-08T15:35:06Z")

</div>

This is the joyful moment when something works!

@ptillisch may explain why is the app working this way.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 7, 2026, 3:35pm UTC](https://forum.arduino.cc/t/basic-example-of-uno-q-analog-volt-to-webui-problem/1429723/7 "2026-08-07T15:35:13Z")

</div>

Closed on August 7, 2026, 3:35pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
