Introduction: How to Control Arduino With a Mail

About: I was born in Rome in 1972. I have a degree in computer science but I am continuing to study it. My interest in this has also become my profession and I work for a IT multinational company. The most important …

There are a lot of solutions to control an Arduino board: web solutions, desktop application solutions, hardware solutions. But what about mail? Yes, you can find something on the web but they need for ethernet shields and often is Arduino that sends mail. I'd like to control Arduino with a mail. So I've written a command line application that uses my Ardulink java open source library. It's called Ardulink Mail and it's able to receive message, analyze them and control the Arduino boards connected to a PC.


Even if Ardulink Mail has some security controls that application could expose your system on risks for malicious attacks. So please use it very carefully. The author and Ardulink organization is not responsible for damages (

Step 1: Download the Software

You need for:


  1. a regular PC or a SoC (system on chip) like Raspberry PI you can use the operating system you like (Microsoft Windows, Linux or even an Apple)
  2. one or more Arduino/Genuino boards (or compatible boards)
  3. an USB cable


  1. a Java runtime (1.6+)
  2. the Ardulink distribution (into this distribution you can find Ardulink Mail that is the command line application we are searching for)
  3. RXTX Library (for Windows systems it is already in the Ardulink distribution, for Linux system it's possible install it with an apt get command see this more detailed guide for Raspberry)

Mail Account

  1. Of course to receive mail, Ardulink Mail has to open an inbox mail. Actually Ardulink Mail is tested and works very fine with a Google mail account.

Step 2: Configuring the Software

Ardulink Mail has two configuration files. They are located into conf folder in the Ardulink distribution.

In this file you can configure:

  • The mail account you like to use with Ardulink Mail. Actually it is tested and works fine with a Google Mail account.
  • Two security parameters. You can enable/disable a list of mail addresses from which Ardulink Mail can receive messages. You can also enable/disable a mail content password. If enabled Ardulink Mail checks if this password is contained in the mail or not.

This XML file contains info about links, connections and mail handlers that Ardulink Mail has to manage. So you can define a connection with an XML fragment like this:


See Ardulink API to understand connections: Then you can define a link with an XML fragment like this:

<name>LINK 1</name>

or like this:

<aConnectionName>SERIAL CONNECTION</aConnectionName>
<name>LINK 2</name>

See Ardulink API to understand links:

Now you can define commands that execute code when a mail is incoming. A command used in the video above is this:

<aLinkNames>LINK 1</aLinkNames>
<mailContentHooks>turn on</mailContentHooks>
<name>ACCENDI LED 26 e 27</name>

In the className tag you can choose a content manager implementation.
Actually Ardulink Mail has two content manager implementation. The first in the example above search for a mail content hook (defined in the mailContentHooks tag) into the incoming mail body. If a content hook is find (the string “turn on” or its Italian translation “accendi”) then all values are sent to all the link names (in the example just one: LINK 1). So in the example regardless the link’s protocol two strings are sent. These strings are two ALProtocol messages and then PIN 26 and PIN 27 are set to HIGH.

There is another content manager implementation. Unfortunately this implementation has a bug in the v0.6.0. The fix will be general available in the next release. See here for more detail.

Since logic on when a content manager has to do something and logic on what a content manager has to do is delegated to the content manager, you can implement a content manager that do what you want when a right incoming mail is read by Ardulink Mail. Even if you content manager don’t use a link to send messages to an Arduino. So Ardulink Mail can be used as a generic mail processor.

Step 3: Start the Software

From Ardulink lib folder you have just to type this command:

java -jar ardulink-mail-0.6.0.jar

See the video to see Ardulink Mail in action.


You can find more info about Ardulink on Ardulink official site or on Github.


Since v0.6.0 Gutenberg, Ardulink has two main features:

  1. Ardulink Mail explained in this instructables
  2. Ardulink MQTT that is a command line application able to connect Arduino boards with an MQTT broker