Things used in this project

Custom parts and enclosures

F360 Hexiwear + Edison dock case
Hexiwear Case.f3z
F360 - Hexiwear Wall Mount
A sleek hexagonal holder that screws to the walls and allows a Hexiwear to slide into the top
Hexiwear Wall Mount.f3z

Code

Particle Photon CodeC/C++
Code for turning the Photon into a sensor. Use at build.particle.io. Requires you to import the HttpClient library via the Particle Online IDE.
// This #include statement was automatically added by the Particle IDE.
#include "HttpClient/HttpClient.h"

#define ADDRESS "192.168.0.27" /* Change this to the IP of the device running the server! */
#define PORT 3000

int pin = D0;

int led = D7;

HttpClient http;

http_request_t request;
http_response_t response;

void setup() {
    pinMode(pin, INPUT_PULLDOWN);
    pinMode(led, OUTPUT);
    
    Serial.begin(9600);
    
}

bool sentOn = false;
bool sentOff = true;

void loop() {
    if(digitalRead(pin) == HIGH){
        if(!sentOn){
            digitalWrite(led, HIGH);
            Serial.println("HIGH");
            send("true");
            sentOn = true;
            sentOff = false;
        }
    }
    
    if(digitalRead(pin) == LOW){
        digitalWrite(led, LOW);
        sentOn = false;
        if(!sentOff){
            Serial.println("LOW");
            send("false");
            digitalWrite(led, HIGH);
            sentOff = true;
        }
    }
}

void send(String on){
    Serial.println("sending...");
    request.hostname = ADDRESS;
    request.port = PORT;
    request.path = "/alarm/"+on;
    Serial.println(request.path);
    
    http.get(request, response, NULL);
    
    Serial.println(response.status);
    Serial.println(response.body);
    Serial.println("sent!");
}
Arduino Sensor CodeC/C++
The code for the MKR1000 to turn it into a sensor
#include <SPI.h>
#include <WiFi101.h>

char ssid[] = "ssid";
char pass[] = "password";

int status = WL_IDLE_STATUS;

char server[] = "192.168.0.27"; /* ip of the device running the nodejs server  */

int sensorPin = 6;

WiFiClient client;

bool sentHigh = false;

void setup() {
  Serial.begin(9600);

  pinMode(sensorPin, INPUT);
  
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);

    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
}

void loop() {
  if(digitalRead(sensorPin) == HIGH){
    if(!sentHigh){
        sentHigh = true;
        sendStatus("true");
      }
  }else{
    sentHigh = false;
  }
}

void sendStatus (char* status){
  Serial.println("\nStarting connection to server...");
  if (client.connect(server, 3000)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println(String("GET /alarm/") +status+" HTTP/1.1");
    client.println(String("Host: ") + server);
    client.println("Connection: close");
    client.println();
    client.stop();
    Serial.println(String("sent alarm status! ") + status);
  }
}
mbed repository with the Hexiwear code
The mbed repository with all the code for programming the Hexiwear via the online mbed IDE/Compiler - Link to the mbed repo is in the Gist
Intel Edison Node.JS Server
Upload to the Edsion. npm install && node.

Credits

1473112518 0278dca0a01648e68b5d157cd8a8b98c%20small
Keith Mitchell

16 year old Canadian Professional Programmer and technology enthusiast

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Using OV7670 Camera Module With Arduino
Advanced
  • 691
  • 30

Protip

This is an Arduino camera module, using the surveillance camera's digital image processing chip-OV0706.

Using Nokia 3310 84x48 LCD with Arduino
Advanced
  • 6,475
  • 115

Protip

These 84 by 48 pixel LCDs are what you might have found in Nokia 3310. And what about using them in the Arduino projects?

A Sudoku Solver's Robot
Advanced
  • 2,457
  • 16

Full instructions

Sudoku-robot is a robot that solves and fills Sudoku grids!

Jrobot - Android and Arduino-Based Global Control Robot Car
Advanced
  • 2,035
  • 11

Jrobot adds wheels to mobile phone and makes it truly mobile. Jrobot on 4G has unlimited range and goes anywhere in the world.

Raspberry Pi - Powered Candy Dispenser
Advanced
  • 1,974
  • 11

Full instructions

Make a candy machine that can give candy with a push of a button or a tweet!

New Electronic Music Instrument Design
Advanced
  • 1,167
  • 7

A new piece for percussion quartet seeks to bring physicality to electronic music using two custom musical instruments.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login