Push Nano's Button

Push Nano's Button © GPL3+

Nano 33 Sense BLE is loaded with environment monitoring sensors whose data can stream over using Bluetooth or WiFi communication protocols.

  • 12 respects

Components and supplies

Apps and online services

About this project


Arduino launches yet another round of innovation for the IoT world. The Nano 33 Sense BLE is loaded with environment monitoring sensors whose data it can stream over to a host using Bluetooth communication protocols. It is the ideal platform to assess mobile solutions that can take advantage of input from gestures and sound. As with the majority of Arduino platforms, development is conducted using the versatile Integrated Development Environment (IDE) or cloud interfaces. The micro-controller for the board is nRF52480 by Nordic Semiconductor.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['7b0b37527f'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955971/uploads2ftmp2f74144035-002d-4e09-82bf-8606ad9f85ea2fnano33onheaderlegs_ntqPRP2FGo.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

This note is the first in a series of simple exercises to explore the libraries that interface with the on-board sensors such as:

  • Inertial measurement unit (IMU) with 9 axes (degrees of freedom)
  • Temperature
  • Pressure
  • Humidity
  • Light
  • Color
  • Microphone

Since the sensors are mounted on the board, there is a faster learning curve since debugging connecting wires on a breadboard is redundant. The board used in these exercises came with the headers mounted – again eliminating the need for post-purchase soldering adventures (for the uninitiated). For more custom solutions, one can purchase a model without the headers.

The Microcomputer

This project is the start of several self-paced training exercises that will illustrate the use of the libraries for the Nano 33:

  • NINA B306 for Bluetooth
  • LSM9DS1 for IMU
  • LPS22HB for barometric pressure and environmental temperature
  • HTS221 for humidity
  • ADPS-9960 for proximity, light, RGB and gesture sensor
  • MP34DT05 for microphone

This note examines only the NINA B306library for Bluetooth connectivity.


The chip-set from u-blox for standalone Bluetooth 5 low energy has its antenna radiation patterns illustrated in the corresponding data-sheet. There are 28digital pins.

Power Modes

There are three power modes for the module:

  • Active
  • Standby
  • Sleep

Serial Communication Interfaces

The module supports the following serial communication interfaces:

  • Universal Asynchronous Receiver/Transmitter (UART), 4-wire, 2x
  • Serial Peripheral Interface (SPI),3x
  • Queued Serial Peripheral Interface (QSPI), 1x
  • Inter-Integrated Circuit (I2C), 2x
  • Inter-IC Sound (I2S), 1x
  • Universal Serial Bus (USB), 2.0, 1x

Digital interfaces

There are two key digital interfaces:

  • Pulse Width Modulation (PWM)
  • Pulse Density Modulation (PDM)


There are 12independent PWM channels to control:

  • Motors
  • Light Emitting Diode (LED)
  • Audio signals

Each channel uses a single General-purpose input/output (GPIO) pin for output signal.


PDM in the current application is primarily for use with the digital microphone for 16-bit samples at 16 kHz rate. It supports single or dual channel data over a single GPIO pin.

Analog Interfaces

Using 8 from 38 digital GPIOs, the analog operations are supported through the following functions:

  • Analog-to-Digital (ADC), 8-channel, 1x
  • Full swing input range from 0 V to VCC
  • 8/10/12-bit resolution
  • 14-bit resolution with oversampling
  • Upto 200 kHz sample rate
  • Single shot or continuous sampling
  • Two operation modes:
  • Single-ended with a single input pin
  • Differential with two input pins and the voltage level difference between them is sampled
  • Either: Analog comparator, 1x
  • Or: Low-power analog comparator, 1x


For the limited purposes of this note, the commands are examined for the Bluetooth functions in the sample code only that introduces the client-server operation which in combination with the notify characteristic becomes and publish-and-subscribe model.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['d121e82dfb'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955976/uploads2ftmp2f8f94520d-ef2f-4627-b889-ecf40969dc5f2f02pnb_FDen7JSsDO.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];


The introductory example illustrates the use of the library withthe following classes:

  • BLE
  • BLECharacteristic
  • BLEService


The primary class in the library to enable Bluetooth services forthe device is BLE (Bluetooth Low Energy or Bluetooth Smart).The key interfaces used in the sample code are illustrated below:

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['a8054c4116'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955977/uploads2ftmp2fb45de3d4-ec78-4dad-8030-928927b4f1992f03pnb_jPgSN8nEeS.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];


The begin method initializes the BLE device upon which itreturns 1 for success or 0 for failure.


The end method stops the BLE device.


The addService method adds a BLE service to the set of services provided by the BLE device.


The setLocalName method sets the local value (i.e.text string) that is used to advertise the BLE device.


The advertise method initiates the advertising of the BLEdevice for service.


The BLECharacteristic class permits the settings for the services at the device.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['4b4dd16d31'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955978/uploads2ftmp2f15eea6ae-2e13-4cc8-b477-ee86c2670f582f04pnb_ZxXayynQYE.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];


The BLECharacteristic constructor for this class createsa new BLE characteristic for the device.


The writeValue method, as the name implies, writes thevalue of the specified BLECharacteristic.


The value method, queries the current value of specified BLECharacteristic for the BLE device.


The BLEService class enables the services of the BLE device.


The BLEService constructor instantiatesa new BLE service for the BLE device using the uuid stringpassed as parameter to the method.

The following uuid string references the LED service:



The addCharacteristicmethod adds a bleCharacteristic to the instantiated servicefor the BLE device.

The bleCharacteristic parameter is set by instantiating from the corresponding class as shown below:

BLEChacteristic ledCharacteristic(uuid, option)

BLEChacteristic buttonCharacteristic(uuid,option)

where option is the union of any of the following modes:

  • BLENotify
  • BLERead
  • BLEWrite

Documenting the Build

All projects in this introductory set of basic and elementary projects, the microcomputer board and the breadboard are mounted on abase-plate. The advantages of this base-plate are:

  • A recessed profile to eliminate exposure to the bottom side
  • Sufficient screws to mount Arduino (UNO or Mega) or RaspberryPi boards
  • Pre-drilled aligned holes for accompanying screws
  • Holes to restrain the base-plate on a table
  • Full size breadboard slot
if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['fb52051428'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955979/uploads2ftmp2ffcebd529-7bf3-475e-8ea2-0e6f11a054492f05pnb_p7Ccyc1EEP.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

The image below illustrates the mounts for the Nano33 in the middle of the full-size breadboard with the push button to the edge to facilitate the insertion of other components and associated wiring for future exercises.

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['68464e0705'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955980/uploads2ftmp2fdb85759a-edcd-4c01-9268-e0f2d1c49a8f2f06pnb_gGL1LsRFL4.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];


The diagram below illustrates the schematic for the elementary exercise to test the ultrasonic sensor:

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['806fff2218'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955981/uploads2ftmp2fc9510b42-e863-42f5-8e1d-887552f2a6012f07pnb_IScVCt67Mp.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];

The assembly diagram below illustrates a proposed layout for the exercise:

if (typeof(lightBoxImages) == 'undefined') { lightBoxImages = {}; } lightBoxImages['613eb73d90'] = [{ URL: 'https://hackster.imgix.net/uploads/attachments/955982/uploads2ftmp2fd025fbc9-8bc3-4319-8fa5-e1345bf71c642f08pnb_2AlXVPVMNS.jpg?auto=compress%2Cformat&w=1280&h=960&fit=max', caption: '', type: 'image' }];


Arduino Nano 33 BLE Sense

ArduinoBLE Library

Digital Proximity, Ambient Light, RGB and Gesture Sensor

Capacitive Digital Sensor for Relative Humidity and Temperature

INEMO Inertial Module

MEMS Audio Sensor

MEMS Nano Pressure Sensor

NINA-B3 Series

nRF52840 Product Specification

Short Video


Nano 33 Sense BLE ButtonLEDC/C++
1. Pair BLE devices
2. Click push button to toggle LED state
  Button LED

  This example creates a BLE peripheral with service that contains a
  characteristic to control an LED and another characteristic that
  represents the state of the button.

  The circuit:
  - Arduino Nano 33 BLE
  - Button connected to pin 4

  You can use a generic BLE central app, like LightBlue (iOS and Android) or
  nRF Connect (Android), to interact with the services and characteristics
  created in this sketch.

  This example code is in the public domain.

#include <ArduinoBLE.h>

const int ledPin = LED_BUILTIN;     // set ledPin to on-board LED
const int buttonPin = 4;            // set buttonPin to digital pin 4; 7th from bottom on right side

BLEService ledService("19B10010-E8F2-537E-4F6C-D104768A1214"); // create a new BLE LED service

                                    // create switch characteristic and allow remote device to read and write
BLEByteCharacteristic ledCharacteristic("19B10011-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
                                    // create button characteristic and allow remote device to get notifications
BLEByteCharacteristic buttonCharacteristic("19B10012-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify);

void setup() {
  while (!Serial);

  pinMode(ledPin, OUTPUT);          // use the LED as an output
  pinMode(buttonPin, INPUT);        // use button pin as an input

  if (!BLE.begin())                 // initialize the BLE device
  {                                 // 1 on success, 0 on failure
    Serial.println("Failed to start BLE!");
    while (1);                      // only wait out is to kill execution

  BLE.setLocalName("Nano33 ButtonLED");// set the local value used when advertising
  BLE.setAdvertisedService(ledService);// set the advertised service UUID used when advertising to the value of the BLEService provided
  ledService.addCharacteristic(ledCharacteristic);// add the characteristics to the service

  BLE.addService(ledService);       // add the service


  BLE.advertise();                  // start advertising

  Serial.println("Bluetooth device active, waiting for connections...");

void loop() {

  BLE.poll();                       // poll for BLE events

  char buttonValue = digitalRead(buttonPin);  // read the current button pin state

  boolean buttonChanged = (buttonCharacteristic.value() != buttonValue);// has the value changed since the last read

  if (buttonChanged)
    ledCharacteristic.writeValue(buttonValue);// button state changed, update characteristics

  if (ledCharacteristic.written() || buttonChanged)
    if (ledCharacteristic.value())  // update LED, either central has written to characteristic or button state has changed
      Serial.println("LED on");
      digitalWrite(ledPin, HIGH);
      Serial.println("LED off");
      digitalWrite(ledPin, LOW);

Custom parts and enclosures

ButtonLED assembly
Hardware assembly (for illustration only)
Uploads2ftmp2f7d44488c f25a 433a 96e2 25f305bf27632fbuttonled bb bcxyann0i1


ButtonLED schematic
Schematic diagram to assist in determining the pin connectivity
Uploads2ftmp2f836c95e5 446c 4385 a0fd 16acb7bf83072fbuttonled schem tgnto49olh


Similar projects you might like

Arduino - Use Reset Button Like a Push Button

by RoHa

  • 13 respects

Push Button Combination Lock Using Arduino

Project tutorial by Asim Zulfiqar and High Voltages

  • 41 respects

Dimming Lights with PWM using Push Button

Project tutorial by Phuong Vo

  • 18 respects

Snap Circuits® - Push Button LED

Project tutorial by Daniel Porrey

  • 12 respects

Snap Circuits® - Push Button Monitor

Project tutorial by Daniel Porrey

  • 9 respects

Slack Away Button with Wia Dot One and Button Module

Project tutorial by Team Wia

  • 8 respects
Add projectSign up / Login