I'm working on the circuitpython Metro M4 airlitf board with a Ble bluetooth and appinventor.
I tested my python code with the Adafruit app "Bluefruit LE Connect app provides iOS & Android". I can send and receive data on this app.
I have a problem communicating from circuitpython to appinventor.
I must make an error in my code for the reception, but after consulting forums I do not see my error. I do not receive the value "45,45.3,70" on appinventor.
When I send the value 3 from appinventor to the circuitpython board the python code should return me the value "45,45.3,70" and nothing happens.
Thank you for your help
Attached are the python and aia files from appinventor and an image of the serial communication
Looking at the Adafruit script, they have omitted the use of UUIDs, which is the bedrock of BLE. Normally we would either change the code to use UUIDs or communicate with Classic Bluetooth instead. However, I see you have modified the code.
Good morning,
Yes the circuitpython board receives the value 3 and displays the message "reading sensors" in the REPL
and then send the following command uart.write(donnees)
Cordially
Mr Mathieu
....because your Script is not identifying the value type (Characteristic UUID) and not sending the value as a Characteristic. Therefore, the data will never be received.
Find another Python script that supports the BLE GATT system. I can confirm that the Service UUID in the App is correct for UART communication.
Instead of BLE, use Classic Bluetooth in the App (No GATT required), with minor change to the existing Script.
Use a script written in C that supports the BLE GATT system (99.99% of App Inventor Users do this because the Arduino platform supports it too). There are many examples in the forum.
Concerning the original Script, are the UUIDs defined in one of the files we cannot see ('from ###')?
Concerning the App code, Google requires location to be switched on and depending on your Android version, certain permissions are required too. That's all missing from your Blocks but is easy to add.
Good morning,
I work on the circuitpython metro m4 board with airlift lite integrated on the board.
the data sent by the command uart.write
code_python.pdf (70.4 KB)
(data)
data = "45.45.3.70"
I am using M7 tablet with android 9
attached the pdf file with the python code and an image of the appinventor application's interaction with python
Cordially
Mr Mathieu
We are not making any progress yet, but the details about the hardware help greatly.
In the Python script, which Adafruit defined to work with their App, the file bleio is imported. We need to see that file.
Also in the script, the word 'adapter' is defined, starting the ESP32 bluetooth. In the English language, adapter (adaptor) would describe an add-on module (hardware), but I think you are invoking BLE when perhaps the original script used WiFi? I ask because 'airlift lite' specifically targets WiFi whereas 'airlift' targets both WiFi and BLE. ESP32 models from 2019 support BLE 5.0 with GATT, as does App Inventor, so the bleio file is key.
There are a number of Lenovo M7 tablet versions - we need to know the exact model that you are using.
Thank you for the diagram - a picture paints a thousand words!
Good morning,
sorry to answer you so late, but I spent 3 days in my family.
For the tablet it is the model: Lenovo TB-7305F with android 9
For the _bleio library I used it to see the MAC address. I don't know if I should use it.
I'm new to coding in python, but I'm not familiar with object programming.
for UTF-16 or UTF-8 I don't know. I am using mu editor software to program Circuitpython board
Adafruit's python scipt works great with Bluefruit Connect software
Cordially
Mr Mathieu
... that would be because it's their hardware, their script and their Software
What I can tell you is, we have had more issues with Adafruit hardware than any other I can think of, mostly because they are a little unconventional - they are perhaps not really expecting us to use anything other than their software with their boards but they do at least have libraries for the Arduino IDE (C language).
We need to see that file - hopefully it is that file that supports BLE GATT.
Edit: Well actually adafruit_ble is built on top of bleio and it isn't using BLE GATT.
Important: In your App Inventor Project, you Have a Service UUID and two Characteristic UUIDs - where did you get those from? They are what we want to work with in the Script.
The Lenovo M7 is a nice Tablet. I have been trying to find out it's Bluetooth Version based on the model TB-7305F, but unfortunately there are a few sub-versions, including only having WiFi, no Bluetooth at all.
Bluetooth version is usually something Android devices do not tell you - if you still have the box, it probably states the version on there. If you can't find the Bluetooth Version, there is a free App on Google Play that can:
We need to know the Bluetooth version number that your M7 supports. On Android 9, I expect it will be version 4.0 at least, but can't be sure without verification.
... forgot to ask - did you try the Project (.aia) file I posted (see Post#12)?. In the Strings Received Block, if anything is received, it is displayed in text_aff.
Try compiling the Project and installing the APK on the M7.
For lenovo M7 tablet TB-7305F WLAN 802 11 B/G/N + BT 4.0 with Android 9
This afternoon I managed to receive information from the circuitpython board to the tablet. I modified a file from "Jose Luis Núñez hacked by Gordon Moore"
So I have an application to transmit and another to receive data in bluetooth.
On the other hand, my trash application must work in both directions, I still have work to do.
I removed the _bleio library from the python code and I have no error.
For the UUIDs, the Adafruit application displays them on the Bluefruit Connect application.
I am a teacher with a Terminal class, I only have 2 hours of lessons per week. I can't teach two programming languages to my students. The python language is required for the written test of the baccalaureate, that's why I chose circuitpython.
your appinventor application is easy to learn for students. I'm sure if I can make my application work in the sense of bluetooth communication, other SI teachers will surely be interested
Cordially
Mr Mathieu
attached the code in python of the apllications and appi aia connunication sens1 sens2.pdf (19.1 KB) HeartRateMonitorGM_V11.aia (313.7 KB)