How to use CoAP Protocol with WizArduino M0 ETH


Configure CoAP Server and CoAP Client using two WizArduino.

Configure the system to be able to turn On/Off the LED

according to the sensing value by connecting CDS sensor to LED.


1. What is CoAP?


The initials CoAP stand for Constrained Application Protocol. CoAP is an application protocol for low specification module. In other words, this is a lightweight version for WPAN device with limited resources although we want to use HTTP. It supports low power and the main purpose is to transfer sensor data. It also has asynchronous request/response design structures.


2. Arduino IDE Setup

sed two WizArduino for Server and Client configuration.



It will turn ON/OFF LED on the server side after reading the data value of illuminance sensor at Client to determine the light ON/OFF and sending it to the server.


First of all, we have to add M0 board since WizArduino is based on M0.


We can select the M0 board as searching for and installing M0 in the board manager.



Next, we need to add a library.

We need to add Ethernet2 library separately and install CoAP library because it is not compatible with Ethernet library based on W5500.


As with adding a board, we can install the library at the top by searching for Ethernet2 and CoAP.


3. CoAP Server


CoAP Server is responsible for receiving the data from CoAP Client.

Run the example of [file-examples-CoAP Simple library-server].


Add 2 in the red boxes for the same reason we installed Ethernet2 library. (Ethernet2.h, EthernetUdp2.h)

In coapserver source code, we create request(goap.put()) of CoAP as comments and use only coap.get() to make CoAP Server only receive.



Then, add code to control the connected LED that analyzes the receiving messages.



3. CoAP Client

Read illuminance sensing data of CDS Sensor by connecting illuminance sensor to Arduino A1.

The read sensing value will send ON/OFF data information to CoAP Server based on the specific threshold value.




CoAP_client_loopCoAP_mac CoAP_Serial


Please Login to comment
Notify of