Hi, thank you for checking this out. someone put together an Arduino Due with a “Adafruit Bluefruit LE UART Friend” for me to control the temperature of something.
I can use the Bluefruit Connect app to send UART commands to accomplish what I want to do, but was trying to make an app with buttons that would send the text instead.
To start, I have been able to create an app that scans for bluetooth devices, connects to the Bluefruit LE, and shows the buttons to enable/disable the heat… I installed the app successfully on my phone, and connected to the device, but when I try to enable it, the app just crashes. I assume that is because I am sending the command the wrong way. I have found some sources that talk about sending numerical values and strings, but none of them seem to exactly apply to what I am doing.
To start, I just want to have a button send the text “enable” like Bluefruit connect would, but at the push of a button instead of manually typing it out.
The complete set of commands is “enable” “disable” and “[desired temperature]”
References here:
This seems really useful, but I don’t know if it directly translates to what I want to do.
This seems to be the closest to what I am working on, but did not get me there.
I also found a blog post that said all example projects now have BLE build into them, but I’m not sure where to find the official example files. I cannot link to that article because I am a new user and am limited to two links per post. I did find a set of them from an old page on the site, and they did not have new BLE extensions in them.
My block layout:
Bluefruit Connect Screenshot after connecting. It seems to report some active values:
Hi Brandizzle
Replace the BLE Block WriteBytes with WriteStrings.
1 Like
Thank you for the reply. That was the first thing I tried. It does the same thing. The app just closes.
Stick with the Strings Block.
Other things:
- Is “Location” switched on?
- Is Developer/Debug mode switched on?
- Is there an Anti-virus App in addition to the one that came with the phone?
- Do you know for sure that the Uuids are correct?
1 Like
Thanks for taking another look. Location has been on, as well as developer/debug. Unless one is baked-in, I don’t think I am running anti-virus. I very well might be missing something about the UUID. Following an example from a different project, I found something from the manufacturer and just put it in both fields. I did however find other examples in the forums where the characteristicUuid was different than the serviceUuid, but did not find any explanations as to why.
I found the DeviceCharacteristics and temporarily added to my app and ran it. Perhaps, I could use something from here:
Try the BLE App from Google Play to get the “master” Uuids. They will be almost the same but not identical strings in most cases (this is not a rule but has become the norm).
The difference between the purpose of the Service Uuid and the Characteristic Uuid: The Service Uuid determines the type and number of Characteristics available - The Characteristic Uuid defines the types/values that are available. It’s easier to understand when you see the official list of both Uuid categories:
Many development devices simply use generic Uuids that do not hold any specific values.
1 Like
It does look like you are actually already using Bluefruit’s generic Uuids. My only doubt is that your board might be a variant and have different Uuids. I have seen issues with these boards before - essentially, they are an Arduino template with built-in bluetooth and clearly the intention is to make things easier, but there seem to be quirks that actually make things more difficult.
1 Like
… by the way, baked-in anti-virus is fine, the troubles with AV manifest when people add a third party AV App.
1 Like
What is happening on the board side - perhaps there is an issue in your script/sketch?
Edit: I think it should be this one - I’d like to see it:
1 Like
It’s probably a good idea to ask about Bluefruit BLE + App Inventor in the Adafruit forum - it’s possible an Adafruit enthusiast can help.
https://forums.adafruit.com/
1 Like
Thanks for your continued help. Using the BLE app gave a bunch of numbers (one set for each of Device Name, Appearance, Peripheral Preferred Connection Parameters, Service Changed, and three other random unlabeled things). None of them matched what I was using before. I plugged in one and the app didn’t crash when running it. Nothing happened, but that’s still an improvement! I will ask for the sketch from the person who put this together for the sketch, and will also post in the other forums and report back later. You’re awesome. Thanks!
It does not seem super active on the adafruit forums. On the off chance that someone who is in real deep, this is the source for App that I am trying to replace:
I’m going to dig through and look for clues… but I literally have no idea what I am doing. :}
There is something of interest in the Manifest, requiring ACCESS_FINE_LOCATION. We have usually used ACCESS_COURSE_LOCATION, I don’t know if the latest BLE extension has changed this - it is also dependant on the version of Android, favouring the latest versions.
So, assuming the extension is already requesting Fine Location, the blocks below will be nothing but a red herring:
Start by trying the ACCESS_FINE_LOCATION permission only.
You should have in your possession the Script/Sketch used to drive the microprocessor - the whole point being that you can reset the board with the manufacturer’s script and also use that script as an example/template for your own code.
Thank you for the additional information. I think it was already getting those permissions, because these blocks seem to execute correctly:
I assume that if it did not connect, this would not execute. But I may be misunderstanding the suggestion, so I gave it a try and was given an error.
In any case, I think it is time for me to give up. This is probably too far over my head. Thank you so much for all you have done @ChrisWard
I checked out your site, and did not find anything that I could do. If you would like me to buy you a cold one, you can DM me your paypal. :]
1 Like
I have not used this device.
In your code I notice that ServiceUUID is 6E400001-XXXXX
and CharacteristicUUID is also 6E400001-XXXXX
Change CharacteristicUUID to
6E400002-XXXXX
or
6E400003-XXXXX
1 Like
Thanks for the suggestion, but this did not make a difference.
Our colleague Gerrikoio has got a BlueFruit Board working with App Inventor: