BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Packet too big, zeRGBa and sensors

#1

Hi, I have problem with my project. I want to get data from 3 sensors (BMP280, DHT11, TEMT6000) + I want control RGB leds with zeRGBa. But if I upload the code and data are going to send to phone and I simultaneously change values on zeRGBa, my module crashed and started to reboot. Is there some way to control RGB and send data simultaneously? I was searching and trying to fix it, but It wasnť working.
Thanks for answer.

Output:
[21387] Invalid HW cmd:
16:44:52.881 -> +IPD,1,
[21429] Packet too big: 13824
[21608] Ready (ping: 91ms).
[24300] Packet too big: 3338

Code:

    #define BLYNK_PRINT Serial
    #define EspSerial Serial1
    #include <ESP8266_Lib.h>
    #include <BlynkSimpleShieldEsp8266.h>
    #define ESP8266_BAUD 115200
    ESP8266 wifi(&EspSerial);

    char ssid[] = "xxxxxxxxxxxxxx";
    char pass[] = "xxxxxxxxxxxxxxx";

    char auth[] = "4xxxxxxxxxxxxxxxxx9";
    BlynkTimer timer_dht;
    BlynkTimer timer_bmp;
    BlynkTimer timer_temt;
    // DHT

    #include <DHT.h>
    #define DHTPIN 22        
    #define DHTTYPE DHT11   
    DHT dht(DHTPIN, DHTTYPE);

    //BMP

    #include <BMP280.h>
    BMP280 bmp;
    #define P0 1013.25
    double T = 0; 
    double P = 0;
    char measure = 0;

    //TEMT6000
    #define analogPin A4
    int analogHodnota;
    int prepocet;

    void sendDHT()
    {
      float h = dht.readHumidity();
      float t2 = dht.readTemperature();

      if (isnan(h) || isnan(t2)) {
        Serial.println("Failed to read from DHT sensor!");
        return;
      }
      Blynk.virtualWrite(V2, h);
      Blynk.virtualWrite(V3, t2);
    }

    void sendBMP()
    {  
      measure = bmp.startMeasurment();
      if(measure != 0) {
        delay(measure);
        measure = bmp.getTemperatureAndPressure(T, P);
        if(measure != 0) {
          P = P + 20; // '+17' is a correction for the sensor error
          T = T - 1; // like said above
      Blynk.virtualWrite(V5, T);
      Blynk.virtualWrite(V4, P);
      Serial.println(T);
      Serial.println(P);
      }
        else
         Serial.println("Error.");
      }
      else
       Serial.println("Error.");
    }

    void sendLIGHT()
    {
       analogHodnota = analogRead(analogPin);
       prepocet = map(analogHodnota, 0, 1023, 0, 100);
       Blynk.virtualWrite(V6, prepocet);
    }


    void setup()
    {

      Serial.begin(9600);
      EspSerial.begin(ESP8266_BAUD);
      delay(10);
      Blynk.begin(auth, wifi, ssid, pass, "xx.xxx.xxx.xxx", 8080);
      dht.begin();
      if(!bmp.begin()) {            
        delay(1000);
        Serial.println("Init. failed.");
        delay(1000);
        Serial.println("Check wiring.");
        while(1);
      }
      else
        Serial.println("Init. OK.");
        bmp.setOversampling(4);
        delay(2000);
        sendBMP();
      timer_dht.setInterval(1500L, sendDHT);
      timer_bmp.setInterval(5000L, sendBMP);
      timer_temt.setInterval(5000L, sendLIGHT);
    }

    void loop()
    {
       
      Blynk.run();
      timer_dht.run();
      timer_bmp.run();
      timer_temt.run();
    }
0 Likes

#2

Don’t try to run both timer functions at the exact same time

0 Likes

#3

I tried to change it to 6000L, didn’t help :confused: Still crashing when using zeRGBa or slider.

0 Likes

#4

These should be a single BlynkTimer timer as the single timer can have up to 16 instances.

Then these should start with only timer.setInterval...

And this should only be timer.run(); in your void loop()

0 Likes

#5

I cannot find any Blynk functions in your code for these widgets :thinking:

0 Likes

#6

Even if I rewrite the code only to timer instead of timer_dht, timer_bmp… etc. it is still crashing
Packet too big: 2603
Yeah, zeRGBa doesn’t need code, you can set it on mobile for specific pins like D3 D4 D5, slider is same. Maybe merge mode in zeRGBa will work, I’m going to try it.

