I was still having difficulty with the file you provided but I finally have a functioning pair of sketches. Thank you for all of your valuable input. I will be studying sending multiple floats on a single UUID and other information you provided. BME_nRF_Good.ino (2.4 KB) Final.aia (1.0 MB)
The .ala block structure looks like this for anyone else interested:
I'm going to move your post to the Help category Baran, as you don't need to hire anyone now.
One thing of interest - are you going to display all 24 values on Screen? If so, a ListView would probably be best. To have two columns and alternately coloured rows would need an HTML ListView, which gets built in real time. When/if you get to that stage, open a new Topic for help.
OMG . . . nope! I currently have to refresh the app and that is a pain. I will have to research what that looks like, as I am pretty raw with this block programming. Thanks for the heads-up!
OK, I am stumped. Would you be able to show me an example of what you are speaking about. Right now, I have to disconnect and reconnect to refresh the data. Thank you so much.
Basically, it all boils down to doing the register for whatever in the connection completed event, with maybe an extra read thrown in. So you're just a block away.
It is used in the example Project that I posted for you Baran. It permits the streaming of data from the ESP32C3 into the App, without you needing to write your own code to check if data is available.
Well . . . after waking up fresh and having some obligatory coffee, I was able to successfully install both files you availed to me. I though I would start with your example and build from it, as you are sending multiple data points on one UUID and I have a separate UUID for each.
I am hoping you might have a deeper understanding of what is happening here than I. Once I press the scan button and, after scanning, I select the psychrometer from the list of scanned devices. When I press the "Connect" button, two things happen. The first is that the .ino file begins printing data in the serial monitor (good!). The second is that the .aka app takes itself offline every time (bad!).
I downloaded the .aka by scanning the QR code presented in the "Build" section but I am not sure which block of code is creating the disconnect. If you have any idea as to why the .aka app disconnects immediately after establishing a connection with the .ino sketch, I am open to it. There is just too much going on in some of those blocks of yours for me to ascertain the issue and determine the problem. Thank you for your patience with me and my glacial learning curve.
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.