nRF52-PCA20020 (Thingy:52)

Overview

Zephyr uses the nrf52_pca20020 board configuration for building for the Thingy:52 board. The board has the nRF52832 MCU with ARM Cortex-M4F processor, a set of environmental sensors, a pushbutton, and two RGB LEDs.

  • NVIC
  • RTC
  • UART
  • GPIO
  • FLASH
  • RADIO (Bluetooth Low Energy)
nRF52 Thingy:52

nRF52 Thingy:52 (Credit: Nordic Semi)

More information about the board can be found at the nRF52 DK website [1]. The Nordic Semiconductor Infocenter [2] contains the processor’s information and the datasheet.

Hardware

Thingy:52 has the following features:

  • Two RGB LEDs
  • CO2 and TVOC sensor
  • Humidity and temperature sensor
  • Color sensor
  • I2C GPIO expander
  • Provisions for a pin header and I2C and serial connectors
  • Bluetooth radio

Supported Features

Interface Controller Driver/Component
NVIC on-chip nested vectored interrupt controller
RTC on-chip system clock
UART on-chip serial port
I2C on-chip i2c master
GPIO on-chip gpio
FLASH on-chip flash
RADIO on-chip Bluetooth

Connections and IOs

Lightwell RGB LED

The LED is driven by the SX1509B GPIO expander chip (device name GPIO_P0).

GPIO Expander Pin LED Channel
5 Green
6 Blue
7 Red

Button

Thingy:52 has a pushbutton, connected to the P0.11 SOC GPIO pin.

Serial

By default the system UART has the following pin configuration:

SOC Pin Signal
P0.02 TX
P0.03 RX

The pins can be found on the P4 and P6 connectors. The system UART console uses these pins by default.

Internal I2C Bus

The internal I2C bus (I2C_0) is not routed to any of the external connectors, but most of the on-board devices are accessed trough it. The following pins have been assigned to the bus:

SOC Pin Signal
P0.07 SDA
P0.08 SCL

The following devices are attached to the bus.

Device Address
SX1509B 0x3e
LPS22HB 0x5c
HTS221 0x5f
CCS811 0x5a

External I2C Bus

The external I2C bus (I2C_1) can be found on the P4 header and the P5 and P7 connectors.

SOC Pin Signal
P0.14 SDA_EXT
P0.15 SCL_EXT

Pin Header

This is the pinout of the P4 pin header. Some of the SOC GPIO pins and I2C GPIO expander pins are accessible through it. It also allows attaching external devices to the four on-board N-channel MOSFET transistors.

Pin Device Signal / Device Pin
1 SOC SCL_EXT / P0.15
2 SOC SDA_EXT / P0.14
3 SOC ANA/DIG0 / P0.02
4 SOC ANA/DIG1 / P0.03
5 SOC ANA/DIG2 / P0.04
6   GND
7 GPIO Expander Pin 0
8 GPIO Expander Pin 1
9 GPIO Expander Pin 2
10 GPIO Expander Pin 3
11 MOSFET 1 Drain
12 MOSFET 1 Source
13 MOSFET 2 Drain
14 MOSFET 2 Source
15 MOSFET 3 Drain
16 MOSFET 3 Source
17 MOSFET 4 Drain
18 MOSFET 4 Source
19   VDD
20   GND
MOSFETs

The MOSFETs are attached to the following SOC GPIO pins:

Device Gate Pin
MOSFET 1 P0.18
MOSFET 2 P0.19
MOSFET 3 P0.20
MOSFET 4 P0.21

Power Rails

Thing:52 has multiple power rails. The necessary rails for the currently supported devices are listed here.

Name Derived from Controlled by
VREG The battery Always on
VDD_nRF VREG Always on
VDD VREG SOC pin P0.30
VDD_CCS VDD GPIO expander pin 10

Due to the dependencies of the power rails, multiple rails may need to be powered for a given device to turn on. The correct order of powering up the rails is the order of the rails down the dependency chain. For example, in order to power the CCS811 gas sensor, VDD has to be turned on first and VDD_CCS after it. Here’s a list of the devices and their power rails:

Device Rail
nRF52832 VDD_nRF
SX1509B VDD
LPS22HB VDD
HTS221 VDD
CCS811 VDD_CCS

Sensors

Device Function Bus I2C Address Power Rail
LPS22HB Pressure and Temperature sensor I2C_0 0x5c VDD
HTS221 Humidity and Temperature sensor I2C_0 0x5f VDD
CCS811 Gas sensor I2C_0 0x5a VDD_CCS

Misc. Device Pins

SX1509B
Device Signal SOC Pin
SX_OSCIO P0.05
SX_RESET P0.16
LPS22HB
Sensor Signal SOC Pin
LPS_INT P0.23
HTS221
Sensor Signal SOC Pin
HTS_INT P0.24
CCS811
Sensor Signal GPIO Expander Pin
CCS_RESET 11
CCS_WAKE 12

Programming and Debugging

Flashing

Flashing Zephyr onto Thingy:52 requires an external J-Link programmer. The programmer is attached to the P9 programming header.

Debugging

Thingy:52 does not have an on-board J-Link debug IC as some other nRF5 development boards, however, instructions from the Nordic nRF5x Segger J-Link page also apply to this board, with the additional step of connecting an external debugger. A development board with a Debug out connector such as the nRF52-PCA10040 can be used as a debugger with Thingy:52.

Testing board features

The green lightwell LED can be tested with the Blinky Application example.

# On Linux/macOS
cd $ZEPHYR_BASE/samples/basic/blinky
mkdir build && cd build

# On Windows
cd %ZEPHYR_BASE%\samples\basic\blinky
mkdir build & cd build

# Use cmake to configure a Ninja-based build system:
cmake -GNinja -DBOARD=nrf52_pca20020 ..

# Now run ninja on the generated build system:
ninja
ninja flash

Also the temperature and humidity sensor can be tested with the HTS221: Temperature and Humidity Monitor sample.

# On Linux/macOS
cd $ZEPHYR_BASE/samples/sensor/hts221
mkdir build && cd build

# On Windows
cd %ZEPHYR_BASE%\samples\sensor\hts221
mkdir build & cd build

# Use cmake to configure a Ninja-based build system:
cmake -GNinja -DBOARD=nrf52_pca20020 ..

# Now run ninja on the generated build system:
ninja
ninja flash