Connecting Python and Arduino, serial returns weird information

So essentially I am running a python script that grabs OSC information from my cellphone, from here I grab this information as

0.6182767748832703
/rotary1/fader3
0.6230342984199524
/rotary1/fader3

Currently, I am printing this information following this idea:

My issue is, that when I check the Serial Monitor, all that I am getting are reverse question marks and sometimes some squares and if I'm lucky a number.

this is also sending indefinitely.

I am going to try to simply return the values, address, and arguments from my OSC instead of printing it. If any of you have any ideas, I will appreciate them a lot.

This is my python code if it helps:

from pythonosc.dispatcher import Dispatcher
from pythonosc.osc_server import BlockingOSCUDPServer


def print_handler(address, *args):
    print(f"{address}: {args}")



def default_handler(address, *args):
    #print(f"DEFAULT {address}: {args}")
    #print(returner(address, *args))
    #returner(address, *args)
    returnArg(args))
    returnAddress(address))


def returner(address, *args):
    stri = str(args)
    #print( type(address), type(stri) )

def returnAddress(address):
    return address

def returnArg(*args):
    filter = str(args)
    for elem in filter:
        if (elem.isdigit() == False):
            #print(elem)
            if (elem != "."):
                filter = filter.replace(elem,"")
                #print(filter)

    #filter.replace("(", "")
    return filter

dispatcher = Dispatcher()
dispatcher.map("/something/*", print_handler)
dispatcher.set_default_handler(default_handler)

ip = "PlaceHolder"
port = 5555

server = BlockingOSCUDPServer((ip, port), dispatcher)
server.serve_forever()  # Blocks forever

some parts are removed since they have my IP.

This is my Arduino Code:

#include <Process.h>

void setup() {
  // put your setup code here, to run once:
  
  //Make a bridge
  Bridge.begin();
  //Make a Serial Killer, whoa scary!
  Serial.begin(9600);

  while (!Serial);
  runPython();
}

void loop() {
  // put your main code here, to run repeatedly:

}

void runPython() {
  
  Process p; //creation of the proccess
  p.runShellCommand("python /C:/Users/ashth/Desktop/test.py");

  if (Serial.available() > 0) {
    // read the incoming string:
    String incomingString = Serial.readString();

    //prints the received data
    Serial.print("Received");
    Serial.println(incomingString);
  }

  //Serial.flush();
  }

Device: Arduino Uno or Elegoo Uno R3

Thanks in advance.

Looks like you've chosen the wrong baud rate.

Unfortunately you failed to read the sticky posts at the top of the forum as you posted your code as images.

As you're using the Bridge class I guess you use the Arduino Yun. What other information do you still hide from us?

Ah my bad, I have made some changes. Thanks for telling me! I thought I could use the bridge, is there another method I need to use in the case of using an Arduino Uno? I tried changing the baud rate, though I went with 9600 because that is what I saw as the default rate when googling, how do I know which is the right rate?

To do what exactly? You should start by telling us what hardware you use, how you wired it and what you're trying to achieve. Remember, in contrary to you we know nothing about your project.

If you used the Bridge library on an UNO you see the communication the library tried with the Linux part of the Yun. As the UNO doesn't have such part it communicates with the PC. It should be gone once you eliminated the Bridge library from your sketch.

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