To add some more specificity, the .ino displays "BLE peripheral is now active" when energized and, once the .aka connects with the .ino, the serial monitor broadcasts "Connected to central: 5d:a1:b4:07:ee:b6" and repeats the data printout11 times in rapid succession. The last line is "Disconnected from central: 5d:a1:b4:07:ee:b6."
It seems like something in the .ala is starting the .ino just fine but is not seeing the data or is disconnecting before it can get a fix.
Shouldn't be that rapid - first data set in 2 seconds and subsequent data sets every 10 seconds. Disconnection from central would occur if you tap the App's disconnect button or something happened on the hardware side - a Bluetooth interruption, power interruption, overheating etc.
The App
Each stage of the process is reported on Screen, so the App should be informing you of what is happening. For example:
The Connect Button:
If the connection is a success, you will see "Connected: Waiting for Data".
If connection fails, you will see "Status: Connection Failed".
There is also an App Inventor Error Block which reports the nature of any App error it catches, for example if the disconnect button was tapped when there wasn't a connection.
I've had an idea - I have updated the App Blocks to save to a log file. Everything that happens on the App side will be saved to the file "/Documents/psychrometer.txt" and you will be able to share that file here. I have tested it, gets as far as finding BLE devices, fails to connect to my device choice (smartwatch) - every message is stored in the file, it's similar to the way the Sketch (.ino) reports to the Arduino Serial Monitor.
My Arduino IDE is version 2.3.2 so i think I am up to date. The latest occurrence was that I ran your modified program and I received a screenshot that, I think, says it would not create the file you were hoping for. The second screenshot is what is displayed for a moment after I try to connect to the chosen signal :Psychrometer."
I am attaching 2 screenshots. A view of the message and the "gray screen of death" I am taken to seconds after pressing the connect button.
The error about cannot write to file is from the App, reported by the "Error Occurred" Block, and error 2104 is "Cannot write to file".
What make and model is your phone and what Android version is it?
On Screen, the App reminds us to switch on Bluetooth and Location - that has to be done before scanning.
I don't know what to make of the message "Psychrometer keeps stopping" - this pops-up after pressing the connect button? Even though I don't have your ESP setup, I do not get that external message, only the App's own messages. However, in the screenshot, no BLE devices have been found, so you are trying to connect to nothing..........
How are the buttons round in your screenshot? Have you changed anything? Obviously the button shape isn't a problem but if you have made other changes......
I am afraid that screenshot about project properties flew over my head like a Canada Goose flying home for the Spring. I am printing out the blocks from your app and the one I posted that "works" without refreshing and see if I might somehow magically combine them into something functional.
I DO have a huge question to ask of which I hope you know the answer. When I have my ESP32C3 breadboard connected to my computer and I have run and loaded the sketch and hit the hard reset button, the serial monitor basically says "I'm ready." When I press the connect button on my app, the serial monitor immediately springs into action printing data and, some seconds later, the app announces that it has connected with the psychrometer. All is well, but . . .If I power up my breadboarded ESP32C3 with a USB power supply (and the serial monitor/computer is not connected) and I hit the hard reset button, the app cannot find the .ino sketch and connect to it. Whether or not the Arduino sketch begins broadcasting seems to depend on whether or not it is connected to the serial monitor. Would you please tell me why this is so and what is causing this (assuming that this is something you are conversant in;). I obviously can't have my laptop connected outside - the idea is wireless communications.
As I mentioned before, the Blocks have been proven in the real world, a version of the project is no doubt in use right now.
So the Object of the exercise is to get the App and the ESP working for you. It's a preliminary stage, if you test the files I send to you and errors occur, just post the errors here for me to see - but don't try to change anything unless I say it must be changed. Once the project is up and running, you have a firm base to work from. You can copy the working project and modify it to do more.
If you look at the .ino code in setup(), the line "while (!Serial);"
while-not-Serial - in other words, wait (forever) for the serial connection. So the subsequent BLE code lines are not reached.
If you are not connecting to the serial monitor, you can comment-out the serial code that sends to the monitor, but really it is best to work with the monitor until you are confident that everything is as required with Bluetooth results.
By the way: The USB power supply should deliver exactly the right volt-amps, you can check that in the Seeeduino ESP32C3 specifications.
My phone is a cheap Android purchased specifically to work with MIT App Inventor projects. It is a TCL T607DL without any cell service attached. Mind you, everything works on the first .apk file I sent to you except for automatically updating the data when rebroadcast. I can disconnect and reconnect for an update but that is not efficient. Even though they are assembled differently, both apps DO activate the ESP32C3 into broadcasting - in fact, both apps "work" with the .ino called BME SensorObject except that my app doesn't refresh and "your" app doesn't show data.
The .ino will display "BLE peripheral is now active" upon reset and will sit there forever doing nothing . . . UNTIL I press the connect button on either of the .apk apps. At that point, and only then, does the .ino sketch begin printing data to the serial monitor and broadcasting the same.
Thank you, again, for your patience and assistance.
I hope that the similarities in actions combined with the difference in instructions may reveal the issue. My thought, if you believe it is Connects_Displays_No_Refresh.aia (1.0 MB) Connects_NoDisplay_Refreshes.aia (246.2 KB)
sound, is to create a new project and, using the backpack, import various parts of each code with modifications towards your sketches refresh rate and my sketches actual (one-shot) connection.
That's perfect for the job, Android 13 and BLE 5.1. Before you start using the app, make sure Bluetooth and Location are both switched on (when the App becomes more advanced, a lot of that stuff can be automated).
The multi-characteristics method used only works once because it is in a Connection Block and should be in a Clock (timer) Block.
Each project needs the .ino Sketch to be coded to match the data handling method employed, so it is not a case of just taking some desirable features from one project into another - the Sketch would have to be changed too.
Here is a version of the "Connects_Displays_No_Refresh.aia" called "Connects_Displays_No_Refresh_Edit.aia".
It uses the multiple Characteristics method and regulates the incoming data with a Clock Timer. The .ino Sketch must match accordingly and you will then see the values updating.
The reason I expected you to persevere with streaming using a single characteristic is because ultimately you will be working with 24 values - it is necessary to regulate the sequence and flow of that much data for it to work, and working also means being able to reject the occasional blip smoothly without crashing.....
Wow, Chris . . . this is everything I dreamed of - two weeks ago;)-. It seems to me that I could play with this, slowly modifying it so that the first three data points were delivered on one UUID. I tend to lean this way because the psychrometer app that was part of the "functioning set" still does not connect and I get the same error as before when I try to run the app with the modified text file creator.
I guess the other thing I could do is recreate all of the math on the app end but that seems like a bunch of extra work, as I already have calculations working in C++.
I have tested Psychrometer.aia on Android 10 and Android 12. In both cases, the log file is recorded. However, on Android 12 it tells me that permission request "WRITE_EXTERNAL_STORAGE" has been denied - but the log file is still written:
OK, that explains your genius rating! You are so right, the message said it wasn't secreted but the file folder says otherwise. I am attaching the psychrometer.txt in hopes that you will discover the issue plaguing my inoperative app.
I do not see anything outstanding when I look at it. It basically confirms the device is found and connection has been attempted, as far as I can tell. The story ends suddenly.