Sending an Email to Arduino

We have seen how to send the arduino serial content as email here, in this blog we will see how to send an email to arduino.Instead of simply sending  “hello world”  text, we will try to control the status of digital IO of the arduino.I will be using Node-RED to receive the email and send it to the Arduino.

Installing Required Components:

First you need to install Node-Red on your host (can be a windows system/Linux based system), then install johnny-five in the node-red directory (in case of windows it would be in your home directory .node-red)

Installing johnny five for node-red
Installing johnny five for node-red


npm install node-red-contrib-gpio
On arduino side, you just need to upload standardfirmata example

  • Open the Arduino IDE, select: File > Examples > Firmata > StandardFirmata

Node RED Flow:

The node-red flow looks some thing like this


If you want to use Gmail, you need to get a password, follow this guide to get one .When Node-RED pulls email from Gmail, body contains additional information apart from what you sent, you may need to do additional processing depending on the content to extract the body.  Then Setup a input email node. 10 seconds refresh interval is too fast, 50 seconds should be a good value.


you need to configure the johnny5 node as well, first create a new board


then need to register callback functions


node.log("Board is ready")

node.log("Input message payload"+msg.payload);
node.log("Input message topic "+msg.topic);
//filter emails based on subject
var obj=JSON.parse(msg.payload);
var pin = new five.Pin([0]);
console.log("Updated pin "+[0] +" to "[1]);
}catch (e) {
node.log("not a JSON body");


The subject of the email should be toarduino and the body is a JSON string with pin number and status (1 for HIGH, 0 for LOW).

Sample email (makes the pin 13 LOW)




Add a Comment

Your email address will not be published. Required fields are marked *