BLE ledservice question

Hey I’ve been spending all day figuring out how to control this HM-10 BLE module with my phone and I just managed to make an app using the MIT app inventor thing and all that. Now the problem is when it comes to the part where I type “BLEService ledService(“address of something here”)” I can see in the tutorial the person put an address there so I assumed it was the same thing if I put my own BLE module address there but for some reason it didn’t work. But now that I’m checking the BLE scanner it shows me the uuid which is exactly what I put in the MIT app thing.

Is there something I should change with the address? I’ll paste the code here.

#include <BLEPeripheral.h>

BLEPeripheral blePeripheral;
BLEService ledService(“0000FFE0-0000-1000-8000-00805F9B34FB”);
BLEUnsignedCharCharacteristic switchCharacteristic(“0000FFE0-0000-1000-8000-00805F9B34FB”,BLERead | BLEWrite);

note I have triple checked and the address there is exactly what I see in the scanner.

Sorry if this question doesn’t belong here but if anyone can help then its greatly appreciated

The standard HM-10 BLE module firmware exposes a BLE peripheral with a proprietary connectivity service (UUID: 0000ffe0-0000-1000-8000-00805f9b34fb) that enables bidirectional communication between the module and any central device connected to it.

The service defines a single characteristic (UUID: 0000ffe1-0000-1000-8000-00805f9b34fb) that stores 20 bytes of unformatted data. (NOTE the different number from yours).

When the central device wants to send data to the module, it writes the characteristic with the desired content. When the module wants to send data, it sends a notification to the central device.

This article in my blog may also help Reliable Bluetooth LE Comms Between Arduino and MIT App Inventor (AI2) – Arduino++

marco_c:
The standard HM-10 BLE module firmware exposes a BLE peripheral with a proprietary connectivity service (UUID: 0000ffe0-0000-1000-8000-00805f9b34fb) that enables bidirectional communication between the module and any central device connected to it.

The service defines a single characteristic (UUID: 0000ffe1-0000-1000-8000-00805f9b34fb) that stores 20 bytes of unformatted data. (NOTE the different number from yours).

When the central device wants to send data to the module, it writes the characteristic with the desired content. When the module wants to send data, it sends a notification to the central device.

This article in my blog may also help Reliable Bluetooth LE Comms Between Arduino and MIT App Inventor (AI2) – Arduino++

Hey thanks a ton for the reply but I'm going through the code you mentioned for controlling an LED matrix and since I'm still pretty new I'm having trouble finding the parts that help me control the bt module and not the parts only for the text window. It's all a bit much to understand for something simpler I'm trying to do.

So my question is: Is there another file I can look at with the code necessary to control the bt module simply for something like one pin at least?

Either way thanks for the response and I'm still reading through your guide but it will take a while to fully grasp what the heck I'm trying to do.

One only thing I can suggest maybe is the AI2 examples may help, although there is not much info on the BLE add-in. The other is that for 1-2 characters being sent, once the link is established, you can probably treat it like a serial interface.

marco_c:
One only thing I can suggest maybe is the AI2 examples may help, although there is not much info on the BLE add-in. The other is that for 1-2 characters being sent, once the link is established, you can probably treat it like a serial interface.

Oh okay, I will go find the examples and see. My main problem is figuring out what to do with all the addresses. I know you explained them in your guide but it was a bit too deep for me to grasp sadly. I couldn't figure out where or how the app talks to the BLE module and then figure out how to get the information from the arduino.

The process breaks down into 2 parts - establishing a connection and then transferring the data.

You don't need to do much on the Arduino side other than run the BLE module and treat it like a serial port (Serial.print() the data to it). Most of the work will need to be done on the AI2 side to receive the message.

If you are sending from AI2, then the Arduino side is a Serial.read() just ike from the 'normal' serial port.

The UUID for Service and Characteristic are only used when the AI2 object starts the BLE link. After that the characters just appear in the object's callback when received.

marco_c:
The process breaks down into 2 parts - establishing a connection and then transferring the data.

You don't need to do much on the Arduino side other than run the BLE module and treat it like a serial port (Serial.print() the data to it). Most of the work will need to be done on the AI2 side to receive the message.

If you are sending from AI2, then the Arduino side is a Serial.read() just ike from the 'normal' serial port.

The UUID for Service and Characteristic are only used when the AI2 object starts the BLE link. After that the characters just appear in the object's callback when received.

So with the uuid's I take the two and put them in a writebyte thing and make sure they are the correct two for the bluetooth module? And after I have the arduino do a Serial.read() and see what data has showed up from the module. But I keep seeing things like to make a 1 pop up in the arduino I put the ASCII form of it which is 48 but then I kept getting all sorts of weird errors.

What I'm asking is, what would I put in the block on AI2 for value and offset? Right now it's set as the service and char uuid as the same from the BLE scan and what people told me was the correct uuids, then for value and offset I saw in a tutorial to put a 1 for value and 0 for offset. So now do I have the arduino do a Serial.read() for a 1?

There are 2 parts.

On the Arduino side you just use the module by sending and receiving like a serial port. Hopefully this does not need to be explained.

On the AI2 side, I am assuming that you installed the Bluetooth LE extension block. You need to establish the connection. Once it is connected you set up the block as in the BLE_Connect image attached. This will prepare the object for sending and receiving characters.

To send a character you need to use the call like in BLE_Send. You data will be different (‘1’ maybe?)

When characters are received, the callback function as in BLE_Receiv is called with the string value received (all the characters in the buffer). If you are not receiving characters, just don’t provide a callback.

But I keep seeing things like to make a 1 pop up in the arduino I put the ASCII form of it which is 48 but then I kept getting all sorts of weird errors.

Where do you keep seeing this? The interface deals with numbers and string separately, so you are probably looking at BT information, not BLE. ‘Weird errors’ is also not specific enough for someone not sitting next to you.

So now do I have the arduino do a Serial.read() for a 1?

Yes, using the serial port for the BLE module, not the USB port.

BLE_Connected.PNG

BLE_Receive.PNG

BLE_Send.PNG

marco_c:
There are 2 parts.

On the Arduino side you just use the module by sending and receiving like a serial port. Hopefully this does not need to be explained.

On the AI2 side, I am assuming that you installed the Bluetooth LE extension block. You need to establish the connection. Once it is connected you set up the block as in the BLE_Connect image attached. This will prepare the object for sending and receiving characters.

To send a character you need to use the call like in BLE_Send. You data will be different ('1' maybe?)

When characters are received, the callback function as in BLE_Receiv is called with the string value received (all the characters in the buffer). If you are not receiving characters, just don't provide a callback.
Where do you keep seeing this? The interface deals with numbers and string separately, so you are probably looking at BT information, not BLE. 'Weird errors' is also not specific enough for someone not sitting next to you.
Yes, using the serial port for the BLE module, not the USB port.

Oh yes sorry for saying weird errors, it was for something in a different tutorial but since I saw your guide I stopped using that method since it didn't make any sense.

And for the serial read for the BLE, I'm supposed to write BTSerial.read() correct?

I don't have the time right now to test out your advice but in the morning I will see and get back to you.

Also I want to say thanks a lot for the responses and helping out, I've learned a ton in such a short span thanks to you guys, I really appreciate it.