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