Nathan MiersenEdwin Li
Published © GPL3+

MEGR 3171 Laundry Machine Sensor

Keep forgetting to get your laundry before it wrinkles? No longer with this laundry notification device!

BeginnerFull instructions provided1 hour271
MEGR 3171 Laundry Machine Sensor

Things used in this project

Hardware components

Argon
Particle Argon
×2
Inertial Measurement Unit (IMU) (6 deg of freedom)
Inertial Measurement Unit (IMU) (6 deg of freedom)
×1
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×10
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
LED (generic)
LED (generic)
×1
Resistor 220 ohm
Resistor 220 ohm
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
ThingSpeak API
ThingSpeak API
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Sensing Circuit Diagram

Notifying Circuit Diagram

Code

Sensor Code

C/C++
// This #include statement was automatically added by the Particle IDE.
#include "ThingSpeak.h"

// This #include statement was automatically added by the Particle IDE.
#include "MPU6050.h"

// MPU variables:
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;

TCPClient client;

unsigned long myChannelNumber = XXXXXXX;
const char * myWriteAPIKey = "XXXXXXXXXXXXXXXXX";

void setup() {

    ThingSpeak.begin(client);

    Wire.begin();
    Serial.begin(9600);
   
}

void loop() {
    // Reads output from accelerometer and gyroscope
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    // Prints to serial for easy testing and calibration
    Serial.print("a/g:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.println(ay);
    
    ax = abs(ax);
    
     if (ax > 500) {
        Particle.publish("Running");
    }
    else
        Particle.publish("Off");

    // Write to ThingSpeak
	ThingSpeak.writeField(myChannelNumber, 1, String(ax), myWriteAPIKey);

    Particle.publish("ax", String(ax), PRIVATE);
    delay(15000);
}

Notifying Code

C/C++
const int buttonPin = D5;
const int led =  D4;
int buttonState = 0; 
void setup() {
  pinMode(led, OUTPUT);
  pinMode(buttonPin, INPUT);
  Particle.subscribe("Running", click, MY_DEVICES);
}

void loop() {
 buttonState = digitalRead(buttonPin);
 if (buttonState == 1) {
     Particle.publish("check");

  } else {
    
    Particle.publish("Off");
  }
}
void click(const char *event, const char *data) {
    digitalWrite(led, HIGH);
    delay(20000);
    digitalWrite(led, LOW);
}

Credits

Nathan Miersen

Nathan Miersen

0 projects • 0 followers
Edwin Li

Edwin Li

0 projects • 0 followers

Comments

Add projectSign up / Login