1.. _thingy52_nrf52832: 2 3Thingy:52 4######### 5 6Overview 7******** 8 9Zephyr uses the thingy52_nrf52832 (PCA20020) board configuration for building 10for the Thingy:52 board. The board has the nRF52832 MCU with ARM Cortex-M4F 11processor, a set of environmental sensors, a pushbutton, and two RGB LEDs. 12 13* :abbr:`ADC (Analog to Digital Converter)` 14* CLOCK 15* FLASH 16* Gas sensor 17* :abbr:`GPIO (General Purpose Input Output)` 18* GPIO Expander 19* Humidity and temperature sensor 20* :abbr:`I2C (Inter-Integrated Circuit)` 21* :abbr:`MPU (Memory Protection Unit)` 22* :abbr:`NVIC (Nested Vectored Interrupt Controller)` 23* Pressure sensor 24* :abbr:`PWM (Pulse Width Modulation)` 25* RADIO (Bluetooth Low Energy) 26* RGB LEDs 27* :abbr:`RTC (nRF RTC System Clock)` 28* :abbr:`SPI (Serial Peripheral Interface)` 29* :abbr:`UART (Universal asynchronous receiver-transmitter)` 30* :abbr:`WDT (Watchdog Timer)` 31 32.. figure:: img/thingy52_nrf52832.jpg 33 :align: center 34 :alt: nRF52 Thingy:52 35 36 nRF52 Thingy:52 (Credit: Nordic Semiconductor) 37 38More information about the board can be found at the `nRF52 DK website`_. The 39`Nordic Semiconductor Infocenter`_ contains the processor's information and the 40datasheet. 41 42 43Hardware 44******** 45 46Thingy:52 has the following features: 47 48* Two RGB LEDs 49* CO2 and TVOC sensor 50* Humidity and temperature sensor 51* Color sensor 52* I2C GPIO expander 53* Provisions for a pin header and I2C and serial connectors 54* Bluetooth radio 55 56Supported Features 57================== 58 59+-----------+------------+----------------------+ 60| Interface | Controller | Driver/Component | 61+===========+============+======================+ 62| ADC | on-chip | adc | 63+-----------+------------+----------------------+ 64| CLOCK | on-chip | clock_control | 65+-----------+------------+----------------------+ 66| FLASH | on-chip | flash | 67+-----------+------------+----------------------+ 68| Gas | on-board | ccs811 | 69| Sensor | | | 70+-----------+------------+----------------------+ 71| GPIO | on-chip | gpio | 72+-----------+------------+----------------------+ 73| GPIO Exp | on-board | sx1509b | 74+-----------+------------+----------------------+ 75| Humidity | on-board | hts221 | 76| and Temp | | | 77+-----------+------------+----------------------+ 78| I2C(M) | on-chip | i2c | 79+-----------+------------+----------------------+ 80| MPU | on-chip | arch/arm | 81+-----------+------------+----------------------+ 82| NVIC | on-chip | arch/arm | 83+-----------+------------+----------------------+ 84| Pressure | on-board | lps22hb_press | 85| and Temp | | | 86+-----------+------------+----------------------+ 87| PWM | on-chip | pwm | 88+-----------+------------+----------------------+ 89| RADIO | on-chip | Bluetooth | 90+-----------+------------+----------------------+ 91| RTC | on-chip | system clock | 92+-----------+------------+----------------------+ 93| SPI(M/S) | on-chip | spi | 94+-----------+------------+----------------------+ 95| UART | on-chip | serial | 96+-----------+------------+----------------------+ 97| WDT | on-chip | watchdog | 98+-----------+------------+----------------------+ 99 100Connections and IOs 101=================== 102 103Lightwell RGB LED 104----------------- 105The LED is driven by the SX1509B GPIO expander chip (device name GPIO_P0). 106 107+-------------------+-------------+ 108| GPIO Expander Pin | LED Channel | 109+===================+=============+ 110| 5 | Green | 111+-------------------+-------------+ 112| 6 | Blue | 113+-------------------+-------------+ 114| 7 | Red | 115+-------------------+-------------+ 116 117Button 118------ 119 120Thingy:52 has a pushbutton, connected to the P0.11 SOC GPIO pin. 121 122Serial 123------ 124 125By default the system UART has the following pin configuration: 126 127+---------+--------+ 128| SOC Pin | Signal | 129+=========+========+ 130| P0.02 | TX | 131+---------+--------+ 132| P0.03 | RX | 133+---------+--------+ 134 135The pins can be found on the P4 and P6 connectors. The system UART console 136uses these pins by default. 137 138Internal I2C Bus 139---------------- 140 141The internal I2C bus (I2C_0) is not routed to any of the external connectors, 142but most of the on-board devices are accessed through it. The following pins 143have been assigned to the bus: 144 145+---------+---------+ 146| SOC Pin | Signal | 147+=========+=========+ 148| P0.07 | SDA | 149+---------+---------+ 150| P0.08 | SCL | 151+---------+---------+ 152 153The following devices are attached to the bus. 154 155+----------+---------+ 156| Device | Address | 157+==========+=========+ 158| SX1509B | 0x3e | 159+----------+---------+ 160| LPS22HB | 0x5c | 161+----------+---------+ 162| HTS221 | 0x5f | 163+----------+---------+ 164| CCS811 | 0x5a | 165+----------+---------+ 166 167External I2C Bus 168---------------- 169 170The external I2C bus (I2C_1) can be found on the P4 header and the P5 and P7 171connectors. 172 173+---------+---------+ 174| SOC Pin | Signal | 175+=========+=========+ 176| P0.14 | SDA_EXT | 177+---------+---------+ 178| P0.15 | SCL_EXT | 179+---------+---------+ 180 181Pin Header 182---------- 183 184This is the pinout of the P4 pin header. Some of the SOC GPIO pins and I2C GPIO 185expander pins are accessible through it. It also allows attaching external 186devices to the four on-board N-channel MOSFET transistors. 187 188+-----+---------------+-----------------------+ 189| Pin | Device | Signal / Device Pin | 190+=====+===============+=======================+ 191| 1 | SOC | SCL_EXT / P0.15 | 192+-----+---------------+-----------------------+ 193| 2 | SOC | SDA_EXT / P0.14 | 194+-----+---------------+-----------------------+ 195| 3 | SOC | ANA/DIG0 / P0.02 | 196+-----+---------------+-----------------------+ 197| 4 | SOC | ANA/DIG1 / P0.03 | 198+-----+---------------+-----------------------+ 199| 5 | SOC | ANA/DIG2 / P0.04 | 200+-----+---------------+-----------------------+ 201| 6 | | GND | 202+-----+---------------+-----------------------+ 203| 7 | GPIO Expander | Pin 0 | 204+-----+---------------+-----------------------+ 205| 8 | GPIO Expander | Pin 1 | 206+-----+---------------+-----------------------+ 207| 9 | GPIO Expander | Pin 2 | 208+-----+---------------+-----------------------+ 209| 10 | GPIO Expander | Pin 3 | 210+-----+---------------+-----------------------+ 211| 11 | MOSFET 1 | Drain | 212+-----+---------------+-----------------------+ 213| 12 | MOSFET 1 | Source | 214+-----+---------------+-----------------------+ 215| 13 | MOSFET 2 | Drain | 216+-----+---------------+-----------------------+ 217| 14 | MOSFET 2 | Source | 218+-----+---------------+-----------------------+ 219| 15 | MOSFET 3 | Drain | 220+-----+---------------+-----------------------+ 221| 16 | MOSFET 3 | Source | 222+-----+---------------+-----------------------+ 223| 17 | MOSFET 4 | Drain | 224+-----+---------------+-----------------------+ 225| 18 | MOSFET 4 | Source | 226+-----+---------------+-----------------------+ 227| 19 | | VDD | 228+-----+---------------+-----------------------+ 229| 20 | | GND | 230+-----+---------------+-----------------------+ 231 232MOSFETs 233~~~~~~~ 234 235The MOSFETs are attached to the following SOC GPIO pins: 236 237+----------+----------+ 238| Device | Gate Pin | 239+==========+==========+ 240| MOSFET 1 | P0.18 | 241+----------+----------+ 242| MOSFET 2 | P0.19 | 243+----------+----------+ 244| MOSFET 3 | P0.20 | 245+----------+----------+ 246| MOSFET 4 | P0.21 | 247+----------+----------+ 248 249Power Rails 250----------- 251 252Thing:52 has multiple power rails. The necessary rails for the currently 253supported devices are listed here. 254 255+---------+--------------+----------------------+ 256| Name | Derived from | Controlled by | 257+=========+==============+======================+ 258| VREG | The battery | Always on | 259+---------+--------------+----------------------+ 260| VDD_nRF | VREG | Always on | 261+---------+--------------+----------------------+ 262| VDD | VREG | SOC pin P0.30 | 263+---------+--------------+----------------------+ 264| VDD_CCS | VDD | GPIO expander pin 10 | 265+---------+--------------+----------------------+ 266 267Due to the dependencies of the power rails, multiple rails may need to be 268powered for a given device to turn on. The correct order of powering up the 269rails is the order of the rails down the dependency chain. For example, in order 270to power the CCS811 gas sensor, VDD has to be turned on first and VDD_CCS after 271it. Here's a list of the devices and their power rails: 272 273+----------+---------+ 274| Device | Rail | 275+==========+=========+ 276| nRF52832 | VDD_nRF | 277+----------+---------+ 278| SX1509B | VDD | 279+----------+---------+ 280| LPS22HB | VDD | 281+----------+---------+ 282| HTS221 | VDD | 283+----------+---------+ 284| CCS811 | VDD_CCS | 285+----------+---------+ 286 287Sensors 288------- 289 290+----------+---------------------------------+-------+-------------+------------+ 291| Device | Function | Bus | I2C Address | Power Rail | 292+==========+=================================+=======+=============+============+ 293| LPS22HB | Pressure and Temperature sensor | I2C_0 | 0x5c | VDD | 294+----------+---------------------------------+-------+-------------+------------+ 295| HTS221 | Humidity and Temperature sensor | I2C_0 | 0x5f | VDD | 296+----------+---------------------------------+-------+-------------+------------+ 297| CCS811 | Gas sensor | I2C_0 | 0x5a | VDD_CCS | 298+----------+---------------------------------+-------+-------------+------------+ 299 300Misc. Device Pins 301----------------- 302 303SX1509B 304~~~~~~~ 305 306+---------------+-------------------+ 307| Device Signal | SOC Pin | 308+===============+===================+ 309| SX_OSCIO | P0.05 | 310+---------------+-------------------+ 311| SX_RESET | P0.16 | 312+---------------+-------------------+ 313 314LPS22HB 315~~~~~~~ 316 317+---------------+-------------------+ 318| Sensor Signal | SOC Pin | 319+===============+===================+ 320| LPS_INT | P0.23 | 321+---------------+-------------------+ 322 323HTS221 324~~~~~~ 325 326+---------------+-------------------+ 327| Sensor Signal | SOC Pin | 328+===============+===================+ 329| HTS_INT | P0.24 | 330+---------------+-------------------+ 331 332CCS811 333~~~~~~ 334 335+---------------+-------------------+ 336| Sensor Signal | GPIO Expander Pin | 337+===============+===================+ 338| CCS_RESET | 11 | 339+---------------+-------------------+ 340| CCS_WAKE | 12 | 341+---------------+-------------------+ 342 343Programming and Debugging 344************************* 345 346Flashing 347======== 348 349Flashing Zephyr onto Thingy:52 requires an external J-Link programmer. The 350programmer is attached to the P9 programming header. 351 352 353Debugging 354========= 355 356Thingy:52 does not have an on-board J-Link debug IC as some other nRF5 357development boards, however, instructions from the :ref:`nordic_segger` page 358also apply to this board, with the additional step of connecting an external 359debugger. A development board with a Debug out connector such as the 360:ref:`nrf52dk_nrf52832` can be used as a debugger with Thingy:52. 361 362Testing board features 363********************** 364 365The green lightwell LED can be tested with the :zephyr:code-sample:`blinky` example. 366 367.. zephyr-app-commands:: 368 :zephyr-app: samples/basic/blinky 369 :board: thingy52_nrf52832 370 :goals: build flash 371 372 373 374Also the temperature and humidity sensor can be tested with the :ref:`hts221` 375sample. 376 377.. zephyr-app-commands:: 378 :zephyr-app: samples/sensor/hts221 379 :board: thingy52_nrf52832 380 :goals: build flash 381 382References 383********** 384 385.. target-notes:: 386 387.. _nRF52 DK website: https://www.nordicsemi.com/Software-and-Tools/Development-Kits/Nordic-Thingy-52 388.. _Nordic Semiconductor Infocenter: http://infocenter.nordicsemi.com/ 389