1. What do you mean by bridge backup?
2. If I have understood your post #1, you want to achieve the following objectives:
(1) To transfer data from MCU (C++ sketch genertaed data) to MPU (Python script is the receiver).
(2) Value passed will be shown on Monitor Console (coupled with sketch) and Python Console (coupled with script) of App Lab.
3. You may try the following hardware setup (Fig-1) and the application (taken from here #1, 6.); where, the MCU acquires data from ADC0-channel and pass it to the MPU using the internal router bridge. If you have no Potentiometer, then you can directly short by a jumper the 3.3V pin with the A0-pin.
Figure-1:
Python Script for MPU (tested)
from arduino.app_utils import *
import time
last_print = 0
interval = 0.1 # seconds between loop checks
# A container to hold the latest ADC value
latest_adc = None
# This function will be called automatically when MCU sends notify
def on_adc(value):
global latest_adc
latest_adc = value
# Subscribe to MCU notifications
Bridge.provide("adc_data", on_adc)
def loop():
global last_print, latest_adc
current_time = time.time()
# Check every 100ms if there is new data
if latest_adc is not None and current_time - last_print >= 1:
voltage = latest_adc * (3.3 / 1023.0)
print(f"ADC: {latest_adc}, Voltage: {voltage:.3f} V") #shows on: Python console
last_print = current_time
App.run(user_loop=loop)
Arduino Sketch for MCU (tested)
#include "Arduino_RouterBridge.h"
void setup()
{
Bridge.begin();
Monitor.begin();
analogReadResolution(10);
delay(5000); //let the bridge hardware be initiated
}
void loop()
{
int adc = analogRead(A0);
Bridge.notify("adc_data", adc);
Monitor.print("Seding data to MPU."); //shows on: Monitor Console
Monitor.print(adc); Monitor.println(" V");
delay(1000);
}
