diff --git a/README-en.md b/README-en.md new file mode 100644 index 0000000..879e9c8 --- /dev/null +++ b/README-en.md @@ -0,0 +1,382 @@ +# LINE Things Development Board +The LINE Things development board is powered by [Nordic Semiconductor's nRF52832] (https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52832), in which the specific module used is the [Raytac MDBT42Q] (http: // www.raytac.com/product/ins.php?index_id=31). This development board is for experimenting with LINE Things. It actually consists of two boards, the first being the core or the CPU board, and the other is the peripheral board or the daughterboard. After verifying the functionality of a concept through the daughterboard, the core can be removed to be placed into a breadboard for custom board designs and prototyping. + +The [Arduino library open sourced by Adafruit] (https://github.com/adafruit/Adafruit_nRF52_Arduino) is used here to allow beginners and veterans to easily experiment with LINE Things through Arduino IDE. + +This document provides details on how to use each board and the peripherals mounted on the boards. +Please refer to each page about how to use LINE Things and Bluetooth LE. + +-[LINE Things-LINE Developers] (https://developers.line.biz/en/docs/line-things/) +-[LINE Hands on dev board use] (https://qiita.com/cpulabs/items/3a37a70cfa41129cb024) +-[Try trial of LINE's IoT platform LINE Things Developer Trial] (https://engineering.linecorp.com/en/blog/line-things-developer-trial/) +-[LINE Things automatic communication function has been released & how to use it] (https://engineering.linecorp.com/en/blog/line-things-automatic-communication/) + +### [Important] Notes on using the Grove connector + +The main board itself will function normally as it is, however there are a couple of mislabeled parts concerning the **Grove connectors on board**. + +* Labels of **P2** and **P6** on the board are swapped. The correct labels should be, **P2** is I2C (5V) and **P6** is I2C (3.3V). +* Labels of **P7** and **P8** on the board are swapped. The correct labels should be, **P7** is Grove-I/O and **P8** is Grove-UART. + +## Table of Contents + +[Documentation on Github Pages] (https://line.github.io/line-things-dev-board/) + +-README.md + -[Quick Start] (#quick-start) + -[How to use] (#How to use) + -[Precautions] (#Precautions) + -[Hardware Specification] (#Hardware Specification) + -[Extension] (#Extension) + -[Schematics and Board Design] (#Schematics and Board Design) +-Documents + -[Default Firmware] (docs-en/default-firmware.md) + -[Controlling LINE Things Development Board through JavaScript] (docs-en/js-control.md) + -[Flashing Firmware] (docs-en/update-firmware.md) + -[Sample Code for Arduino] (docs-en/examples.md) + -[Troubleshooting] (docs-en/trouble-shooting.md) + +## Quick Start +With the default firmware, you can experiment with LINE Things and all of the on-board peripherals right away. +You will be able to view the statuses of all the sensors, as well as control the LEDs. +Upon powering the board on and connecting to it via LINE Things, you will be able to Write values to the device and send Notify events back to LINE app. +Please note that the default TX power setting is set to the minimum setting, so you will need to be physically close to the device. + +### For the first time using LINE Things +If this is the first time you are using LINE Things, please scan the QR code founnd on the daughter board or on the under side of the CPU board. You will need to agree to the terms of use in order to use LINE Things. + +! [] (https://developers.line.biz/media/line-things/qr_code-311f3503.png) + +### Using the Default Firmware +The default firmware provides control of the development board through LIFF without the need to make any modifications to the firmware. For example, it is possible to send notifications from the development board with values from the sensors etc. +A library, utilizing LIFF's Javascript API, is also provided to make it easy to interact wioth the default firmware. + +For the default firmware specifications, refer to [Default Firmware] (docs / default-firmware.md). +For more information about the JavaScript libraries, refer to [Controlling LINE Things Development Board via JavaScript] (docs / js-control.md). +LIFF app for the default firmware is at `liff-app / linethings-dev-default /` and `liff-app / linethings-js-control /`. + +The firmware has a function to rewrite the Service UUID of the Advertising packet through LIFF. +The Service UUID can be obtained from the LINE Developers console and is used for building devices through LINE Things Developer Trial. +The function is to be used to allow devices to be unique without making modifications to the firmware. + +##### Modify and initialize Service UUID from LIFF +LINE Things Developer Trial requires a product to be registered and a GATT Service UUID to be generated. +You can modify the Service UUID in the example LIFF app at (`liff-app / linethings-dev-default /`, `liff-app / linethings-js-control /`). +With this, you will not need to modify the device firmware. + +###### Rewriting Service UUID from LIFF +Open the default LIFF app from LINE and head on over to the Write advertising packet tab. +Put the Service UUID you want to advertise in the text box and press the rewrite button. +If the display on the Dev board shows "BLE advertising uuid changed from LIFF ....", then the new Service UUID is now programmed onto the device. + +Upon success, **Close LINE Things in LINE App and press the Reset button on the dev board**. + +###### Return the Service UUID to its initial state +With the power on, press the reset button on the CPU board while pressing the SW1 tactile switch on the board. +You will see on the screen, `Set advertising packet UUID to default.` upon startup. + +### Customizing the Firmware +[Adafruit open-source Arduino library] (https://github.com/adafruit/Adafruit_nRF52_Arduino) can be used to easily develop on Arduino IDE. + +For hardware specifications, refer to [Hardware Specification] (# Hardware Specifications). +Refer to [Flashing the Firmware] (docs / update-firmware.md) for the steps on flashing the firmware. +The sample code, [Sample Code] (docs / examples.md), describes how to control each peripheral. + +If you want to revert to the default firmware, use `arduino / linethings-dev-default / linethings-dev-default.ino`. +This example uses `things_temp_lib`,` SparkFun MMA8452Q Accelerometer`, `Adafruit SSD1306`,` Adafruit GFX Library`. `things_temp_lib` is available at ` library / things_temp_lib` compressed as a zip file. You will need to extract it into your Arduino library directory. For other libraries, please install them through the library manager. + +[LINE Things Starter] (https://github.com/line/line-things-starter) is also compatible with LINE Things dev board. +From LINE Things Starter's repository, flash the firmware for the LINE Things dev board. + +--- + +## How to use +### Inserting the CPU core and using the daughter board +First, ensure that the CPU core is installed onto the daughter board. To install the CPU core onto the daughter board, line up the pins of the CPU core to the daughter board. make sure that the Bluetooth antenna is pointing towards the **outside** of the board. + +#### 1. Selecting the power source +The motherboard can be powered by external power sources such as through USB or a bench supply as well as on-board sources such as through batteries. Be sure to turn off the * SW3 * power switch before making these settings. +To power the board via external power sources such as USB or a bench supply, make sure the power connection **disconnected** first. Move the jumper on **P4** to the upper side to select external power source. Connect your power supply to power the board. +Likewise, to use the internal power source, ie. battery, move the jumper on **P4** to the lower side to select the on-board power source. To turn the board on, you will need to slide SW3 to **On**. + +[motherboard_power] (https://user-images.githubusercontent.com/135050/55808659-1d993400-7bfe-11e9-8bd1-298ff1bf8d40.jpg) + + * External power supply and USB power + * Set *P4* to the top as seen from the front as shown in the picture. + * Battery powered + * Set *P4* to the bottom as seen from the front as shown in the picture. + +※ 5V logic systems can not be used in case of battery power source. An external power source is advised +※ Do not use USB power to drive motors. An external power supply is advised to drive motors instead. + +#### 2. Turning on the board + +* External power supply and USB power + * Connecting a USB cable or a power source through the *CN3* connector will turn on the board, regardless of the *SW3* switch's position. +* Battery powered + * With the battery installed, slide the *SW3* power switch upwards to the ON position to turn the board on. + +Make sure that the power supply LED (*DS1*) is on. You are now ready to use the development board. + +### Using the CPU Core as a Standalone +The CPU core is fully functional as a standalone board, requiring only power to be supplied to it. The Reset pin is internally pulled up and can be left unconnected if unused. + +## Usage Notes +### CPU board +[motherboard_direction] (https://user-images.githubusercontent.com/135050/58088649-16722600-7bfe-11e9-8b84-82e1e9ebd65e.jpg) + + * Before powering the development board on, be sure that the CPU core is connected in the correct orientation. + * When using the CPU core as a standalone, ensure the antenna sits as far away from the breadboard as possible (preferably the edge of the breadboard) to avoid any interference. Additionally, any GND wiring and planes as well as any RF signals near the attena can cause interference. + * For a reliable connection and communication, make sure to keep the antenna as exposed as possible. Avoid metallic enclosures as it can block BLE signals. Plastic enclosures are highly advised. + +### Motherboard + * Labels of **P2** and **P6** on the board are swapped. The correct labels should be, **P2** is I2C (5V) and **P6** is I2C (3.3V). + * Labels of **P7** and **P8** on the board are swapped. The correct labels should be, **P7** is Grove-I/O and **P8** is Grove-UART. + * If you are using batteries as your power supply, make sure the polarity of the batteries are properly placed. Reverse voltages may cause permanent damages to the boards. + * If the board is powered externally at 3.3V, make sure to not draw power more than 600mA (total power draw, including the CPU core's consumption) to avoid any damage to the power regulator. + * Ensure the polarity of the power source's connections as well as the voltage before making connections to the board. + * Some parts may missing from the board, you may add them as needed. + +--- + +## Hardware Specifications +### CPU core +[cpuboard] (https://user-images.githubusercontent.com/135050/58088657-1bcf7080-7bfe-11e9-89f4-5e6bbde1a363.jpg) + +The [Raytac MDBT42Q] (http://www.raytac.com/product/ins.php?index_id=31) module is the main processor of this development board. +Adafruit's nRF52 Arduino library is compatible with this module and can be used for development through Arduino IDE. It also has JTAG pins available to be connected via J-LINK etc. +You can also develop everything from scratch using Nordic's nRF5 SDK. Both configurations of the board are supported; CPU core as a standalone as well as paired with the daughter board as a complete development board of LINE Things. + +#### Pin assignment +[cpuboard_pinassign] (https://user-images.githubusercontent.com/135050/58088655-1a9e4380-7bfe-11e9-90d4-530f84e56242.png) + +#### Technical Specification +The following is CPU core's specification. + +| Item | Value | +---- | ---- +Operational voltage | 1.7 to 3.6 V | +| Maximum RF Power | 4dBm | +| Flash size | 512KB | +| RAM size | 64KB | + +### Daughter board +[daughterboard] (https://user-images.githubusercontent.com/135050/58088621-078b7380-7bfe-11e9-8d0d-8d9c216770b4.jpg) + +Mounted on the daughter board are LEDs, tactile switches, temperature sensors, and an OLED screen. +**Please ensure the orientation of the CPU core when using the daughter board. Permanent damages may occur if placed incorrectly.** + +#### Technical Specification +| Item | Value | +---- | ---- +Power source | Battery / USB / external power supply | +Operational voltage (battery) | 3V (2 single AAA batteries 1.5V in series) | +Operational voltage (USB) | 5V | +Operational voltage (external supply) | 5V | +| Maximum continuous current consumption (battery powered / motor not used) | 0.6A | +| Maximum continuous current consumption (when using motor) | 2.6A | + +## Peripherals on the daughter board +**NOTE 5V systems and 3.3V systems cannnot be directly connected to one another.** +The development board will act as a 5V system if powered by an external power source. Conversely, the development board will be a 3.3V system if powered by batteries. Please proceed with caution and make sure all connections are made with their corresponding voltages. +**You WILL damage your board if connections to an incompatible voltage system is made.** + +### LED +The anode of the LED is connected to the microcontroller. Therefore, when the microcontroller outputs High, the LED will turn on. Please set the port to output when using it. + +| Board number | Microcontroller pin number | +---- | ---- +| DS2 | 7 | +| DS3 | 11 | +| DS4 | 19 | +| DS5 | 17 | + +### Tactile switch +The tactile switches are not pulled up nor down on the circuit, therefore, you will need to set the pins to INPUT_PULLUP when programming the microcontroller. + +| Board number | Microcontroller pin number | +---- | ---- +| SW1 | 29 | +| SW2 | 28 | + +### Buzzer +A piezoelectric buzzer is included. To make the buzzer sound, you will need to provide an AC signal from the microcontroller. Setting the pin to HIGH will not cause the buzzer to make a sound. Normally on a regular Arduino, you would be able to use the tone() function to create such signals, however the timer in the nRF52832 is incompatible with this library. Therefore, you will need to generate the signal yourself through timers, interrupts, etc. In the sample provided, we take advantage of FreeRTOS's timer to generate a 1KHz interrupt to toggle the pin state which creates a 500Hz signal to make the buzzer sound. If you want to change the pitch of the buzzer, you will need to play around with the timers. +You can use the tone () function to produce any sound with regular Arduino, but you can not use this with the nRF52832 Arduino environment. + +| Board number | Microcontroller pin number | +---- | ---- +| BZ1 | 27 | + +### OLED +The board includes a 128x64 pixel OLED Screen (SSD1306), connected via I2C. You can control the board via Adafruit's SSD1306 Library. The I2C address of the screen is **0x3D**. + + +| Pin name | Microcontroller pin number | +---- | ---- +| SCL | 26 | +| SDA | 25 | + +### Temperature sensor +A temperature sensor (AT30TS74) is also included; connected via I2C, its address is at **0x48**. + +| Device pin | Microcontroller pin number | +---- | ---- +| SCL | 26 | +| SDA | 25 | + +### Accelerometer +An accelerometer (MMA8452Q) is also connected via I2C at the address **0x1C**. Sparkfun provides a handy library for this module. + +| Device pin | Microcontroller pin number | +---- | ---- +| SCL | 26 | +| SDA | 25 | + +### Motor +Two motor drivers (DRV8830) can be installed. Once soldered, they will be connected via I2C with the addresses at **0x60** (CN1) and **0x62** (CN2) + +| Device pin | Microcontroller pin number | +---- | ---- +| SCL | 26 | +| SDA | 25 | + +#### Notes +* The motor driver is not installed by default. To use it, you need to remove some parts and solder additional parts yourself. +Please see [Motor Driver] (# Motor Driver) for details. +* Driving motors is for a 5V system. Please use an external power source to power the board when driving motors. + +### Grove terminal (I2C) +The correct connection for this is **P6** on the board. There is a misprint on the silkscreen. + +| Connector pin number | Pin name | Microcontroller pin number | +---- | ---- | ---- +| 1 | SCL | 26 | +| 2 | SDA | 25 | +| 3 | 3.3V |-| +| 4 | GND |-| + +#### Notes +* This connector is not installed by default. You need to solder the Grove connector to use it. +* Although the label on the board is Grove-I2C 5V on P6, the correct labels should be I2C-3.3V for P6 and I2C-5V for P2. + +### Grove terminal (I2C / 5V system) +The correct connection for this is **P2** on the board. There is a misprint on the silkscreen. + +| Connector pin number | Pin name | Microcontroller pin number | +---- | ---- | ---- +| 1 | SCL | 26 | +| 2 | SDA | 25 | +| 3 | 5V |-| +| 4 | GND |-| + +#### Notes +* This connector is not installed by default. You need to solder the Grove connector to use it. +* Although the label on the board is I2C-3.3V on P2, the correct labels should be I2C-3.3V for P6 and I2C-5V for P2. +* This is for 5V systems. Please make sure the board is powered by an external power source to use this port. +* Connect devices with 5V interfaces through this connector. Connecting a 3.3V device will cause damages to the board and the device. + +### Grove terminal (UART) +The correct connection for this is **P8** on the board. There is a misprint on the silkscreen. + +| Connector pin number | Pin name | Microcontroller pin number | +---- | ---- | ---- +| 1 | RxD | 6 | +| 2 | TxD | 8 | +| 3 | 3.3V |-| +| 4 | GND |-| + +#### Notes +* This connector is not installed by default. You need to solder the Grove connector yourself to use it. + +### Grove terminal (general purpose digital I / O) +The correct connection for this is **P7** on the board. There is a misprint on the silkscreen. + +| Connector pin number | Pin name | Microcontroller pin number | +---- | ---- | ---- +| 1 | D0 | 2 | +| 2 | D 1 | 3 | +| 3 | 3.3V |-| +| 4 | GND |-| + +#### Notes +* This connector is not installed by default. You need to solder the Grove connector yourself to use it. + +### GPIO +The pins are at **P1** on the board. + +Pin 6 is a reset pin. You can reset the microcontroller by setting it to LOW. It is pulled up on the CPU core board, so it can be disconnected if not used. + +| Connector pin number | Pin name | Microcontroller pin number | +---- | ---- | ---- +| 1 | I / O | 2 | +| 2 | 5V |-| +| 3 | I / O | 3 | +| 4 | 3.3V |-| +| 5 | I / O | 4 | +| 6 | RESET |-| +| 7 | I / O | 5 | +| 8 | I / O | 26 (SCL) | +| 9 | I / O | 12 | +| 10 | I / O | 25 (SDA) | +| 11 | I / O | 13 | +| 12 | I / O | 16 | +| 13 | I / O | 14 | +| 14 | I / O | 15 | +| 15 | I / O | 8 (RxD) | +| 16 | O | 11 (LED-DS3) | +| 17 | I / O | 6 (TxD) | +| 18 | O | 7 (LED-DS2) | +| 19 | GND | | +| 20 | GND | | + +#### Notes +* Pins 8 and 10 are connnected via I2C to the CPU core since there are peripherals on-board using these pins. It is strongly recommended to use these pins as I2C pins instead of GPIO. +* Pins 15 and 17 are connected to the UART terminal which is also used for flashing firmware. It is strongly recommended to use these pins for UART connections instead of GPIO. +* Pins 16 and 18 are connected to LEDs on the board. It is strongly recommended to use these pins as output pins. + +## Expansion +### Motor driver +Motor drivers are not pre-installed on the daughter board. In order to connect motors to the board, you will need to remove **R18** and solder the following parts on their labeled positions. + +You can solder the DRV8830 DGQR GND pad by flowing solder from the reverse side of the board. + + +| Additional parts substrate silk | Parts | Parameters | +---- | ---- | ---- +| U1 | IC | DRV8830DGQR | +| U2 | IC | DRV8830DGQR | +| L1 | Coil | 100uF / 2A | +| C1 | Capacitor | 1000pF | +| C2 | Capacitor | 1000pF | +| C13 | Capacitor | 100uF / 16V | +| C14 | Capacitor | 470uF / 16V | +| R10 | Resistor | 0.2Ω / 2W | +| R11 | Resistor | 0.2Ω / 2W | +| CN1 | Connector | JST-XH-02P | +| CN2 | Connector | JST-XH-02P | + +### Power / Grove Connector +The power supply connector uses a JST-XH-02P connector. The Grove connector uses standard 4P connector. + +### Battery Holder +The battery holder uses two AAA battery holders that can be purchased through Farnell/Element14 part number 1702632. + +-https://www.newark.com/keystone/2466/battery-holder-1aaa-through-hole/dp/16F1095 + +## Schematics / Diagrams +-CPU core board + -[Circuit Diagram] (https://github.com/line/lines-things-dev-board/blob/master/schematics/cpu_board/Outputs/schematic.pdf) + -[Artwork Diagram-Table] (https://github.com/line/lines-things-dev-board/blob/master/schematics/cpu_board/Outputs/pcb_top.pdf) + -[Artwork Diagram-Back] (https://github.com/line/lines-things-dev-board/blob/master/schematics/cpu_board/Outputs/pcb_bottom.pdf) +-Daughter board + -[Circuit Diagram] (https://github.com/line/lines-things-dev-board/blob/master/schematics/main_board/Outputs/schematic.pdf) + -[Artwork diagram-table] (https://github.com/line/lines-things-dev-board/blob/master/schematics/main_board/Outputs/pcb_top.pdf) + -[Artwork Diagram-Back] (https://github.com/line/lines-things-dev-board/blob/master/schematics/main_board/Outputs/pcb_bottom.pdf) + +### Ordering your own PCB +-[`/ cpu_board / Outputs /`] (/ cpu_board / Outputs /) +-[`/ main_board / Outputs /`] (/ main_board / Outputs /) + +Gerber data required for board production is stored here. Use bom_{cpu/daughter}_board.xls for the parts list required for installation. +The circuit diagram and board are designed by Altium Circuit Studio. If you want to make modifications to the design, you can open it from Circuit Studio. +https://www.altium.com/circuitstudio/ \ No newline at end of file diff --git a/docs-en/default-firmware.md b/docs-en/default-firmware.md new file mode 100644 index 0000000..a56e09f --- /dev/null +++ b/docs-en/default-firmware.md @@ -0,0 +1,99 @@ +# Default Firmware + +## GATT Service Specifications + +This section describes the specifications of GATT service characteristic implemented in default firmware. The details here are not necessary when using the [JavaScript Library](js-control.md) but is crucial for extending or controlling the device from other sources than LIFF. + +### Details of Characteristics +All Characteristics except PSDI are implemented in the following service: + +- `DEVBOARD_SERVICE_UUID` + - `f2b742dc-35e3-4e55-9def-0ce4a209c552` + +The Characteristics and their UUIDs within this service are described below. + +|Description | Characteristic Name | UUID | Properties | Size (Fixed Length) | +----|----|----|----|---- +| 1 | WRITE_BOARD_STATE_CHARACTERISTIC_UUID | 4f2596d7-b3d6-4102-85a2-947b80ab4c6f | Write | 20Byte | +| 2 | VERSION_CHARACTERISTIC_UUID | be25a3fe-92cd-41af-aeee-0a9097570815 | Read | 1Byte | +| 3 | NOTIFY_SW_CHARACTERISTIC_UUID | a11bd5c0-e7da-4015-869b-d5c0087d3cc4 | Notify | 2Byte | +| 4 | NOTIFY_TEMP_CHARACTERISTIC_UUID | fe9b11a8-5f98-40d6-ae82-bea94816277f | Notify | 2Byte | +| 5 | COMMAND_WRITE_CHARACTERISTIC_UUID | 5136e866-d081-47d3-aabc-a2c9518bacd4 | Write | 18Byte | +| 6 | COMMAND_RESPONSE_CHARACTERISTIC_UUID | 1737f2f4-c3d3-453b-a1a6-9efe69cc944f | Read + Notify | 4Byte | + +1. This is used for reqriting the Service UUID in the JavaScript library. +2. This is the firmware version of the Dev Board. If undefined, the version will be defaulted to 1. +3. When subscribed, this will notify the switch state upon change. +4. When subscribed, this will notify the current temperature at regular intervals. +5. This is used to write commands to the device, such as device settings and notify settings. +6. If a command has a response, the response will be sent/can be read from this characteristic. + +### WRITE_BOARD_STATE_CHARACTERISTIC_UUID (Rewriting the Service UUID) +`Write device` allows values to be written to the board as shown in `/liff-app/linethings-dev-default`. However, this characteristic is exclusively used for rewriting the Service UUID. + +Protocol + +| |Command (1Byte) | reserved (2Byte) | hash (1Byte) | payload (16Byte) | Description | +----|----|----|----|----|---- +| Write device | 0 | {0, 0} | 0 | see code | Implemented in Version 1 onwards, this is used for setting up devices and GPIO.| +| Write Service UUID | 1 | {0, 0} | hash of uuid | uuid | UUID payload omits "-"| + +### VERSION_CHARACTERISTIC_UUID (Reading Firmware Version) +This characteristic is for reading the firmware version. Firmware version 1 does not have this characteristic implemented. Therefore, if this characteristic has an error in LIFF, you can safely assume you are using firmware version 1. All other functions will continue to work other than Rewriting the Service UUID implemented in version 2 onwards. + +### NOTIFY_SW_CHARACTERISTIC_UUID (SW Notify) +This sends notifications when the switch is pressed. The switch notification is set at `DEFAULT_CHARACTERISTIC_IO_WRITE_UUID` by default. +Other default settings are as follows. +- Source is from SW1 and SW2 +- Mode is `CHANGE` +- Interval is set at 50ms + +Protocol + +|value[1]|value[0]| +----|---- +|address(1:SW1, 2:SW2)|SW value| + +### NOTIFY_TEMP_CHARACTERISTIC_UUID (Temperature Notify) +`DEFAULT_CHARACTERISTIC_IO_WRITE_UUID` is the default characteristic set to used for temperature notification. If subscribed, the temperature data of 16 bytes will be sent 100 times, once every 10 seconds by default. +Initial setting: source = 1, interval = 10000ms + +### COMMAND_WRITE_CHARACTERISTIC_UUID (Device Usage) +This is used to configure various settings for the peripherals on board. + +Protocol + +| |Command (1Byte) | Payload (17Byte) | Description | +----|----|----|---- +| Control display | 0 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, address_x, address_y} | Specify the index address for Write Text | | +| Write text | 1 | {length of text, (text max 16Byte)} | Writes any text | +| Clear display| 2| N/A | Clears the Display| | +| Write LED | 3 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port, value} | | +| Buzzer | 4 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, value(0:OFF / 1:ON)} | | +| GPIO Direction | 5 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port, direction(0:Input / 1:Output)} | | +| GPIO Digital Write | 6 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port, value} | | +| GPIO Analog Write | 7 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port, value} | | +| I2C Start transmission | 8 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, address} | | +| I2C Write data | 9 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, data} | | +| I2C Stop transmission | 10 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | | +| I2C Request from | 11 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, address} | | +| I2C Read request | 12 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | | +| Set digital GPIO port for read | 13 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port} | | +| Set analog GPIO port for read | 14 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, port} | | +| Set display font size| 15 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, fontsize(1~3)} | | +| Write LED Byte | 16 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, value} | | +| SW Notify config | 17 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, source(0:Disable / 1:SW1, 2:SW2, 3:SW1 & SW2), mode(0:LOW / 1:CHANGE / 2:RISING / 3:FALLING), interval[1], interval[0]} | | +| Temperature Notify config | 18 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, source(0:Disable / 1:Temperature), interval[1], interval[0]} | | +| Read value request | 32 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, source(0:SW / 1:Accel / 2:Temp / 3:DIgital GPIO / 4:Analog GPIO / 5:I2C)} | | + +### COMMAND_RESPONSE_CHARACTERISTIC_UUID (Read via LINE) +`COMMAND_WRITE_CHARACTERISTIC_UUID` is the characteristic to read data and states of peripherals and GPIO. The data received will depend on the peripheral requested. + +|Source|Value format| +----|---- +|Switch|{0, 0, SW2, SW1}| +|Accel| {0, X, Y, Z} | +|Temperature|温度が100倍された値 | +|GPIO Digital| {0, 0, 0, value} | +|GPIO Analog| {0, 0, 0, value}| +|I2C| {0, 0, (0:invalid / 1:valid), value} | \ No newline at end of file diff --git a/docs-en/examples.md b/docs-en/examples.md new file mode 100644 index 0000000..dfe266c --- /dev/null +++ b/docs-en/examples.md @@ -0,0 +1,302 @@ +# Sample code for Arduino + +These are sample codes for the each peripheral on LINE Things developement board. Please refer to [Flashing Firmware](update-firmware.md) for [Flashing the Firmware](update-firmware.md). + +## LED Example +```cpp +/** +* LED Example +* Lights DS2 ~ DS5 will light up following one another every 0.5s. Afer all lights are lit, they will all turn off after 0.5s. The process will repoeat indefinitely. +*/ + +const int LED_DS2 = 7; +const int LED_DS3 = 11; +const int LED_DS4 = 19; +const int LED_DS5 = 17; + +void setup() { + // We set each LED pin to OUTPUT + pinMode(LED_DS2, OUTPUT); + pinMode(LED_DS3, OUTPUT); + pinMode(LED_DS4, OUTPUT); + pinMode(LED_DS5, OUTPUT); +} + +void loop() { + // We light up each LED every 500ms + digitalWrite(LED_DS2, HIGH); // LED_DS2 is turned on + delay(500); // 500ms wait + digitalWrite(LED_DS3, HIGH); + delay(500); + digitalWrite(LED_DS4, HIGH); + delay(500); + digitalWrite(LED_DS5, HIGH); + delay(500); + // Turning off LED_DS2~5 + digitalWrite(LED_DS2, LOW); // LED_DS2 is turned off + digitalWrite(LED_DS3, LOW); + digitalWrite(LED_DS4, LOW); + digitalWrite(LED_DS5, LOW); + delay(500); +} +``` + + +## Tactile Switch Example +```cpp +/** +* Tactile Switch Example +* LED LED_DS2 is lit when SW1 is pressed +*/ + +const int LED_DS2 = 7; +const int SW1 = 29; + +void setup() { + // We set the switch to INPUT with internal pull-up + pinMode(SW1, INPUT_PULLUP); + // We set the LED pin to OUTPUT + pinMode(LED_DS2, OUTPUT); +} + +void loop() { + // LED LED_DS2 is lit when SW1 is pressed + digitalWrite(LED_DS2, !digitalRead(SW1)); +} +``` + +## Buzzer Example +```cpp +/** + * Buzzer Example + * The buzzer will ring every 0.5s + */ + +const int BUZZER_PIN = 27; +SoftwareTimer buzzer; + +// Generate a signal with a 1KHz cycle +void buzzerEvent(TimerHandle_t xTimerID) { + digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN)); +} + +void buzzerStart() { + pinMode(BUZZER_PIN, OUTPUT); + buzzer.begin(1, buzzerEvent); + buzzer.start(); +} + +void buzzerStop() { + buzzer.stop(); + digitalWrite(BUZZER_PIN, 0); +} + +void setup() { +} + +void loop() { + buzzerStart(); + delay(500); + buzzerStop(); + delay(500); +} +``` + +## OLED Example +```cpp +/** +* OLED Example +* Make sure to install the `Adafruit SSD1306 Library` and `Adafruit GFX Library` +*/ + +#include +#include +#include + +// Creating an instance of the display +Adafruit_SSD1306 display(128, 64, &Wire, -1); + +void setup() { + // Initialization of the display + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Generate the voltage for the display as well as identify the address + display.clearDisplay(); // Clear the memory buffer of the display + display.display(); // Display the buffer +} + +void loop() { + // Display Text + display.setTextSize(1); // Setting Text size to 1 + display.setTextColor(WHITE); // Color White + display.setCursor(0,10); // X=0, Y=10 + display.println("LINE Things"); + display.println("Starter Board"); + display.display(); // Display the buffer + delay(1000); + // Drawing a line + display.drawLine(0, 32, 128, 32, WHITE); + display.display(); + delay(1000); + // Drawing a rectangle + display.fillRect(20, 40, 20, 20, WHITE); + display.display(); + delay(1000); + // Drawing a circle + display.fillCircle(100, 50, 10, WHITE); + display.display(); + delay(1000); + // clearing the display + display.clearDisplay(); // Clear the memory buffer + display.display(); // Display the buffer + delay(100); +} +``` + +## Temperature Sensor Example +```cpp +/** +* Temperature Sensor Example +* This example takes advantage of the OLED to display the temperature reading. +* Make sure to have the included library `library/things_temp_lib.zip` installed in your library directory +* Make sure to install the `Adafruit SSD1306 Library` and `Adafruit GFX Library` +*/ + +#include +#include +#include +#include + +// Creating an instance of the display +Adafruit_SSD1306 display(128, 64, &Wire, -1); + +ThingsTemp temp = ThingsTemp(); + +void setup() { + // Initialization of the display + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Generate the voltage for the display as well as identify the address + display.clearDisplay(); // Clear the memory buffer of the display + display.display(); // Display the buffer + + // Initialize the temperature sensor + temp.init(); +} + +void loop() { + // Get the temperature reading + float data = temp.read(); + // Displaying the temperature + display.clearDisplay(); // Clear the memory buffer + display.setTextSize(1); // Set Text Size to 1 + display.setTextColor(WHITE); // Color White + display.setCursor(0,10); // X=0, Y=10 + display.println("LINE Things"); + display.println("Starter Board"); + display.print("Temperature:"); + display.print(data); + display.println("C"); + display.display(); // Display the buffer + delay(1000); +} +``` + +## Accelerometer Example +```cpp +/** +* Accelerometer Example +* This example takes advantage of the OLED to display the accelerometer reading. +* Make sure to install the `SparkFun MMA8452Q Accelerometer Library` +* Make sure to install the `Adafruit SSD1306 Library` and `Adafruit GFX Library` +*/ + +#include +#include +#include +#include + +// Creating an instance of the display +Adafruit_SSD1306 display(128, 64, &Wire, -1); +// Creating an instance of the accelerometer at address 0x1c +MMA8452Q accel(0x1c); + +void setup() { + // Initialization of the display + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Generate the voltage for the display as well as identify the address + display.clearDisplay(); // Clear the memory buffer of the display + display.display(); // Display the buffer + + // Initializing the accelerometer + accel.init(SCALE_2G); +} + +void loop() { + // Get value from accelerometer + if (accel.available()) { + accel.read(); + } + + // Displaying the values + display.clearDisplay(); // Clear the memory buffer + display.setTextSize(1); // Set Text Size to 1 + display.setTextColor(WHITE); // Color White + display.setCursor(0,10); // X=0, Y=10 + display.println("LINE Things"); + display.println("Starter Board"); + display.print("X:"); + display.println(accel.cx); + display.print("Y:"); + display.println(accel.cy); + display.print("Z:"); + display.println(accel.cz); + display.display(); // Display the Buffer + delay(300); +} +``` + +## Motor Example +```cpp +/** + * Motor Example + * This exmample will control 2 motors + * Please install the included library/things_motor_lib.zip library + */ + +#include + +ThingsMotor motor_cn1 = ThingsMotor(MOTOR_ADDR_CN1); +ThingsMotor motor_cn2 = ThingsMotor(MOTOR_ADDR_CN2); + +int i = 0; + +void setup() { + motor_cn1.init(); + motor_cn2.init(); +} + +void loop() { + motor_cn1.control(MOTOR_BACK, i); + motor_cn2.control(MOTOR_FORWARD, i); + delay(100); + i++; + if (i >= 100) { + i = 0; + } +} +``` + +## Sample Sketches with peripherals not on the daughter board + +### Addressable RGB LED - NeoPixel +![neopixel](https://user-images.githubusercontent.com/135050/58088640-12de9f00-7bfe-11e9-8a8e-6c73594a59f3.jpg) + +This example lights up addressable LEDs (WS2812B), also known as NeoPixels. The brightness of the LEDs will progressively get brighter, 0-100%. You can change the colors of the LEDs bu pressing **SW1** on the daughter board. GPIO 1 (or IO2 on the CPU core) is connected to the **Data IN** port of the NeoPixel, GPIO 3 (3.3V) is connected to **VCC**, and GPIO 20 (GND) is connected to **GND**. Although the NeoPixels are made to work at 5V, it has been tested and proven to work at 3.3V. + +The sketch is available at `arduino/linethings-dev-neopixel/linethings-dev-neopixel.ino`. +You will need to change the number of pixels on your strip at `NEOPIXEL_PIXELS`. The default length is 16 LEDs. + +Adafruit provides a hand library called **Adafruit_NeoPixel**. Search for `adafruit neopixel` in the library manager and install `Adafruit Neopixel by Adafruit` to use the NeoPixels. + +### RC car +This will allow you to make an RC Car with the development board to be controlled via LINE. +Using the sketch `arduino/linethings-dev-car/linethings-dev-car.ino` and the LIFF application `liff-app/linethings-dev-car/` you can make your very own LINE controlled remote car. +#### Precautions +* Batteries as a power source will not work for this sample, please resort to using an external power source. +* USB Power from PC or handheld devices may provide unstable power due to the high power consumption of the motors. \ No newline at end of file diff --git a/docs-en/js-control.md b/docs-en/js-control.md new file mode 100644 index 0000000..72de715 --- /dev/null +++ b/docs-en/js-control.md @@ -0,0 +1,167 @@ +# Controlling LINE Things Development Board through JavaScript + +The GATT Characteristic in LINE Things development board allows easy control of the hardware and GPIO available on board. + +By utilizing the Javascript library provided, you will be able to configure and set the behavior of the device purely through LIFF without the need to modify the firmware. For example, you can set the interval to which a sensor's data is sent, which cannt then be used either through LIFF or through Automatic Communication. + +Please note that if the the display is controlled through this characteristic, the display will not update. To update the contents, you will need to power cycle the board or press RESET. + +All of the functions explained here is available in the example `liff-app/linethings-dev-js-control`. You can use this to test out the functions before writing your own LIFF app. + +Further examples are available at `liff-app/examples-js-control`. + +## Before We Begin +To use this function, you will need the LINE Things Development Board firmware to be at version 2 or higher. If you get an alert in the LIFF app, please update your firmware. + +See [Flashing the firmware](https://github.com/line/line-things-dev-board#updating_firmware). + +## Using LIFF +The JavaScript Classes used are implemented in `things-dev-board.js`. Please make sure to require `things-dev-board.js` on your html file. +When using LIFF BLE plugin, after calling `requestDevice()`, make sure to call `connect()` on the callback return object. + +To use these examples, you would need to host the pages online (such as GitHub Pages) and define their endpoints in the [Developers Console](https://developers.line.biz). + +|File Name|Contents| +|----|----| +|default|Basic control of all peripherals and GPIO| +|display|OLED Example for controlling the OLED display through LIFF| +|led-blink|Controlling the LED similar to Arduino's setup() and loop()| +|notify|An example to periodically notify the user of the temperature and button presses.| + +*Note* The led-blink example uses a loop in its code to replicate the behavior in Arduino. However this is poor practice since it will consume a lot of power. Please refer to this example only as a demonstration rather than guidance. A proper LED blink should be written to be event-driven to conserver power. + +## JavaScript Library + +### Rewriting the Service UUID +Insert the UUID you would like to set in `writeAdvertUuid(uuid)` as a string. Please note that the changes will not be applied until the next power cycle or device RESET. The LIFF application will then need to be restarted as well to reconnect to the device. + +This is only available in firmware version 1. + +Once set, the UUID will be stored in the Flash memory of the device. The stored UUID will be used in every subsequent power cycle. To reset the UUID to the default value, hold SW1 and press RESET. + +### Reading Firmware Version +Call `deviceVersionRead()` then `versionRead()` to get the current firmware version on the device. Since firmware version 1 does not have a version read characteristic, the non-existent value of the non-existent characteristic is defaulted to 1. + +The following features are available on firmware version 2 onwards. + +### Display Control +Please note that the display is controlled through this characteristic and the display will not update. To display the changes you've made, you will need to power cycle the board or press RESET. + +#### Clearing the Display +`displayClear()` +This is used to clear the memory buffer of the display. + +#### Moving the text write cursor +`displayControl(addr_x, addr_y)` +Specifies the position to begin writing text. The range of both X and Y are 0~63. + +#### Changing the font size +`displayFontSize(size)` +Specifies the font size. This can be set as 1, 2, or 3. + +#### Writing Text +`displayWrite(text)` +This is used to write text (up to 16 characters) as a string. To remove the text, you will need to execute backspaces multiple times. + +### LED Control +#### Individual LED Control +`ledWrite(port, value)` +Port determines the GPIO the LED is on. The board has LEDs on ports 2~5 in which are labeled as DS2~5 respectively. The values can be either 0 for OFF and 1 for ON. + +#### Overall LED control +`ledWriteByte(value)` +Control all LEDs at once. + +### Buzzer Control +`buzzerControl(value)` +To turn the buzzer on, set the value to 1. + +### GPIO Digital Control +#### Input/Output Setting +`gpioPinMode(port, value)` +Specify the GPIO you want to set on port. Use 0 in value to set it as an INPUT and 1 to set it as an OUTPUT. + +#### OUTPUT +`gpioDigitalWrite(port, value)` +Select the GPIO you want to control in port. To turn it OFF, set value to 0, to turn it on, set value to 1. + +### Analog Output +`gpioAnalogWrite(port, value)` +Select the GPIO you want to control in port. Value can be set from 0~255. + +### I2C +`i2cStartTransmission(address)` +`i2cWrite(value)` +`i2cStopTransmission()` +`i2cRequestFrom(address, length)` +`i2cReadRequest(device)` + +These are designed to work similar to Arduino's I2C. `i2cReadRequest(device)` is used to read data from an I2C device and storing it into a buffer on the dev board. The data can then be read via LIFF through `readReq(cmd)` and `deviceRead()`. + +### Reading Data from the Device +To read data from the device, you will first need to store the data into the device's buffer. Specify the port of the target peripheral by peripheral type, and the port number to read. Note that you will not need to specify these for switches, accelerometer, and temperature sensor since `readReq(cmd)` provides the read methods already. + +`i2cReadRequest(device)` +`gpioDigitalReadReq(port)` +`gpioAnalogReadReq(port)` + +To read data and store it into buffer call `readReq(cmd)` + + +|cmd value|Data type| +----|---- +|0|Switch| +|1|Accelerometer| +|2|Temperature| +|3|Digital GPIO value| +|4|Analog GPIO value| +|5|I2C Data| + +Finally, call `deviceRead()` to read the data stored in the buffer. + +### Notification +#### Switch +`swNotifyEnable(source, mode, interval, callback)` +Enables switch state notification based on the mode set. +`swNotifyDisable()` +Disables switch notification +##### Source + +|Value|Source| +----|---- +|0|disable| +|1|SW1| +|2|SW2| +|3|SW1 or SW2| + +##### Mode + +|Value|State| +----|---- +|0|LOW| +|1|CHANGE| +|2|RISING| +|3|FALLING| + +##### Interval +Specifies the time in milliseconds before the next interrupt is allowed to be made. This can be use a button debounce. + +##### Callback +Let's you set a method to be executed when a notification is triggered. + +#### Temperature +`tempNotifyEnable(interval, callback)` +Enables notification of the temperature reading regularly. +`tempNotifyDisable()` +Disables the temperature notification. +Please note that `i2cStartTransmission(address)` is called when the notification is enabled and will not stop until `i2cStopTransmission()` is explicitly called. + +##### Source + +|Value|State| +----|---- +|0|disable| +|1|enable| + +##### callback +Let's you set a method to be executed when a notification is triggered. diff --git a/docs-en/trouble-shooting.md b/docs-en/trouble-shooting.md new file mode 100644 index 0000000..de07bcf --- /dev/null +++ b/docs-en/trouble-shooting.md @@ -0,0 +1,33 @@ +# Troubleshooting +## I am unable to detect the device / I cannot connect to the device +The cache of smartphone may store incorrect or corrupt data. Normally toggling Bluetooth off and on from the settings menu should resolve the issue, however, a restart may be required. + +## I am unable to connect/program through Arduino. I am getting errors in Arduino +In Arduino IDE, go to `Tools -> Board` and make sure `Adafruit Bluefruit nRF52832 Feather` is selected. If you do not have this option available, please refer to the Flashing Firmware documentation. +If you continue to get errors, make sure that under `Tools -> Port` the correct port is selected for your device. + +If errors still occur, there may be issues with your bootloader or SoftDevice, such as inconsistent versions or incompatible versions. To fix this refer to Adafruit's Documentation, [Arduino Core for Adafruit Bluefruit nRF52 Boards - Bootloader Support](https://github.com/adafruit/Adafruit_nRF52_Arduino/#bootloader-support). + +## POWER LED(*DS1*) does not light up +Ensure that the jumper (*J4*) is set according to the power source preferred. Double check the polarity of your power source and orientation of the batteries to make sure no connections are reversed. + +## The motor isn't moving +Originally, the development board does ont come with the necessary parts to drive motors. You will need to install those parts yourself, see [Motor driver](#Motor_driver) for more details. If the parts are already installed, ensure that all connections are properly made between all components. + +Please bear in mind that the battery power source is not enough to drive the motors. An external power source is highly recommended. + +## Motor moves but seems unstable +The GND pad on the under side of the DRV8830DGQR IC may not be soldered. Make sure to solder it via the through-hole connection from the bottom side of the dev board. + +## Something was originally working then stopped working while programming/debugging +If you are using I2C devices (the OLED display, temperature sensor, accelerometer on the board), their communications may have been deadlocked. Resetting the development board will not resolve the issue, so you will need to power cycle the board. + +## Arduino cannot compile the sample files +In Arduino, go to `Tools -> Board` and open **Boards Manager**. Search for "nRF52" and find **Adafruit nRF52 by Adafruit**. Make sure that the version installed is **0.10.1** or higher. + +## I've set a new UUID but the advertised UUID remains unchanged +The default sample firmware stores the UUID in Flash memory. In order to make changes to the UUID, the UUID changes must be applied after the device boots up the firmware and override the preloaded UUID value. + +See [Reverting Service UUID to Stock](#service-uuid-reset) + +Once the new UUID has been set, on the smartphone side, you will need to unpair with the device in the Bluetooth settings as well as unlink the product from LINE Things Device Link screen. This should allow you to connect to the device with its new UUID. If there are still issues, repeat the steps above, then kill the LINE application and toggle the Bluetooth off and on from your device settings. A restart may be required. diff --git a/docs-en/update-firmware.md b/docs-en/update-firmware.md new file mode 100644 index 0000000..21a085a --- /dev/null +++ b/docs-en/update-firmware.md @@ -0,0 +1,77 @@ +# Flashing the Firmware +The method below shows how to flash the firmware using Arduino IDE + +## Arduino Environment Preparation +After installing Arduino IDE, proceeed with the following steps. Please have the board **disconnected** during this process. + +1. Open Arduino IDE +2. Open Preferences +3. Add `https://www.adafruit.com/package_adafruit_index.json` at 'Additional Board Manager URL' +4. Go to **Tools -> Board** and select **Boards Manager** +5. Search for "nRF52" and install **Adafruit nRF52 by Adafruit** (version 0.10.1 or higher) (*Note: If you are using Linux, additional configuration is required, see [Linux Setup](https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/arduino-bsp-setup)*) +6. Install [CP2102N driver](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers) + +## Setting Up the Hardware +### Using CPU core with the daughter board + +1. Ensure that the CPU core is proper installed onto the daughter board. +2. Connect the board to your PC using a Micro-USB cable connected to J1. +3. Go to **Tools -> Board** and select **Adafruit Bluefruit Feather nRF52832**. +4. Go to **Tools -> Board** and make sure the correct port is selected *ie. COM1, /dev/cu.SLAB_USBtoUART*. +5. To test the environment, click upload to upload an empty sketch onto the device. There should be no errors. + +### Using the CPU core as a stand-alone via daughter board' Serial IC + +1. Connect pins *RxD*/*TxD*/*Reset*/*VCC*/*GND* from the CPU core to the daughter board as shown below. For pin assignments, refer to the CPU core pin assignment. +2. Connect the daughter board to a PC using a Micro-USB cable connected to J1. +3. Go to **Tools -> Board** and select **Adafruit Bluefruit Feather nRF52832**. +4. Go to **Tools -> Board** and make sure the correct port is selected *ie. COM1, /dev/cu.SLAB_USBtoUART*. +5. To test the environment, click upload to upload an empty sketch onto the device. There should be no errors. + +![motherboard_external](https://user-images.githubusercontent.com/135050/58088646-14a86280-7bfe-11e9-974d-d4925148f3ae.jpg) + +### Using the CPU core as a stand-alone via external Serial ICs (not recommended) +Any Serial IC with USB-TTL conversion that can output DTR as well (such as the CP2102 mounted on the daughter board) can be used. In addition to the adapter, a 0.1uF capacitor is required. + +1. Connect pins *RxD*/*TxD*/*Reset*/*VCC*/*GND* from the CPU core to the Serial adapter as shown below. **Ensure the capacitor is connected between the Reset pin and the DTR pin** +2. Connect the Serial adapter to a PC using a Micro-USB cable connected to J1. +3. Go to **Tools -> Board** and select **Adafruit Bluefruit Feather nRF52832**. +4. Go to **Tools -> Board** and make sure the correct port is selected *ie. COM1, /dev/cu.SLAB_USBtoUART*. +5. To test the environment, click upload to upload an empty sketch onto the device. There should be no errors. + + +| USB-TTL IC | CPU Core | Important Remarks | +----|----|---- +| VDD(3.3V) | P28 | | +| GND | P1 | | +| DTR | P27 | 間に0.1uFのコンデンサを挟んでください | +| RxD | P6 | | +| TxD | P8 | | + +![cpuboard_prog_external](https://user-images.githubusercontent.com/135050/58088653-18d48000-7bfe-11e9-9b5a-f9637b23e590.jpg) + +## Advanced Users +### Using a J-LINK +By using a J-LINK, you are able to perform advanced development of the device without Arduino IDE. Connect the debugger to the CPU core as show in the picture below. Please note that using a J-LINK debugger will overwrite the original bootloader, thus making the board no longer compatible with Arduino IDE. Modifications to the CPU core on a lower level can invalidate any design certification placed on the device. Please proceed at your own risk if you are aware of what you are doing. Should you need to restore the CPU core back to its initial state (compatible with Arduino IDE), see [Using Adafruit's Bootloader](#Using-Adafruit;s-Bootloader). + +#### Wiring Diagram +![cpuboard_jlink](https://user-images.githubusercontent.com/135050/58088636-1114db80-7bfe-11e9-8a03-2222d94d49c5.png) + +| Connect Pin Number | Pin Name | +----|----| +| 1 | SWDIO | +| 2 | GND | +| 3 | SWDCLK | +| 4 | VCC | + + +### Using Adafruit's Bootloader +Should you need to revert your board back to the original bootloader, you will need a J-LINK debugger to burn the bootloader to the board. + +Please follow Adafruit's guide [Arduino Core for Adafruit Bluefruit nRF52 Boards - Burning new Bootloader](https://github.com/adafruit/Adafruit_nRF52_Arduino/#burning-new-bootloader) to burn the bootloader. + +※ Do **NOT** do this, if your board is already working with Arduino IDE. If you would like to update the bootloader, see [Updating the BootLoader](#Updating-the-BootLoader) + +### Updating the BootLoader +Adafruit has a comprehensive guide to performing a bootloader update at +[Updating the Bootloader](https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/updating-the-bootloader). \ No newline at end of file