Naro BLE33 Sense

Arduino projects on the go
Post Reply
John Ryan
Posts: 36
Joined: 31 Mar 2021, 03:56
Location: Rotorua New Zealand

Naro BLE33 Sense

Post by John Ryan »

To pass the time on wet cold windy NZ winter days when we can't go flying I've acquired a naro BLE33 Sense.
This little gem detects movement about x,y & z axies , temperature , humidity, colour, air pressure and a few other things.
There is an example in the BLE library which displays the various outputs on the serial monitor. As you move the thing around you can see the x,y,z values changing between -1.0 and +1.0.

I thought what a great idea to hook this up to anNRF24 and control 2 channels with it (Don't fancy my chances of ever flying a model with it).

By combining this example with the Arduino servo example I've managed to make a 2 axis servo controller using the x & y outputs .
Now I'm wondering if anyone out there has been playing around with a BLE33 as I have a couple of problems.

1. It only works when the serial monitor is open
2. I can't use the map function Ch1val = map(x,-1,1,45,135); This results in a constant value of 90 (servo centered).
However Ch1val = ((x*45)+90); works.

Enjoy your northern summer

John
User avatar
Mike_K
Posts: 677
Joined: 16 Feb 2018, 06:35
Location: Hertfordshire

Re: Naro BLE33 Sense

Post by Mike_K »

Hi John

We'd really need you to post your code to help fully.

I have never played with the Nano 33 BLE, but have played with external 9 axis sensors and I think the problem with the Arduino map function is that it only works with integer numbers, but I assume the output of the Nano internal sensor is a float with an output of -1 to 1

With a traditional Arduino, it uses an Atmega328P, that are very slow with float calculations, so the first thing you'd do is convert the float value into an integer (in my case multiply by 1000), but the new Nano uses an ARM Cortex based processor (Nordic I think without checking) and float calculations will be quicker than a traditional Nano doing integer calculations, so no need to convert. But the map function is still in the Atmega328P age.
John Ryan
Posts: 36
Joined: 31 Mar 2021, 03:56
Location: Rotorua New Zealand

Re: Naro BLE33 Sense

Post by John Ryan »

Hi Mike

Thanks for your feedback. You were correct with your solution to the mapping problem. I've made a note about that for future reference.
I've attached a copy of the code.

John
Attachments
2_Ch_Tilt_Servo_Driver_2-7-23.ino
(3.35 KiB) Downloaded 97 times
User avatar
Mike_K
Posts: 677
Joined: 16 Feb 2018, 06:35
Location: Hertfordshire

Re: Naro BLE33 Sense

Post by Mike_K »

Hi John,

The line (#37) in setup()

while (!Serial);

This line will wait until the serial port is ready, which if it isn't connected will be forever. I assume that with the serial port unconnected, the Nano BLE returns a 0, which is inverted by the ! in front of the serial command and it will wait for it to be connected. If you want to try it without the serial connected, comment out that line.
John Ryan
Posts: 36
Joined: 31 Mar 2021, 03:56
Location: Rotorua New Zealand

Re: Naro BLE33 Sense

Post by John Ryan »

HI Mike

You are a genius! It's now all working as it should.
Many thanks.

John
Post Reply