Search code examples
encodingbluetootharduinoapp-inventor

App Inventor and arduino encoding, bluetooth communication


I made an app in App Inventor that sends text to arduino. Text is of type: "1,1,2,2,0,0,0,2,1,0". But at the arduino end I receive something like this: x€xx€xx€xx€...

For communication i use HC-05 bluetooth module. And arduino is mega adk. I tried to set encoding in App Inventor to UTF-8 and ASCII. Is there a way to this without changing arduino code?

arduino code:

void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial1.begin(38400);
   Serial.println("Starting");
}

void loop() {
   if (Serial1.available()>0) {
     String data;
     data = Serial1.readString();
     Serial.println(data);
   }
delay(2000);
}

App Inventor blocks (sending): enter image description here


Solution

  • I don't think it's your encoding. Try changing the baud rate of Serial1 to 9600 as well. (You should configure your Bluetooth module to work at this baud rate too) Also, I suggest you do it this way:

        if(Serial1.available())    {
    
             Serial.print((char)Serial1.read());    
     }
    

    If these didn't work either, make sure your bluetooth is configured properly, devices are paied and connected etc. Also, you may download and use the serial Bluetooth terminals that are already in GoogleStore to make sure you receive the bytes properly first.