Dear Blynk team,
I’ve been studying with Arduino for 2 years and recently I’ve discovered Blynk and I’d like to start my words with a huge congrats to the whole Blynk team. You’ve done a thing that can be specified as “revolutionary”.
I’ve been working on “Home automation” for a school project and I am having trouble with the mpu6050 accelerometer. I had written a code to use the sensor as a “earthquake sensor” but everytime it detects and earhquake (everytime i shake the sensor) i get
[40272] Packet too big: 18768
[40902] Ready (ping: 33ms).
[47257] Packet too big: 18768
[47846] Ready (ping: 32ms).
on the serial monitor.
I am using an Arduino uno with esp8266 shield. I am using the blynk app from an iphone and i am on a local server. Also I am using notification and Value display widgets to notify the eartquake. Here is my code:
#include <Wire.h>
#include <MPU6050.h>
#define minval -1
#define maxval 0
MPU6050 mpu;
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "xxx";
char ssid[] = "xxx";
char pass[] = "xxx";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
void setup()
{
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass, "my local server ip", 8442);
// Initialize MPU6050
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
{
Blynk.notify("Earthquake sensor stopped working.");
delay(500);
}
mpu.setThreshold(3);
}
BLYNK_READ (V14) {
Vector rawGyro = mpu.readRawGyro();
Vector normGyro = mpu.readNormalizeGyro();
if(normGyro.XAxis > maxval || normGyro.XAxis < minval && normGyro.YAxis > maxval || normGyro.YAxis < minval && normGyro.ZAxis > maxval || normGyro.ZAxis < minval) {
Blynk.virtualWrite(V14, "Earthquake!");
Blynk.notify("Earthquake detected.");
}
else{
Blynk.virtualWrite(V14, "-");
}
delay(5000);
}
void loop()
{
Blynk.run();
}