Arduino Nano BLE 33 Sense Microcontroller: Hardware and GPIO Functions
Tags: arduino, microcontroller
Published: 2024-01-01 08:00:01

The Arduino Nano BLE 33 Sense Microcontroller is an Arduino-compatible board with a fleet of onboard sensors, including sound, light, temperature, and a microphone. It can be programmed with Arduino C and MicroPython to read and write data. This article introduces this unique board, details how to use the digital and analog pins and which functions the board supports.

_This article originally appeared at my blog [admantium.com](https://admantium.com/blog/micro19_ble33_sense/)_.

## Arduino Nano BLE 33 Sense Hardware

![](https://admantium.com/images/blog/micro19_cover.jpg)
_Source: [https://www.elektor.de/](https://www.elektor.de/arduino-nano-33-ble-sense-rev2-with-headers)_

The Arduino BLE 33 Sense has the following hardware:

- Microcontroller: ARM Cortex-M4F
- Flash Memory: 1MB
- SRAM: 256KB
- EEPROM: None
- ClockSpeed: 64MhZ
- GPIO: 14 (6 digital, 8 analog)

And the following connection protocols are support:

- Bluetooth 5
- NFC-A tag
- USB2.0

It also features a crypto chip ATECC608A.

## Digital Pins

![](https://admantium.com/images/blog/micro19_ble33_sense_pin_layout.png)
_Source: [docs.arduino.cc](https://docs.arduino.cc/hardware/nano-33-ble-sense)_

The Arduino BLE 33 Sense has 14 digital pins that, like other similar Arduino boards, can be used as input or output pins.

For programming, either the [Arduino C](https://docs.arduino.cc/software/ide-v1/tutorials/getting-started/cores/arduino-mbed_nano)  or [MicroPython](https://docs.arduino.cc/tutorials/nano-33-ble-sense/ble-sense-python-api) can be used.

### Digital Input

All pins operate in input mode per default. You can also set them explicitly to be of type input.

#### C

```c
pin = 3;

pinMode(pin, INPUT);
value = digitalRead(pin);
```

#### MicroPython

```python
p3 = Pin(43, Pin.OUT)

p3.low()
p3.high()
```

<https://docs.arduino.cc/learn/programming/arduino-and-python#digital-read-pull-up>

All digital pins are configured as output pins by default. However, they can be explicitly configured with the method `setPinMode(pinNumber, mode)`, where mode is either `INPUT` or `INPUT_PULLUP`.

The input state - which is translated to true/false bases on the voltage - are `HIGH` and `LOW`. To obtain the state, use the method `digitalRed(pinNumber)`. The mode `INPUT_PULLUP` reverses the values of `HIGH` and `LOW`, and the receiving end of the wire should be connected to ground.

### Digital Output

To output a digital signal, the Pins need to be configured with the method `pinMode(pinNumer, OUTPUT)`. To write a value, the method `digitalWrite(pinNumber, Value)`, where value is either `HIGH` or `LOW`.

#### C

```c
pin = 3;

pinMode(pin, INPUT); //configured as an input
value = digitalRead(pin);
```

#### MicroPython

```python
from machine import Pin
from utime import sleep

pin_nr = 29 # A3 pin
a3 = Pin(pin_nr, Pin.IN, Pin.PULL_UP)

while True:
    value = a3.value()
    print(value)
    sleep(1)
```

## Analog Pins

The Arduino BLE 33 Sense has 8 analog input pins and 5 analog output pins for generating PWM signals.

### Analog Input

Analog input pins are numbered A1 to A8. Pins A4 and A5 should only be used for I2C, however.

#### C

```c
pin = A1

value = analogRead(A1)
```

#### MicroPython

```python
from machine import Pin, ADC
from time import sleep

a3 = Pin(29)
adc = ADC(a3)

while True:
    reading = adc.read_u16()
    print("ADC: ",reading)
    sleep(1)
```

### Analog Output

Analog outputs create a PWM signal. This signal oscillates between a range of values with a configurable frequency.

In the C version, you just set the desired value, the frequency will be calculated automatically. In the Python version, you configure the value and frequency independently.

#### C

```c
pin = A1

value = 1000
analogWrite(pin, value);
```

#### MicroPython

```python
from machine import Pin, PWM, ADC

a2 = Pin(29)

pwm = PWM(a2)
duty = 30000 # sets the duty cycle
pwm.freq(1000) # sets the frequency

while True:
    pwm.duty_u16(duty)
```

## GPIO Functions

The Arduino Nano BLE 33 provides the following GPIO functions:

- PWM: [Pulse width modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation) is a signaling technique in which a digital signal is switching rapidly between two states - high and low - in a certain frequency. PWM output can be generated on these pins: 21, 23, 24, 27, 28.
- UART: Digital Pins 16 (RX) and 17 TX can be used to directly connect two devices for a serial connection using the [UART protocol](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter).
- SPI: With the [SPI protocol](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface), a synchronous serial communication between one server and several clients is created. On the BLE 33 sense microcontroller, pins 29 and 30 need to be used.
- I2C: This more advanced protocol allows the connection of multiple devices to establish a server/client architecture for information exchange. Pin 8 for SDA and pin 9 for SCL are used to establish the [I2C](https://en.wikipedia.org/wiki/I%C2%B2C), and then one device must be programmed to obtain the server role and then actively reading from and writing to other devices.
- ADC: A system that converts analog signals into digital ones by using a suitable binary representation for different values of the input signal. Several pins can be used for [ADC](https://en.wikipedia.org/wiki/Analog-to-digital_converter), pin 4 to 11. Additionally, pin 4 can be used as output as well, providing a digital to analog converter.

## Sensors

The BLE 33 features several additional sensors that are already soldered to the board. You can access their values by following the [programming sketches tutorial](https://docs.arduino.cc/hardware/nano-33-ble-sense) from the official documentation. Here is a brief description of their capabilities:

- Inertial Motion Unit [LSM9DS1](https://www.st.com/resource/en/datasheet/lsm9ds1.pdf): This chip combines a linear acceleration, angular rotation, and magnetic field sensor. It can be used to detect motions as well as changes in orientation.
- Microphone [MP34DT05]: The microphone records sound up to 65db and works with low power consumption. The [datasheet](https://www.st.com/resource/en/datasheet/mp34dt05-a.pdf) contains additional information.
- Light Sensor [APDS9960](https://eu.mouser.com/datasheet/2/678/av02-4191en_ds_apds-9960_2015-11-13-1828458.pdf): This sensor supports a wide range of functionalities. For detecting light and color, the technologies Digital Ambient Light Sense (ALS) and Color Sense (RGBC) are provided. The detection algorithms can be fine tuned to filter UV and IR light. Also, it has a very high sensitivity and can even be used behind dark glass.
- Proximity & Gesture Sensor [APDS9960](https://eu.mouser.com/datasheet/2/678/av02-4191en_ds_apds-9960_2015-11-13-1828458.pdf): With the very same chip, by accessing light sensitivity, the proximity of objects can be detected. Gestures are recognized with the help of an additional four separate diodes that detect motions in different angles.
- Barometric pressure Sensor [LPS22HB](https://www.st.com/resource/en/datasheet/lps22hb.pdf): This chip reliably reads the barometric pressure. It recognizes the device and ambient temperature in making its calculations and draws very little power.
- Temperature & humidity Sensor [HTS221](https://www.st.com/resource/en/datasheet/hts221.pdf): This sensor detects temperatures in the range of +15 to +40 °C, and relative humidity from 20% to +80% rH.

## Conclusion

The Arduino BLE 33 sense is a very capable microcontroller. In the established form factor of an Arduino Nano, this board features an extensive set of other sensors: inertial motion, light, gesture & proximity, barometric pressure, and temperature. This article detailed how to access the boards GPIO for reading and writing values, as well as which communication protocols are supported. The BLE 33 sense can be programmed both with Arduino C and MicroPython. Finally, it is also possible to run machine learning models on it.