Blynk mpu6050 earthquake sensor "Packet too big" error

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();
  }
1 Like

I’ve edited your post to include three backticks ``` before and after your code. That makes it look nice and understandable.

The first thing I see is the huge delay (5s). This will mess up things. Study the Push Data example to see how to execute timed stuff. This will teach you how to send data in a timed manner to Blynk :slight_smile:

thank you for all of your answers. I had to write my code a couple more times but it turned out to be working. To anyone who’s also working on an earthquake sensor on Blynk 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[] = "xx";


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



#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);


#define PIN_UPTIME V14

BLYNK_READ(PIN_UPTIME)
{
  
  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 alert.");

}

 else{
    Blynk.virtualWrite(V14, "-");
 }
 
  }


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

  EspSerial.begin(ESP8266_BAUD);
  delay(10);

Blynk.begin(auth, wifi, ssid, pass, "xxx", 8442);

while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))

  { 
    Blynk.notify("Earthquake sensor stopped working.");

    delay(500);
    }

  mpu.setThreshold(3); 
}

void loop()
{
  Blynk.run();
}

@isiktantanis What board are you using?

Arduino UNO @Shadeyman

1 Like