:thinking:BTW When I change in server.properties user.message.quota.limit to bigger value (on my local blynk server) then it says Buffer overflow…

0 Likes

#7

Only if you use Virtual Pins instead of direct GPIO control.

Besides, Virtual Pins are the recommended way anyhow, as the direct GPIO control aspect is more for simple control and (in my experience) can interfere with more advanced code running on the device.

0 Likes

#8

Okay, so I edited my code to work for zeRGBa merge code, now it doesn’t say Packet too big, so that is super… But, zeRGBa is not working correctly - if I set all colors on zeRGBa to 0 (like put the zeRGBa circle directly down to right side), my LED shines RED :face_with_raised_eyebrow:

Code again:
//BLYNK

#define BLYNK_PRINT Serial
#define EspSerial Serial1
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);

char ssid[] = "CentralniMozekLidstva";
char pass[] = "CML.CentralniMozekLidstva2004";
//char ssid[] = "Karamel";
//char pass[] = "babickasasa1914";
char auth[] = "4ef842eaa3424e3a923688c05aca0b99";
BlynkTimer timer;
// DHT

#include <DHT.h>
#define DHTPIN 22        
#define DHTTYPE DHT11   
DHT dht(DHTPIN, DHTTYPE);
#define RED_LED 6
#define BLUE_LED 5
#define GREEN_LED 7
//BMP

#include <BMP280.h>
BMP280 bmp;
#define P0 1013.25
double T = 0; 
double P = 0;
char measure = 0;

//TEMT6000
#define analogPin A4
int analogHodnota;
int prepocet;

void sendDHT()
{
  float h = dht.readHumidity();
  float t2 = dht.readTemperature();

  if (isnan(h) || isnan(t2)) {
Serial.println("Failed to read from DHT sensor!");
return;
  }
  Blynk.virtualWrite(V2, h);
  Blynk.virtualWrite(V3, t2);
}

void sendBMP()
{  
  measure = bmp.startMeasurment();
  if(measure != 0) {
delay(measure);
measure = bmp.getTemperatureAndPressure(T, P);
if(measure != 0) {
  P = P + 20; // '+17' is a correction for the sensor error
  T = T - 1; // like said above
  Blynk.virtualWrite(V5, T);
  Blynk.virtualWrite(V4, P);
  Serial.println(T);
  Serial.println(P);
  }
else
 Serial.println("Error.");
  }
  else
   Serial.println("Error.");
}

void sendLIGHT()
{
   analogHodnota = analogRead(analogPin);
   prepocet = map(analogHodnota, 0, 1023, 0, 100);
   Blynk.virtualWrite(V6, prepocet);
}

BLYNK_WRITE(V10) // zeRGBa assigned to V10
{
// get a RED channel value
int r = param[0].asInt();
// get a GREEN channel value
int g = param[1].asInt();
// get a BLUE channel value
int b = param[2].asInt();
analogWrite(RED_LED, r);
analogWrite(BLUE_LED, b);
analogWrite(GREEN_LED, g);
}

void setup()
{
   pinMode(RED_LED, OUTPUT);  // Set RED pinMode
  pinMode(BLUE_LED, OUTPUT);  // Set GREEN pinMode
  pinMode(GREEN_LED, OUTPUT);
  Serial.begin(9600);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  Blynk.begin(auth, wifi, ssid, pass, "89.185.250.251", 8080);
  dht.begin();
  if(!bmp.begin()) {            
delay(1000);
Serial.println("Init. failed.");
delay(1000);
Serial.println("Check wiring.");
while(1);
  }
  else
Serial.println("Init. OK.");
bmp.setOversampling(4);
delay(2000);
sendBMP();
  timer.setInterval(1500L, sendDHT);
  timer.setInterval(5000L, sendBMP);
  timer.setInterval(6000L, sendLIGHT);
}

void loop()
{
   
  Blynk.run();
timer.run();
}
0 Likes

#9

Just double, triple check all your pin choices (PWM), pinmodes, code and wiring are correct… sometimes best to work on ecolour at a time.

0 Likes

#10

Oh, I find the problem!
When you are setting zeRGBa in mobile up, in merge mode, there is lines (red, green, blue) between 2 fields for each color (like between 0 and 255) and small wave in circle in the middle, that you can switch it on and off, RED color wave was switched on, so i switched it off and now, it is working without problems.
But anyways, thank you very much for the help! :slight_smile:

0 Likes

#11

Yes, that is a form of “range mapping” that honestly just doesn’t work worth a bleep… I recommend you never touch it :stuck_out_tongue:

0 Likes