Useful coding references for nRF52840 microcontrollers
signed char, int8_t
unsigned char, uint8_t
signed short, int16_t
signed int, int32_t
unsigned int, uint32_t
signed long, int64_t
unsigned long, uint64_t
Useful Basic Function
nrf_delay_ms(500); //delay in msec
bsp_board_init(BSP_INIT_LEDS); //initialising LED
bsp_board_led_invert(0); //toggle LED
nrf_gpio_pin_set(LED_1); or bsp_board_led_on(0);
nrf_gpio_pin_clear(LED_1); or bsp_board_led_off(0);
LED_1 = NRF_GPIO_PIN_MAP(0,13)
All the function is written in a manner that is portable and general purpose coding. This may make it very difficult to read and understand. But basically, it works like PIC microcontroller where each pin or peripheral can be individually configure.
The entry point to the program is at “main.h” -> “int main(void)”.
Hardware specific “fixed” configuration are all done in “pca10056.h“. All pins input/output definition are configured in this file which is very specific to this designed pca10056 circuit board.
“boards.c” contains generic codes for managing the LED and Push Buttons codes.
Project (Solution) specific codes will be under the Application folder. Usually consist of “main.c” where the code starts, and “sdk_config.h” where are the configuration of the application will be.
Function that starts with sd_XXXXXX(), these are the basic functions provided directly from softdevice API module.
Function that starts with nrf_XXXXXX(), these are functions by nRF encapsulation softdevice API sd_XXXXXX().
Data type naming convention ends with XXXXXX_t
sec - security
conn - connection
lbs - led button service
ble - Bluetooth low energy
auth - authorised
evt - event
adv - advertisement
lesc - LE security
len - length
gattc_evt- GATT client event
gatts_evt- GATT server event
Pin maps for the nRF52840-DK board examples demonstration
Pin out in the nRF52840 example demo
One of the more important BLE event function
This ble_evt_handler() is callback whenever the BLE events occurs. The lower level will be called and propagated up to our application level through ble_evt_handler() where we will handle the BLE message.
For interrupt there are a total of 4 levels. Highest interrupt priority is taken by SoftDevice, the next level is by the application. Followed by a lower priority SoftDevice, then the lowest priority to the application.
/**@brief Function for handling BLE events.
* @param[in] p_ble_evt Bluetooth stack event.
* @param[in] p_context Unused.
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
The path of the incoming data event (BLE_GATTS_EVT_WRITE) start from ble_conn_params.c->ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context), then followed by ble-lbs.c->ble_lbs_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context) then main.c->ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
For the event object p_ble_evt, the data structure is very large. But not all data in the structure are valid. It depends on the event that had took place. Read only that section of the structure. nRF simply lump everything into this single data structure. In actual fact the data communication isn’t so large.
nRF Object Class Documentation
- LED Button Service modules
- GATT request queue module. Commands from application to SoftDevice are put to a queue system here
Close to SoftDevice Level
Low Level (Hardware)
boards.h, pca10056.h, bsp.h
- hardware board related. Board Support Package
nRF Singleton Object Instance
m_ represent singleton object.
- LED Button Service object for the Central device
- BLE scanning object
- GATT object
- DB Discovery object
- GATT queue object
p_ represent pointer to object
//Explore Variable p_ble_evt
// evt_id //type of Bluetooth events
// common_evt //common event
// gap_evt //GAP originated event
// auth_status //(ble_gap_evt_auth_status_t)
// auth_status //< Authentication status, see @ref BLE_GAP_SEC_STATUS.
// error_src //< Authentication status, see @ref BLE_GAP_SEC_STATUS.
// bonded //< Procedure resulted in a bond.
// lesc //*< Procedure resulted in a LE Secure Connection.
// sm1_levels //< Levels supported in Security Mode 1.
// sm2_levels //< Levels supported in Security Mode 2.
// kdist_own //< Bitmap stating which keys were exchanged (distributed) by the local device. If bonding with LE Secure Connections, the enc bit will be always set.
// kdist_peer //< Bitmap stating which keys were exchanged (distributed) by the remote device. If bonding with LE Secure Connections, the enc bit will never be set.
// gattc_evt //GATT client
// gatts_evt //GATT server
// l2cap_evt //L2CAP, Logical Link Control and Adaptation Layer Protocol
Naming convention used in nRF SDK BLE codes
....xxx_t => the "_t" defines the data object type.
scan_evt => scan event data to the main application
nrf_ble_scan => Bluetooth scanning parameters
ble_gap_evt_adv_report => Advertise Report object
ble_evt_t -> ble_gap_evt_t -> ble_gap_evt_adv_report_t
ble_gap_evt => GAP event
p_adv_report->data.p_data => Advertising data pointer
p_adv_report->data.len => Advertising data length
03 19 00 00 02 01 06 0E |........
09 4E 6F 72 64 69 63 5F | Nordic_
42 6C 69 6E 6B 79 |Blinky
Advertise data starts (length of 22 of the whole packet)
This advertise packet consist of 3x Advertising Data (AD) elements
First byte 03 indicates the length of the first element which is 03 19 00 00.
19 is the AD type «Appearance»
00 00 is the data for Appearance which is unknown
The next set of AD element is 02 01 06.
First byte 02 indicates the length.
01 is the AD type for «Flags»
06 is the data for flags.
It indicates that BR/EDR is Not supported, and LE General Discoverable Mode is true.
The next set of AD element is 0E 09 4E 6F 72 64 69 63 5F 42 6C 69 6E 6B 79
0E is the total number of data bytes which is 14.
The AD type is 09, which stands for «Complete Local Name».
The data 4E 6F 72 64 69 63 5F 42 6C 69 6E 6B 79 represent "Nordic_Blinky" which is the name of the device.
The AD type code can be found on this page,
Notes: Possible point of improving Bluetooth product.
Company Identity. Register for an unique company ID code, and implement into Bluetooth product. Display of Nordic ID 0x0059 as the company ID can be a security breach. https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/ https://www.bluetooth.com/develop-with-bluetooth/join/ https://www.bluetooth.com/develop-with-bluetooth/join/membership-benefits/ https://devzone.nordicsemi.com/f/nordic-q-a/7594/about-company-identifiers https://devzone.nordicsemi.com/f/nordic-q-a/2636/using-nordic-manufacturer-id-in-advertizing-data https://devzone.nordicsemi.com/f/nordic-q-a/24449/advertising-manufacturing-specific-data-without-company-id
There are 4 ways of loading your program onto Nordic chip.
Debug header (for use of programming of the full image of the chip memory *.hex). This can be done using nRF52840-DK or nRF9160-DK board as a J-LINK programmer, or using a J-LINK programmer like the j-link Base, j-link BASE Compact or J-Link EDU Mini Programmer.
USB Bootloader (USB Wired DFU, programming of the non-boot loader, application memory *.hex). This can be done using the onboard USB peripheral.
Bluetooth Firmware Loader (Wireless DFU, programming of the non-boot loader, application memory *.bin). This can be done when your chip is pre-flash with bootloader firmware and SoftDevice firmware.
USB Mass Storage (drag and drop *.hex file into the JLINK storage drive to automatically program the chip). This can be done through the nRF52840-DK or nRF9160-DK board.
An nRF52840-DK kit board to act as the programmer for the chip
This is the most fundamental method of loading in firmware into the Nordic nRF52840 chip.
Connect up the nRF52840-DK or nRF9160-DK kit. They are used as a programmer in this example. These boards contains a programmer chip that uses Jlink driver for connection as a programmer, to upload *.hex file into the nRF52840 or nRF9160 chips.
There is typically 3 *.hex module that you need to load into the chip’s memory. Namely,
Different chip has its own memory map where the *.hex file should be loaded to. Here is the memory map for nRF52832, nRF52840.
Go to the software “nRF Connect” and open the “Programmer” program.
You will come to the screenshot as follows.
Selecting Programmer Board
There is a drop-down list on the top. When you board is connected, there should be an option in the drop down list for you to choose from. Select the programmer shown in the list.
If there is no board listed even when you got your board connected to the computer. You may also see error message in red color at the log box below. Check out the last section to see if there is a solution to resolve your problem.
Load Bootloader *.hex file
Bootloader *.hex file is the part that allows you to use USB cable to directly load the program into the chip.
It enables the chip to be able to receive it firmware through wired USB.
Click on the “Add HEX file” on the right side. Choose the bootloader that you want to use.
On the memory map, you will see green (bootloader sectors in use) on the top and bottom of the memory map.
Load SoftDevice *.hex file
SoftDevice is a bluetooth stack codes that you can choose to load into the chip.
These 2 *.hex files are LED demonstration example which is found in the nRF5 SDK zip file that you downloaded eariler. Under the directory “examples\peripheral\blinky\hex\” & “examples\peripheral\led_softblink\hex\”. The source code can also be found in the project directory.
Please take note that there are project folder for different type of development board. One is for pca10040 development kit board, and the other is pca10056 development kit board. The one I have is PCA10056. You can take a look at the white sticker which is paste on top of your nRF52840-DK board to confirm which board you have. If you choose the wrong *.hex file, the example will not work. The files has a prefixed name “_pca10056.hex” at the back.
List of board types
2) Connect up your nRF52840 board with a micro USB cable.
You should be able to see a storage drive popping out from your computer. Inside this drive “JLINK”, you will see the following files inside.
3) Copy the “blinky_pca10056.hex” hex file into the root of the JLINK drive. This copy action will trigger a programming process of the hex file into the nRF52840 chip. After a short second, you should see the LED1 LED2 LED3 LED4 on the nRF52840 board started to lights on in sequence, followed by lights off in sequence.
4) Next, copy the “led_softblink_pca10056.hex” hex file into the root of the JLINK drive. After a second, you should see that the 4 LED now behaves differently. They will now fade out and fade on the lights. The old hex file can be remains in the drive. The programming action will only take place during the first time transferring of the *.hex file onto the JLINK drive.
That’s all for a simple demonstration of programming the nRF52840 chip that is on the nRF52840-DK development kit board. Simple just load in the hex file to nRF52840-DK board.
You have successfully programmed the nRF52840 chip.
Method 2 to program nRF52840 development kit via SEGGER Embedded Studio Software
2) Open source code projects. We will use the project “blinky_pca10056”
From the menu bar go to File -> Open Solution
Open solution is like open project in other development platform. Go to the nRF5 SDK directory and select the project file “examples\peripheral\blinky\pca10056\blank\ses\blinky_pca10056.emProject“.
Folder “ses\” for the project files using SEGGER Embedded Studio. Folder “armgcc\” is for the project files using GNU Arm Embedded Toolchain.
The project will be loaded.
In this project, you will see the file “main.c” where the blinky action codes is. Play around by modifying the code. This “main.c” file is share by other projects (defined by different board)
3) Program your new code to the nRF52840-DK board.
Ensure that you board is connect via the USB micro.
From the menu bar go to Build -> Build and Run (Ctrl+T or Ctrl+F5)
The SEGGER software will compile your code and load it to the nRF52840-DK board. It will take quite a couple of seconds to complete the up loading.
This completes your experience loading your codes using SEGGER Embedded Studio.
Play around with the other projects to get yourself familiar with the other peripherals on the chip nRF52840. Learning digital I/O pins and UART pins are the most important to help you get started in your microcontroller firmware programming. Once these two peripheral are mastered, understanding the rest will be much simpler.
Method 4 using nRF52840-DK as a programmer to program other boards
The nRF52840-DK can be used as a programmer to program other external board using the P19 Debug Header or the P20 Header Pins on the board. The DK board will detect the VTG pins for any board connected to it. If there is a connecting board, the nRF52840-DK will program the external board instead of the nRF52840 chip onboard the nRF52840-DK board.
Ensure that the text file “Makefile.posix” in the SDK directory F:\…..\nRF5 SDK\components\toolchain\gcc is configured to point to the correct compiler’s install directory and version.
I am using the nRF52840-DK board (PCA10056), so we go to the following blinky project folder. “…\nRF5 SDK\examples\peripheral\blinky\pca10056\blank\armgcc”
Inside the folder, it contains a “Makefile”. The make file contains the excuting of the program nrfjprog in sequence to load the compiled source code “*.hex” into the chip.
To flash the chip: (load *.hex into the chip)
//to program the nRF52 microcontroller chip with the hex file.
nrfjprog --family nrf52 --program $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex --sectorerase
//--> Please note that the microcontroller needs to be reset in order for the new firmware to run !!!
// flag --sectorerase //to erase the memory sector (before the programming) where the code is flash onto.
// flag --sectoranduicrerase //to erase the memory sector (before the programming) where the code is flash onto.
// flag --chiperase //to erase all the user memory (before the programming) including UICR.
//verify the loaded firmware
nrfjprog --family NRF52 --verify nrf52840_xxaa.hex
//to reset the microcontroller chip after the programming
nrfjprog --family nrf52 --reset
//Example of programming a blinky firmware (LED indicator blinking firmware example)
> nrfjprog -f nrf52 --program blinky_pca10056.hex --sectorerase
Parsing hex file.
Erasing page at address 0x0.
Applying system reset.
Checking that the area to write is not protected.
//Example of verifying the firmware code flash in
> nrfjprog --family NRF52 --verify blinky_pca10056.hex
Parsing hex file.
>>Example of flashing and verifying at one go
> nrfjprog --family nrf52 --program blinky_pca10056.hex --sectorerase --verify
Parsing hex file.
Erasing page at address 0x0.
Applying system reset.
Checking that the area to write is not protected.
>>Example of flashing and verifying at one go, including a reset at the end.
> nrfjprog --family nrf52 --program blinky_pca10056.hex --sectorerase --verify --reset
To erase the chip:
nrfjprog -f nrf52 --eraseall
To execute this command is chip is hang.:
nrfjprog -f UNKNOWN --eraseall
Tip#: Using Win10 file explorer, you can simply key in “cmd” in the directory text field, the command prompt will be loaded with the path at the current window’s directory that you are at. Very convenient feature.
In every project (solution), in the “Application” folder contains a file named “sdk_config.h” to allow you to configure some of the parameter of the project. To allow you to enable/disable software module in the project.
First you have to go to File->Open Studio Folder…->External Tools Configuration. You will need to paste some XML codes to enable the CMSIS tool. Save the XML file. Close the SEGGER IDE and restart again.
This time round, go to the project application folder to look for the “sdk_config.h” file. Right click it, you will now get to see there is a newly added option “CMSIS Configuration Wizard“
You can now use this to enable/disable your project configuration instead of editing on the precompiler code on the file “sdk_config.h”. Click on “save” after the changes. When a warning window pops up for file modified externally, click yes to have the changes updated onto the file.
When I was first handled with the task of building a Bluetooth and NB-IoT gateway, I was a bit overwhelmed by the messy and complex documentation on the manufacturer’s website. So I decide to do a write guide to start off a hello world example as I learn discover that Thingy 91 module is all about.
Start up hardware
Thingy 91 (from Nordic)
Thingy 91 is a prototyping kit which consist of the IC chip nRF9160 (for NB-IoT communication), and nRF52840 (Bluetooth Low Energy BLE 4.0, 5.0 communication). Simple battery powered electronic hardware to get engineer start up with working on nRF9160.
nRF9160-DK (from Nordic)
nRF9160-DK is similar to Thingy91, an development kit for learning nRF9160 IC chip. That why the it is named “-DK”. It consist of the same IC chip nRF9160 and nRF52840.
An additional big chip is found on this kit. This chip is there for the programming of the IC nRF9160 or nRF52840. A switch SW5 near this big chip is used for selecting the chip that you want to program. You can select nRF52 (for nRF52840 chip) or nRF91 (for nRF9160 chip).
Beside able to program the IC chip on its own board, this development kit can also act as a programmer to program nRF52xxx or nRF91xxx chips on other boards. You can use nRF9160 as a programmer device to program the chips (nRF52840 or nRF9160) on the Thingy91 board via the JTAG cable (10pins ribbon cable).
How to get started?
This was one big question on my head. I done many installations until I also don’t know what I was doing. Here I want to start off by learning how to program a “Hello World” firmware into nRF52840 chip first.
I decided not to rush into things and do things step by step from the basis fundamental first.
What do you need?
Development Kit nRF9160-DK
USB micro cable
A computer with a Windows Operating System
Ways to program Nordic nRF52840 chip
There are a number of ways to program the Nordic chip nRF52840.
Install the software nRF Connect on your desktop computer.
Open up this software nRF Connect.
Go to Getting Started Assistant, click <Install>
Open and execute the program Getting Started Assistant to guide you with the steps to take.
Summary from Getting Started Assistant
Install the toolchain
Clone the nRF Connect SDK
Download SEGGER Embedded Studio
Set up a project in SEGGER Embedded Studio
Install the toolchain
The whole installation experience is a pain. Please ensure there is no space in the name of your folders. It will not be recognized by the software tools.
Install toolchain Chocolatey. Chocolatey tool makes software installation on WinOS looks easy. It will be like typically how we do software installation on Linux OS system. Helps you to automate and create software deployment package for Windows. Learn about Chocolatey here. The subsequent steps, we will be doing installation and configuring of Chocolatey from WinOS command prompt.
Open a command prompt as an Administrator on your WinOS computer. Press on your keyboard Windows+X. Click on the pop-up menu “Command Prompt (Admin)” or “Windows PowerShell (Admin)”. A command prompt should pops up.
Paste the following command text into the PowerShell, >Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’)) This will download and install Chocalatey onto your computer system.
Enter the following command text into the PowerShell to check if Chocolatey is installed. >choco You should receive the following message when Chocolatey is properly installed. Chocolatey v0.10.15 Please run ‘choco -?’ or ‘choco -?’ for help menu.
Enter the following command texts, and click verify button on Getting Started Assistant. The Assistant should highlight green which indicates that the task is done properly. Do the same for the subsequent command. >choco feature enable -n allowGlobalConfirmation
Enter the following command texts, and click on verify button. >choco install -y cmake –installargs ‘ADD_CMAKE_TO_PATH=System’
Ensure that there is a bin folder under c:\gnuarmemb\bin. Use the Verify button to confirmed that you have done it correctly.
Please ignore the following test….. Open up “Command Prompt” and key in the following command to check if GNU toolchain is installed. >arm-none-eabi-gcc –version
Please ignore the following test….. Install onto “C:\gnuarmemb” directory. (recommended by nRF Connect) example: “C:\gnuarmemb\GNU Tools Arm Embedded\9 2019-q4-major“
Click verify on your Assistant when this is done.
Clone the nRF Connect SDK from Nordic Repository.
Nordic has developed SDK specially for their nRF chip products (only for nRF9160 or nRF5340). These source code are in Nordic repository. The following commands are to copy/update that source code onto our own local computer system.
Enter the following command texts in Windows PowerShell, and click on Verify button.
Install West (Zephyr’s meta-tool), a swiss-army knife command-line tool . Use pip3 to install west. >pip3 install west
Create your own directory to store nRF Connect SDK, and create a directory (no spaces in the directory name) ncs under it. example: e:\nRFConnectSDK\ncs\, >cd ‘e:\nRFConnectSDK’ >mkdir ncs >cd ncs
Initialise West meta-tool, and update it >west init -m https://github.com/NordicPlayground/fw-nrfconnect-nrf >west update
Visit the webpage nRF Connect SDK Release Notes to look for the version that you want to clone onto your computer system. Look for the Release Tag to use. In this example, I am looking at “nRF Connect SDK v1.2.0 Release Notes”. The Release Tag that I see from this release is “v1.2.0“. Use this tag for git checkout as shown below. This will fetch the release version v1.2.0 from the repository. >cd ‘e:\nRF Connect SDK\ncs\nrf’ >git checkout v1.2.0 >west update If you want the latest version (may not be a stable version from Nordic), use the command “git fetch origin” instead of “git checkout v1.2.0”. The command “west update” simply update the files to that version.
Install a list of required Python modules. >cd ‘f:\nRF Connect SDK\ncs’ >pip3 install -r zephyr\scripts\requirements.txt >pip3 install -r nrf\scripts\requirements.txt >pip3 install -r bootloader\mcuboot\scripts\requirements.txt
Use command prompt to navigate to the folder where SEGGER Embedded Studio is located. In this example, it is located at “e:\nRF Connect SDK\arm_segger_embedded_studio_v442a_win_x64_nordic\bin\”
Execute the file emStudio.exe to launch the software.
A pop up screen may appeared indicating “No commercial-use license detected”. Activate your free license.
Setup the path of the Zephyr Base (the location of your cloned Zephyr repository, path ncs/zephyr), and the path where GNU ARM Embedded Toolchain is installed.
In the software go to Tools > Options, and select the nRF Connect tab.
In our example, the path for
Zephyr Base, “e:\nRFConnectSDK\ncs\zephyr“
GNU ARM Embedded Toolchain, “c:\gnuarmemb“
You can now start opening your nRF Connect project. Select File > Open nRF Connect SDK Project.
Follow the setting of the screenshot on the right.
For the board name, remember to select the name ending with xxxxxxns. Which means Non-Secure version.
CMakeLists.txt (location of the project makelist. Typically located at ../ncs/nrf/samples/nrf9160/lte_ble_gateway/CMakeLists.txt)
Board Directory (location of the board used for the project. Typically located at ../ncs/zephyr/boards/arm/nrf9160_pca10090 )
Board Name (names for the board will be automatically generated when the board directory is selected). Always choose the board name with xxxxns at the end of the name. ns means Non-Secure.
Build Directory (the folder of where the output build will be located, will be automatically generated when the CMakeLists.txt is selected. The build… will be generated in the same directory of the CMakeLists.txt)
Check the box “Clean Build Directory” so that the outdated build is not cache.
Issue installing Chocolatey due to outdated software. TLS 1.2 at a minimum version. Error message “DownloadString” with “1” argument(s): “The request was aborted: Could not create SSL/TLS secure channel.” reference: https://chocolaty.org/docs/troubleshooting
When verifying “choco install -y cmake –installargs ‘ADD_CMAKE_TO_PATH=System'”, an error message occurred. Error message is ” ‘cmake’ is not recognized as an internal or external command, operable program or batch file.” Solution 1: is to download and install cmake software. https://cmake.org/install/ It is found that cmake is already installed, just that it needs some repair only. You may need to install and uninstall. Remember also that you may need to go to Tools > Options > nRF Connect > Executables > CMake Executable, to set the location of the newly installed cmake program. Solution 2: set environment path in the command prompt. $env:path += “;C:\Program Files\cmake\bin” After this, key in cmake in the command prompt. It should work.
SEGGER software keep asking me to activate license. Solution: Close Segger Embedded Studio and open any SES project from Nordic SDK. https://devzone.nordicsemi.com/f/nordic-q-a/43274/my-segger-license-is-never-activated Example of such a SDK project file is “nRF5_SDK_15.2.0_9412b96” Open a *.emProject files using the SEGGER program. The file can be found under the folders “examples\peripheral\blinky\pca10056\blank\ses” There will no longer be a license problem the next time you open the SEGGER.
What I learned is Zephyr is a OS is based on a small-footprint kernel designed for use on resource-constrainted systems.
Don’t give name to a directory that have space inside.
Error message while opening a nRF Connect SDK project. “warning: BSD_LIBRARY (defined at…….. has direct dependencies TRUSTED_EXECUTION_NONSECURE with value n, but is currently being y-selected by the following symbols: -MODEM_INFO (defined at…….” Solution: When choosing the board name, choose one with name ending with xxxxxxns. Reason: bsdlib can only be used from a non-secure application and you need bsdlib to use the modem. Reference: https://devzone.nordicsemi.com/f/nordic-q-a/57722/cmake-error–open-nrf-connect-sdk-project
Remember to put the switch to nRF9160 (instead of nRF52840) before the programming. You can switch and click on the “Read” button from the nRF Programmer software to check which chip the nRF9160-DK board is connected to.
The following tutorial is a good reference to show us how to update the modem firmware to the nRF9160 chip on the nRF9160-DK board.
They can be loaded via the nRF Cloud Programmer software.
For modem firmware, after going into the programmer software, go to the lower right side of the screen and load in the *.zip file (modem firmware). Remember to slide the switch on the Thingy91 to select for the nRF9160 chip.
For the thingy91_at_client firmware, in the programmer software load up the hex file. Then click “erase & write” to begin flashing. Remember to slide the switch on the Thingy91 to select for the nRF9160 chip.
For the thingy91_nrf52_usb_uart_bridge firmware, in the programmer software load up the hex file. Then click “erase & write” to begin flashing. Remember to slide the switch on the Thingy91 to select for the nRF52840 chip.
Playing with the nRF9160 modem
Everytime the board is plugged in, there will be 3 COM port that appears. 2x COM belongs to the nRF9160 chip, one maybe for the AT command, and the other maybe the logging messages from the modem module. 1x COM belongs to the nRF52840 chip.
Using the software LTE Link Monitor to initialise the modem and send AT command.
First connect the device, communication port by selecting the connected Thingy91 or nRF9160 device.
Some console text will starts to appear. If not, can also press the reset button on the hardware board. Key in the command “AT” to check if the board is responding to this AT command.
Key in “AT+CGMR” to check the modem firmware version.
Key on the modem command “AT+CGMR” to initalise and start the module. The indicator on the software Modem, UICC, LTE, PDN will all start to turn green.
This is an illustration of an installation done. There is no network point in this illustration as it is using a 3G modem for communication instead. The cables are pulled into the enclosure via the cable entry hole channel on the left side of the enclosure.
In a typical setup, the following 3 type of cables has to be laid.
Dual ganged power socket.
Network point socket.
Cables from machines to this payment terminal enclosure.
Enclosure Installation Height
The recommended installation height of the power/network socket point is about 1157mm. The enclosure will be installed after power/network sockets are installed. The enclosure will cover directly over the sockets and cable trunking.
The position of the sockets will be the center location of the enclosure. The installed position of the sockets will determine the position of of the payment terminal.
Install the sockets/enclosure at a comfortable and ergonomic high for your user.
The following information provides the internal layout of the casing.
Power Point & Network Point Installation
The payment system requires a minimum of 1x power point and 1x network point. A spare power point is recommended for future use.
Resources to Provision:
2x Power Point
1x Network Point
The following is the dimension of the enclosure covering the power point and network point. The opening from the enclosure is about 298 x 120mm. Space is tight. Please ensure that there is enough space for the enclosure to cover over the power/network points on the wall.
Please note that there are 3 pre-designed hole channel for cable entry. Two are located by the sides and one at the bottom of the enclosure. The hole channels are aligned to the ceter of the enclosure. It is recommended not to have the cable entry coming from the top of the enclosure, nor the trucking be laid across the top of the enclosure. This is for aesthetically pleasing reason. It will look nicer to select the cable entry channel location to a position that is not too visible. The best entry location will be from the bottom of the enclosure.
The standard width of the hole channel (max) is indicated on the layout above. The holes are design base on the commonly available cable trunking found on the market. Suitable for small and big cable trunking.
There may be situation where the 3 standard hole channel on the casing may not be big enough for the trunking deployed. If the trunking size is bigger than the standard hole channel on the casing, the hole channel will have to be manually enlarge to cater for the massive chunk of wiring.
Cables from Washer/Dryer machines to Payment Terminal
Cables are required from the machines to the payment terminal location. This is to allow the payment system to trigger the machine after the user successfully made their payment.
Cable range AWG20-25 (multi-strand) is recommended. CAT5 cables is easily available and is also fine to use.
Estimate about 1 cable per Washer/Dryer stack. It is recommended to lay a spare cable for every 2 stacks of machine. There are a lot of vibration from the machine, and it is possible that wire may break after long use. This is especially for Cat5 cables as they are only of a single strand. Therefore spare cables is recommended.
These cables will be laid all the way into the enclosure together with the power/network socket. There is no need to terminal these cables. Just leave it dangling with an extra length of about 500mm will.
Network Port Settings
The payment terminal communicates over the internet for all payment transaction. When using local network point that is protected by the organisation firewall, some of the port number needs to be open so that communication needed by the transaction can proceed.
Please contact us for further details of the exact network port to open.
Use Ping.exe program to test data route to ensure that the port is open on the network point.
Wiring & Connection
Wiring and connection for speed queen washing/dryer machine.
This procedure is for fast forwarding or skipping the washing machine operating procedure. This is needed to help clear the credit triggered on the machine.
A quick paragraph to summaries the procedure. Simply ensure that the bypass switch is activated (disconnected or open circuit), press and hold button 1 & 2 to enter into the maintenance mode “rAPd”. Press “Start” button until the whole process ends.
The detailed procedures and explanation is as follows,
When the machine is idling, the display panel shows “100” indicating the credit of $1.00 required to start the machine.
After the payment, the machine will response with a beep with number changed to 30 (representing 30min of washing) This indicate that the machine has accepted the payment.
Open the front panel with a physical key.
Disconnect the bypass switch. This bypass switch allow us to go into the maintenance mode. With the machine bypass activated, it will also not record any transaction or operation to this machine. If you can see a sensor switch which detect the panel open, this is also known as the bypass switch. The washer (left side), dryer machine (right side), each has their own by pass switch.
Press and hold button 1 & 2 (the left side buttons, top and button). It will go into maintenance mode with the panel displaying “rAPd“.
The front loading door has to be close in order for the machine to cycle through the wash cycle.
Press the green Start button to fast forward the whole washer process. This reduces the timing on the machine. You will see the number 30min reducing. Keep on pressing until the value becomes 1, then wait for a few second for the machine to react, and a final press will get the machine time to becomes 0.
Open the door to complete the whole process. The washing machine will reset back to machine idling state. This panel will display “100” again, and the machine status will become available for the next transaction to take place.
Do remember to restore back the bypass switch before leaving the place. Test to check that the machine cannot enter into the maintenance mode by press holding the button 1 & 2.
Price Settings on the Washing Machine
Open the door for 2 sec and close it back to go into the configuration mode.
Press and hold button 1 & 2.
You will enter into “rAPd” menu. It is a bypass operation.
Press button 3 & 4 (up/down button) to scroll through the menu.
Scroll to the menu item Prog. Then press button 5 to enter.
Scroll to the menu item AtS, then press enter.
Scroll to the menu item 0, then press enter.
Then the price setting will be displayed. Example for $1, it will be 0100.
Press button 3 & 4 to change the price.
Press enter to go to the next digit until the price is entered.
Then press button 2 (back key) to escape all the way to the operation mode.
Some of the more common problems
Network point is down
Machine is not triggered
Machine is not available for selection
Cannot connect to payment gateway
QR code can be found on the system which will lead you to this page. (future implementation)