---
title: "Remote control your Arduino MEGA and Wiznet Ethernet with Nabto"
url: "https://maker.wiznet.io/WIZnet/projects/remote-control-your-arduino-mega-and-wiznet-ethernet-with-nabto/"
markdown_url: "https://maker.wiznet.io/WIZnet/projects/remote-control-your-arduino-mega-and-wiznet-ethernet-with-nabto/md"
type: "UCC: User Created Content"
author: "Panneer"
author_url: "https://www.nabto.com/remote-control-arduino-mega-and-wiznet-ethernet/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Panneer"
original_url: "https://www.nabto.com/remote-control-arduino-mega-and-wiznet-ethernet/"
published: "2023-02-22"
language: "en"
hardware: ["Arduino Mega 2560", "WIZnet W5100 ethernet shield"]
likes: 3
views: 261
comments: 1
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Remote control your Arduino MEGA and Wiznet Ethernet with Nabto

> Remote control your Arduino MEGA and Wiznet Ethernet with Nabto

Original author: Panneer (source: https://www.nabto.com/remote-control-arduino-mega-and-wiznet-ethernet/)

## Components

- **Arduino Mega 2560** x 1 ([docs](https://www.farnell.com/datasheets/1674878.pdf?_ga=2.12759806.871556650.1519619484-654667508.1508905608&_gac=1.209399078.1518779130.EAIaIQobChMI97my66Sq2QIV77ftCh01kgA_EAMYASAAEgKPyvD_BwE))
- **WIZnet W5100 ethernet shield** x 1 ([docs](https://www.wiznet.hk/en/open-source-hardware/102-w5100s-ethernetshield.html?search_query=W5100+ethernet+shield&results=84))
- Software: **uNabto framework**: uNabto framework and the client APIs can be downloaded using this link

## Article

**Summary:**

With this article you will learn how to create a firmware and an app to securely Internet remote control (from inside AND outside your home network) an Arduino MEGA board with a Ethernet Shield. The IoT communication infrastructure used for this is the Nabto platform which you can [try for free](https://console.cloud.nabto.com/) and easily create remote control IoT systems for all types of microcontrollers and remote control clients (apps, tablets, pc’s etc.). The app and firmware is a simple Heating control demonstration which easily can be altered to your own need.

**What you need:**

- Arduino MEGA2560 board

- Wiznet W5100 Ethernet Shield version 1

**Arduino MEGA:**

(If you know all about Arduino, please scroll down to “**About uNabto” **section**)**

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino-300x198.jpg)

**Technical Specifications:**

1. Microcontroller: ATmega1280 or 2560

2. Operating Voltage: 5V

3. Input Voltage(recommended): 7-12V

4. Input Voltage(limits): 6-20V

5. Digital I/O Pins: 54 (of which 14 provide PWM output)

6. Analog Input Pins: 16

7. DC Current per I/O Pin: 40 mA

8. DC Current for 3.3V Pin: 50 mA

9. Flash Memory: 128KB or 256KB

10. SRAM: 8 KB

11. EEPROM: 4 KB

12. Clock Speed: 16 MHz

**Wiznet W5100 Ethernet Shield:**

The Arduino Ethernet Shield connects your Arduino device to the internet. Just plug this module onto your Arduino board, connect it to your network with an RJ45 cable. As always with Arduino, every element of the platform – hardware, software and documentation – is freely available and open-source.

**Specifications:**

- Operating voltage 5V (supplied from the Arduino Board)

- Ethernet Controller: W5100 with internal 16K buffer

- Connection speed: 10/100Mb

- Connection with Arduino on SPI port

**Technical Specification:**

- IEEE802.3af compliant

- Low output ripple and noise (100mVpp)

- Input voltage range 36V to 57V

- Overload and short-circuit protection

- 9V Output

- High efficiency DC/DC converter: type 75% @ 50% load

- 1500V isolation (input to output)

**Interfacing Arduino MEGA with Ethernet Shield:**

Ethernet Shield Arduino board connects to a LAN or the Internet. Installation is very simple. Plug the Ethernet shield connectors in the expansion card connectors of Arduino and then connect the Ethernet cable to the RJ45 connector slot. In the image below you can see the Arduino Mega with an installed expansion board Ethernet Shield.

**About uNabto:**

Nabto is an IoT application platform that helps you to
1. Quickly develop high-quality client side apps using SDKs and/or template apps
2. Customize the device side application using the provided demo application.
3. The uNabto framework and the client APIs can be downloaded using the below link.
<https://www.nabto.com/downloads.html>

**uNabto Framework:**

The drawing below gives a brief overview of how the Nabto platform actually work. The Device represents the Arduino Mega and the uNabto server (uNabto SDK and Device specific Platform adapters) is running on the device. As soon as device connects to the internet it identifies itself at the Nabto Basestation, using its unique ID which is already registered in Nabto Cloud Console. If a Client wants to connect to the device, a connect request with the device ID is sent to the Basestation, and a direct connection to the device is established after verifying the identity of client. A client can be a native mobile app or an abstraction framework like our [Heat Control](https://github.com/nabto/ionic-starter-nabto)Ionic starter app used in this demo.

![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino4-300x103.png)

- Get more information on the Nabto Cloud Console and the Client/Device SDKs at [www.console.cloud.nabto.com](https://console.cloud.nabto.com/).

**The uNabto Platform Adapter:**

The uNabto Platform Adapter is a small component that abstracts the Native Platforms network and time functionality. The Platform Adapter is part of the uNabto server.

The uNabto server is divided into two layers:

- The uNabto framework ([uNabto SDK](https://github.com/nabto/unabto))

- The uNabto Platform Adapter abstraction layer between the framework and the Native Platform

![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino5-300x198.png)

The device specific uNabto server is readily available in the Nabto Cloud Console to port it to the Arduino module.

**Implementing the Platform Adapter:**

The Platform Adapter acts as link between the generic uNabto framework and the Arduino platform. The adapter is divided into single files, as suggested in the Nabto documentation ([TEN023 Nabto device SDK guide](https://www.nabto.com/downloads/docs/TEN023%20Writing%20a%20uNabto%20Device%20Application.pdf), section 12):

- unabto_config.h: Basic uNabto configuration

- unabto_platform_types.h: Define all necessary uNabto types

- unabto_platform.h: Platform specific ad-hoc functions

- time_adapter.cpp: Time functions

- random_adapter.cpp: Random generator functions

- dns_adapter.cpp: DNS resolver functions

- network_adapter.cpp: Communication functions

- log.cpp: Logging

**Heat Pump Demo:**

The Heat Pump demo showcases how to use the Nabto request response model on the Atmel AVR platform. This demo uses the Arduino MEGA board and Wiznet W5100 Ethernet shield (Ethernet module version 2) to perform the actions.

**Heat Pump Library – Arduino Mega:**

Get the Nabto Arduino Mega2560 library from [<https://github.com/nabtodaemon/heatcontrol-arduinomega#heatcontrol-arduinomega>] and follow the below installation instructions.

- Add the library to the Arduino IDE via

Sketch -> Include Library -> Add .ZIP Library

Browse to the folder containing the downloaded library file and add the unabto-arduinomega-sdk-2.1.1.zip (downloaded zip file)

- Open the HeatPump.ino example via

File -> Examples -> Nabto-Mega2560 -> HeatPump

The sample sketch includes the Nabto class, which encapsulates the Nabto setup. For the sketch to work, the below settings are to be changed. The setting should specify the board’s MAC address (found on the Ethernet board) followed by the unique Device ID and pre-shared key of the device obtained from [console.cloud.nabto.com](https://console.cloud.nabto.com/)

| 1 2 3 | `// Enter device id and pre-shared key from console.cloud.nabto.com` `const char* DEVICE_ID = "abc.xyz.trial.nabto.net/";` `const char* PRE_SHARED_KEY = "4f2a03f29f509035c03bc229ae870849";` |
| --- | --- |

(i.e. Sign-up for a Nabto Cloud Console account, Create a product, Create licenses, copy a license Id and License Key into the DEVICE_ID and PRE_SHARED_KEY in the code section mentioned above)

The loop function inside the sketch is used to call the tick() method of the Nabto class that triggers the framework to check for new UDP packets and send responses. The time between ticks should be around 10 milliseconds. This is achieved by a hard delay, but you can also use the time to do application related tasks. For example, the demo uses it to update the brightness of the LED and to simulate the room temperature in the demo application tick function.

**Test your device:**

After compiling and uploading your HeatPump sketch to the Arduino Mega, it establishes a connection to your Ethernet network and starts the uNabto server. In your serial monitor you should see the following printout:

![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino7-300x128.jpg)

Now, using the Heat Control Ionic starter app (also available on google play store) connect your device and verify that the inbuilt LED changes its brightness according to the target heat.

Read more about obtaining the the Heat Control app or how to compile, possible adjust, your own version here https://www.nabto.com/pc-tutorial
![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino8-300x300.jpg)![](https://maker.wiznet.io/uploads/2021/03/17.06.28-Remote-control-your-arduino9-235x300.jpg)
When the Heat Control Ionic app is started for the first time, you need to pair your client app with the device. Then on, the paired device will be automatically discovered if available online.

---

Source: https://maker.wiznet.io/WIZnet/projects/remote-control-your-arduino-mega-and-wiznet-ethernet-with-nabto/
