How do you connect App inventor with raspberry pi 3(bluetooth)?

HI, I am new to this and I currently trying to get my app inventor and raspberry pi to connect. In my project I am using App inventor to simulate a open and closing while on the raspberry pi 3 I have a relay and 2 led to show open and closing.

if anyone can help teach me or give me a link similar to this I will be grateful.

maybe this one can help you

PiPresents oscRemote

To connect Android with Raspberry, Bluetooth or the MQTT Mosquitto broker is usually used.
Find information on installing Bluetooth on Raspberry.

Here a tutorial in Spanish:
http://kio4.com/raspberry/31_bluetooth.htm

1 Like

@Juan_Antonio That link looks awesome!
I've built a robot containing a Raspberry Pi Zero W. Currently, the only way to control it is from my Raspberry Pi 2 luggable, which communicates with the Zero via Wi-Fi (no router). It'd be nice if I could control the robot from my Android smartphone, which is a lot smaller! (Plus I always have my phone with me.)

Try installing Bluetooth on your RPi.

When you have Raspbian installed on your pi then you can use Node-RED. It has an "http in" node. Set the method to POST and the url e.g. to /mit.
node-red-1

The json node translates the text to a json object that you can handle in the function node. Mine looks like this:

functie

Then you can use the web component in App inventor. Set the url to the ip address of your raspberry pi followed by :1880/mit. (e.g. http://192.168.0.10:1880/mit) You can use the PostText method. I use this to switch a light on and off by sending a MQTT message to Domoticz using the MQTT node in Node-RED.

You can access your Raspberry Pi pins directly from Node-RED using the Raspberry Pi nodes.

nodes

So you can just send some text to Node-RED and let Node-RED handle it.

I hope this is of any help.

@Juan_Antonio I can't get that Circuit Digest example to work (even after I added () to the prints so the codes is Python 3). The Pi code has never got past server_socket.accept() despite much mucking about on my Android phone. (The Bluetooth terminal program mentioned by Circuit Digest doesn't seem to work on my phone; at least, I haven't found any way of telling it which Bluetooth device to connect to. I've tried a couple of other Bluetooth terminal programs, but they can't connect to my Pi.)
I've got an App Inventor app which happily displays a list of paired devices using


If I tap on "B8:27:EB:14:9D:19 RPi0W" (which is the Pi running the Circuit Digest Python code), my code does

which pops up an error message (which disappears frustratingly quickly) that says "Error 507: Unable to connect. Is the device turned on?" (It is, and waiting for a connection.)

@sjoerd1953 I'm sorry, but most of that is over my head!

Does anyone know of any other descriptions of how to connect App Inventor to Raspberry Pi?

The process indicated in the link worked for me.

Raspberry Pi 3 Model B
Raspbian Buster.
Android 5 and Android 9

@Juan_Antonio How strange! My phone's running Android 10 (and my Pi 0W is running Buster).
I might look (elsewhere) for code for 2 Raspberries to communicate by Bluetooth. (Or maybe I can get my phone to talk to my Pi via Wi-Fi.) What software were you running on your Pi? The Python code on the Code Digest page outputs thus:

Blockquote
print "Received: %s" % data
if (data == "0"): #if '0' is sent from the Android App, turn OFF the LED
print ("GPIO 21 LOW, LED OFF")

What you get with:
sudo sdptool browse local

I had to open port 22
Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10003
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 22
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100

maybe I can get my phone to talk to my Pi via Wi-Fi

Try MQTT, install Mosquitto in RPi

http://kio4.com/raspberry/11_iot_eclipse.htm

http://kio4.com/raspberry/16_mosquitto.htm

Initially, I got "Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory".
Then I tried the instructions in raspbian - Failed to connect to SDP server on FF:FF:FF:00:00:00: No such file or directory - Raspberry Pi Stack Exchange
Then sdptool gave the 189(!) lines I've attached. My minimal App Inventor app still won't connect to the Python code. Nor will Bluetooth Terminal or Serial Bluetooth Terminal from Google Play. I guess this is unsurprising, since a comment on that StackExchange page says "This fix stopped working on 2021-01-11-raspios-buster-armhf.img" :frowning:
sdptool.txt (4.3 KB)

Read in my tutorial:
3.- Establecimiento del canal.
http://kio4.com/raspberry/31_bluetooth.htm