Introduction: Arachnio Email-enabled Motion Sensor

This Instructable tells you how to create a motion sensor with the Arachnio that will email you when it detects motion, similar to the project referenced in the Arachnio Kickstarter video but adapted for the production Arachnio. In order to keep the code simple, I haven't included any use of the RTC, the SD card, or sleep modes.

This build uses a PIR sensor, but the code and most of the hardware setup will work just as well with any sensor that produces a digital output.

This Instructable uses the contents of the Arachnio Sensor Pack reward, or the Arachnio Node Pack plus a PIR sensor, battery, and solar panel.

Please note that all of the Arachnios and accessory boards used here are prototypes and the final boards may vary slightly from the ones here.

Step 1: Tools and Materials

For this project, you will need the following tools:

  • A good soldering iron with controllable temperature and a small conical or screwdriver tip
  • A small pair of diagonal cutters
  • Wire strippers
  • A vise or other work holder

You will need the following materials:

  • One Arachnio
  • One Arachnode
  • One PIR sensor -- in this project, we're using the Parallax one since that's what Fry's carries.
  • Wire
  • A LiPo battery & (optional) solar panel

Step 2: Wire Up the PIR Sensor

The PIR sensor has three pins... VCC, GND, and OUT. I used multi-colored ribbon cable for the wire on this project, since I think it's easier to make sure it's pinned right (and I had some lying around). As you can see in the second picture, I went with black to GND, red to VCC, and brown to OUT.

Soldering wires to the pins is tricky. The way I start is by separating and stripping the ends of the wire. I then apply a generous coating of solder to the pins and the ends of the wire.

With the board held in a vise or helping hands, I then hold the solder-coated end of each wire to the corresponding pin and melt them together with the iron.

Make sure the jumper is in the 'high' position (i.e. opposite to what it is here), so the output is continuously high in the presence of motion.

Step 3: Connect It All Up

Once you have wires attached to the PIR sensor, it is time to wire the sensor to the Arachnode:

VCC => 3.3V


OUT => D12

That's the end of the physical part of the assembly, unless you want to mount the sensor in an enclosure or mounting plate. I figure that's very personal to your application, so I haven't covered it here.

Step 4: Software

This code depends on the ITEAD WeeESP8266 library. Start by downloading and installing it:

This code is based on the TCPClientSingle example from the WeeESP8266 library and this email tutorial from the Arduino Playground. It's designed to be connected continuously to the WiFi; this example doesn't do anything with power management and needs a beefy battery and solar panel to work.

If you liked this tutorial, please support the Arachnio on Kickstarter:

<p>#include "ESP8266.h"</p><p>#define SSID        "mySSID"
#define PASSWORD    "myPassword"
#define HOST_NAME   ""
#define HOST_IP     ""
#define HOST_PORT   (25)
#define FROM        "<><>"
#define TO          "<><>"</></></p><p>#define PIRPIN      12</p><p>ESP8266 wifi(Serial1);</p><p>int sendMail (void);</p><p>void setup(void)
    Serial.print("setup begin\r\n");
    Serial.print("FW Version:");
    if (wifi.setOprToStationSoftAP()) {
        Serial.print("to station + softap ok\r\n");
    } else {
        Serial.print("to station + softap err\r\n");
    if (wifi.joinAP(SSID, PASSWORD)) {
        Serial.print("Join AP success\r\n");
        Serial.println( wifi.getLocalIP().c_str());       
    } else {
        Serial.print("Join AP failure\r\n");
    if (wifi.disableMUX()) {
        Serial.print("single ok\r\n");
    } else {
        Serial.print("single err\r\n");
    Serial.print("setup end\r\n");
    pinMode(PIRPIN, INPUT);
void loop(void)
  if (digitalRead(PIRPIN) == HIGH) {
    if (digitalRead(PIRPIN) == HIGH) {
}</p><p>int sendMail (void) {
  char buf[256] = {0};
  char rbuf[32] = {0};
  if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
    Serial.print("create tcp ok\r\n");
  } else {
    Serial.print("create tcp err\r\n");
    return 0;
  strcat(buf, "helo ");
  strcat(buf, HOST_IP);
  wifi.send((const uint8_t*)buf, strlen(buf));
  if (!wifi.recv((uint8_t*)rbuf, 32)) return 0;
  buf[0] = '\0'; // reset buf for the next set of strcat calls
  strcat(buf, "To: You ");
  strcat(buf, TO);
  strcat(buf, "\r\nFrom: Me ");
  strcat(buf, FROM);
  strcat(buf, "\r\nSubject: Something moved!\r\n\r\n");
  strcat(buf, "A moving thing was detected!\r\n.\r\n");
  wifi.send((const uint8_t*)buf, strlen(buf));
  if (!wifi.recv((uint8_t*)rbuf, 32)) return 0;
  buf[0] = '\0'; // reset buf for the next set of strcat calls
  strcat(buf, "QUIT\r\n");
  wifi.send((const uint8_t*)buf, strlen(buf));
  if (!wifi.recv((uint8_t*)rbuf, 32)) return 0;
  if (wifi.releaseTCP()) {
    Serial.print("release tcp ok\r\n");
  } else {
    Serial.print("release tcp err\r\n");
  return -1;