Arduino Nano BLE write value to a peripheral

Not currently ML (although it will be)
I’m trying to write a value to a peripheral (Hue bulb) using BLE on the Arduino Nano.
So far I can connect to the peripheral using the nano but when I try to write (or read) a value to (or from) the characteristic that I want it always returns 0 - indicating failure.
Arduino documentation on BLE is pretty pants so I’m struggling to see where I’ve gone wrong.

This is a link to my stack overflow post which contains the whole code.

Currently what I’m trying to do is send either 0x00 or 0x01, on and off respectively to the correct characteristic on the bulb.
I’ve confirmed that it should work with a BLE app.

I feel like I’m really close (it’s at least equally possible that I’m not)

Hmm… looking at the code, I’m a bit stumped. Don’t you have to define the permissions on the BLECharacteristics as such (for example):

// RX / TX Characteristics
BLECharacteristic rxChar(uuidOfRxChar, BLEWriteWithoutResponse | BLEWrite, WRITE_BUFFER_SIZE, WRITE_BUFFER_FIZED_LENGTH);
BLEByteCharacteristic txChar(uuidOfTxChar, BLERead | BLENotify | BLEBroadcast);

Probably, I’m about 2 days into understanding BLE. A long journey to go.
In this case would the uuidOfTxChar be the nano? As it would be the device transmitting?

Ah, here is a really good reference for how to setup and use the BLE:

It is a slightly long read, but take a look at the full code. It is a great example. That should really get you going with the BLE fully, both to transmit and receive data on the Nano.

3 Likes

Thank you so much!

A long read is exactly what I need.
Thank you for taking the time :slight_smile: