This project is a laundry machine sensor that notifies you when the washing machine or dryer has completed the cycle. Most laundry machines only notify that the cycle is completed with a ring or beep. However, it is very easy to miss this sound, especially if the laundry machines are on the other side of the house. This device solves that problem by allowing you to place a device in any room that lights up when the washing machines are running.
It utilizes two Particle Argons. One Argon senses the movement of the laundry machines and sends it to the other Argon, which turns on an LED when there is enough movement.
Building The CircuitsThe first step is building the sensing circuit. A GY-521 module, a breakout board for a MPU-6050. This board contains a three-axis accelerometer, a three-axis gyroscope, a digital motion processor, and a temperature sensor.
For this project, only the accelerometer was utilized. The GY-521 was connected to the Argon as shown in the circuit diagram.
Once the circuit was built, it was tested and calibrated using the serial plotter in the Arduino IDE.
This plot shows that the acceleration stays roughly zero when still, as expected. When the accelerometer is lightly moved around, it easily exceeds 500. This will give a good baseline value to use in the Argon Code.
The second step is building the notifying circuit. This circuit utilizes a switch and an LED. When the switch is pressed, the D7 LED on the other Argon lights for 20 seconds, to check that the connection is established. When the sensing circuit reports that the laundry machine is running, the LED turns on.
Programming
The first step is to include the MPU-6050 library in the code, which assigns the values output from the MPU-6050 to usable variables. These variables are defined as ax, ay, az, gx, gy, and gz. The ThingSpeak library is also included, in order to publish the live data from the sensor.
#include "ThingSpeak.h"
#include "MPU6050.h"
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);
Particle.subscribe("start", check, "XXXXXXXXXXXXXXXXXXXXXXX");
}
void check(const char *event, const char *data) {
digitalWrite(led, HIGH);
delay(20000);
digitalWrite(led, LOW);
}
void loop() {
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
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");
ThingSpeak.writeField(myChannelNumber, 1, String(ax), myWriteAPIKey);
Particle.publish("ax", String(ax), PRIVATE);
delay(15000);
}
The fields filled with "X" need to be filled with correct information. The first, "myChannelNumber" needs to be filled with the channel ID of the ThingSpeak channel. The second, "myWriteAPIKey" needs to be filled with the write API key given by the ThingSpeak channel. The third, in the Particle.subscribe function, needs to be filled with the device ID of the other Argon.
The Particle.subscribe function is used to listen to the other Argon. When the button is pressed on the other circuit, the LED on the sensor circuit turns on for 20 seconds. This allows the user to ensure that both Argons are connected, and establishes 2-way communication.
Whenever the x-acceleration exceeds 500, which is very likely during a laundry cycle, an event named "Running, " along with the acceleration value, is published to the cloud. The data is also constantly published to ThingSpeak for live data graphing.
Live GraphingThe data is constantly published to ThingSpeak every 15 seconds, as this is the quickest ThingSpeak can receive data. This allows you to see when the laundry is running, and any unexpected high acceleration values (for example, if your laundry machine is bouncing around from an uneven load).
The live graphs can be seen here.
Comments