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.
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.
BTW When I change in server.properties user.message.quota.limit to bigger value (on my local blynk server) then it says Buffer overflow…
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.
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
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();
}
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!