Controlling LED's from my phone via BluetoothLE

That's good. Yet you have not used the most recent App Inventor Project that I updated.....?

Well, I did say:

:grin:

So, use the LED_Control_HM10_5.aia with the LED_COBAK5.ino. Only the modification to the Sketch is necessary - we should see a value there, even if it's not correct.

I have used most recent .aia you updated sir

I'm sorry sir, I've used it. I'm very sure I use it😁

I don't understand how you get the Visible error though, given that the Project does not use that function. :thinking:

Hi Muhammad

Can you download this extension written by Taifun:

I have updated the files to get a bit more debug info. Please do not modify them.
The App Project records Status in a similar way to the Arduino serial monitor. You can copy it to the clipboard and then paste it into an email to yourself - then copy from the email and paste here.

I have also updated the Sketch to improve the Serial messages and added a note about switching LEDs on/off as it is dependent on how you have wired them up. Copy the Serial messages from the monitor and paste here.

LED_Control_6.aia (207.7 KB)

LED_COBAK6.ino (7.3 KB)

I also don't understand sir, I have matched the block and the sketch, nothing is different and after I studied again your post also did not meet for this problem

Well, let me check it first sir. And for the record I never change anything you post :grin:

I've tried it sir, and the result is no action from the arduino
The status is written like this:

Select the device
Device Found
Connect the device
Connecting
Connected: Can Write: false
Send LED Value
Value Sent: (6)
Send LED Value
Value Sent: (1)
Send LED Value
Value Sent: (1)
Send LED Value
Value Sent: (6)
Send LED Value
Value Sent: (1)
Send LED Value
Value Sent: (6)
Send LED Value
Value Sent: (7)
Send LED Value
Value Sent: (2)
Send LED Value
Value Sent: (7)
Send LED Value
Value Sent: (2)
Send LED Value
Value Sent: (7)
Send LED Value
Value Sent: (2)
Send LED Value
Value Sent: (7)
Send LED Value
Value Sent: (1)
Send LED Value
Value Sent: (6)
Send LED Value
Value Sent: (1)
Send LED Value
Value Sent: (6)

Then nothing is written on the serial monitor for the value

Some progress. The interesting bit: Connected: Can Write: false

However, we need to ensure it's not a false negative (a 'red herring'), so can you change the initialization of the variable from 'false' to 'true' and test again?

Snap1

The Status is telling us that the App values are sent correctly. The Serial Monitor is telling us the values are not received in any shape or form. It seems like there is something very simple missing.......I assume your phone has location switched on?

ref: https://docs.arduino.cc/tutorials/nano-33-ble-sense/cheat-sheet

@ewpatton can you shine a light on what we have missed out? Not sure about the BLE Can Write Block.

@gerriko_io
@uskiara
@Juan_Antonio

I think one of these Arduino-Bluetooth experts will be able to identify what is wrong, if anyone can spare the time to take a look?

Hello @ChrisWard and all, (@Juan_Antonio, @Gerriko_io )
sure I'll give it a look, but not today because my friend with his Lancia Fulvia (year 1967) will run the Montecarlo Rally in a few hours and I've prepared for him the "race software" with AI2 interfaced to Hall sensors on wheels (+Arduino Nano+ESP32 + Bluetooth :slight_smile: )to compute the speed, and at the same time interfacing the GPS to keep the road.
IMG-20230121-WA0002

So we are (very :grimacing:) busy 'till his departure (approx h 21.00 tonite).

Honestly I've already had a look at this probem, but I don't have a NANO33 BLE. I've just some ESP32 capable of BLE (and an HC08 + UNO in the case). So even if I will be able to make it working, will it be worth for @Muhammad_Zulkifli ? The BLE libraries for NANO33 and ESP32 are hardly different each other.

@Muhammad_Zulkifli in the case, have you the chance to revert your projet on a ESP32 ?

Anyway, sure, tomorrow (Italian time) morning, I'll give it a try.
Ciao ciao.
:crossed_fingers:

2 Likes

Regarding the issue of the CanWrite variable being set to false, there are two different types of writes in the BLE spec. CanWriteCharacteristic block corresponds to writes without checking for a confirmation and determines whether you can use the Write family of blocks. Separately, there is the method CanWriteCharacteristicWithResponse that corresponds to whether you can use the Write*WithResponse blocks. By specifying BLEWrite for the characteristic you need to use the latter set of blocks. You can probably also add BLEWriteWithoutResponse flag on the Arduino side to get the intended behavior without having to swap out all of the blocks.

1 Like

I searched for BLEWriteWithoutResponse - I think you have nailed it (fingers crossed)

Hi Muhammad

Re Evan Patton's post, try this Sketch (with App Project LED_Control_6.aia):
LED_COBAK6a.ino (7.5 KB)

Very very worth or me sir

I've never done that, sir.

It works sir! ok, now I can proceed to be able to move the linear actuator for my prosthetic hand. And to drive the linear actuator, can we use a list index like the LED we discussed?

And I can teach my friends in college to make projects such as turning on LEDs or driving motors or something else

1 Like