---
title: "W55RP20 COAP Client example"
url: "https://maker.wiznet.io/Aimee0/projects/w55rp20-coap-client-example/"
markdown_url: "https://maker.wiznet.io/Aimee0/projects/w55rp20-coap-client-example/md"
type: "WCC: WIZnet Created Content"
author: "Aimee"
author_url: "https://maker.wiznet.io/Aimee0/"
original_author: "Aimee"
published: "2024-10-29"
language: "en"
hardware: ["WIZnet W55RP20"]
likes: 0
views: 711
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# W55RP20 COAP Client example

> This is an example of acting as an COAP client using W55RP20-EVB-Pico.

Original author: Aimee

## Components

- **WIZnet W55RP20** x 1 ([docs](https://wiznet.io/products/ionic-chips/w55rp20))

## Documents and links

- [W55RP20 coap client example](https://github.com/WIZnet-ioNIC/WIZnet-PICO-COAP_C/tree/main/examples/coap_client) (code)

## Article

github link : <https://github.com/WIZnet-ioNIC/WIZnet-PICO-COAP_C/tree/main/examples/coap_client>

### How to test COAP Client example

**Setup board configuration**

Setup board to W55RP20_EVB_PICO in CMakeLists.txt in WIZnet-PICO-COAP_C/ directory.

```plaintext
# Set board
#set(BOARD_NAME WIZnet_Ethernet_HAT)
#set(BOARD_NAME W5100S_EVB_PICO)
#set(BOARD_NAME W5500_EVB_PICO)
set(BOARD_NAME W55RP20_EVB_PICO)
#set(BOARD_NAME W5100S_EVB_PICO2)
#set(BOARD_NAME W5500_EVB_PICO2)
```

**Setup network settings**

Setup network configuration such as IP in 'w5x00_coap_client.c' which is the COAP Client example in 'WIZnet-PICO-COAP_C/examples/coap_client/' directory.

```plaintext
/* Network */
static wiz_NetInfo g_net_info =
    {
        .mac = {0x00, 0x08, 0xDC, 0x12, 0x34, 0x56}, // MAC address
        .ip = {192, 168, 11, 2},                     // IP address
        .sn = {255, 255, 255, 0},                    // Subnet Mask
        .gw = {192, 168, 11, 1},                     // Gateway
        .dns = {8, 8, 8, 8},                         // DNS server
        .dhcp = NETINFO_STATIC                       // DHCP enable/disable
};
```

```plaintext
uint8_t payload[] = ""; 
uint8_t uri_path[] = ".well-known/core";
```

**Setup coap client configuration**

Setup COAP configuration in 'coapClient.c' in 'WIZnet-PICO-COAP_C/libraries/coapLibrary/coapClient/' directory.

```
static uint8_t destip[4] = {192, 168, 11, 3};  
static uint16_t destport = 5683;
```

**Setup coap server program**

Download libcoap program

```
$ git clone https://github.com/obgm/libcoap.git
$ cd libcoap
$ git checkout main
```

Build libcoap program

```
$ cmake -E remove_directory build
$ cmake -E make_directory build
$ cd build
$ cmake .. -DENABLE_TESTS=ON
$ cmake --build .
$ cd Debug
```

If the build is successful, the programs coap-server.exe and coap-client.exe will appear as shown below.

![](https://maker.wiznet.io/upload/ckeditor5/50543170%5F1730209240%2Epng)

Execute libcoap server program and open COAP server.

![](https://maker.wiznet.io/upload/ckeditor5/50543170%5F1730209253%2Epng)

**Build & Run**

If the COAP Client example works normally, you can see the network information and the list of resources provided by the CoAP server every second.

![](https://maker.wiznet.io/upload/ckeditor5/50543170%5F1730209310%2Epng)

Wireshark packet capture.
![](https://maker.wiznet.io/upload/ckeditor5/50543170%5F1730209328%2Epng)

---

Source: https://maker.wiznet.io/Aimee0/projects/w55rp20-coap-client-example/
