I have too sketch :
#define CO2_RX D2
SoftwareSerial SerialCO2(CO2_RX, CO2_TX); // RX, TX
But i dont know if it will be working with Nextion …
I have too sketch :
#define CO2_RX D2
SoftwareSerial SerialCO2(CO2_RX, CO2_TX); // RX, TX
But i dont know if it will be working with Nextion …
Ok here is;
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <Wire.h>
#include <SoftwareSerial.h>;
#include <Nextion.h>
#include <SI7021.h>
#include <Adafruit_BMP085.h>
#include <BH1750.h>
BH1750 lightMeter;
float temp, hum;
bool SI7021_present = true;
//#define I2C_SCL 5 //D1
//#define I2C_SDA 4 //D2 //D4
SI7021 sensor;
Adafruit_BMP085 bmp;
float dst, bt, bp, ba;
char dstmp[20], btmp[20], bprs[20], balt[20];
bool bmp085_present = true;
// MH-Z19:
// power - 5v
//D4 - TX sensor, D3 - RX sensor
//#define CO2_TX D4
//#define CO2_RX D3
//SoftwareSerial co2Serial(CO2_TX, CO2_RX);
SoftwareSerial HMISerial(12,14,false,256);//RX-D1 5 , TX-D2 6
Nextion myNextion(HMISerial, 9600);
char auth[] = ""; // Put your Auth Token here. (see Step 3 above)
SimpleTimer timer;
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, "", ""); //insert here your SSID and password
sensor.begin(4,5);
Wire.begin(4,5);
delay(10);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
//while (1) {}
}
// Setup a function to be called every second
timer.setInterval(10000L, sendUptime);
lightMeter.begin();
// co2Serial.begin(9600);
//co2Serial.flush();
myNextion.init();
String dim = "dim=50"; //pro podsvíceni
myNextion.sendCommand(dim.c_str());
}
/*int readCO2()
{
byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
char response[9];
co2Serial.write(cmd, 9); //request PPM CO2
co2Serial.readBytes(response, 9);
byte crc = 0;
for (int i = 1; i < 8; i++)
{
crc += response[i];
}
crc = 255 - crc;
crc++;
if (response[8] != crc)
{
Serial.println("Wrong crc from co2 sensor!");
return -1;
}
if (response[0] != 0xFF)
{
Serial.println("Wrong starting byte from co2 sensor!");
return -1;
}
if (response[1] != 0x86)
{
Serial.println("Wrong command from co2 sensor!");
return -1;
}
int responseHigh = (int) response[2];
int responseLow = (int) response[3];
int ppm = (256 * responseHigh) + responseLow;
return ppm;
}*/
void sendUptime()
{
//int co2_ppm = readCO2();
//Blynk.virtualWrite(1, co2_ppm); // virtual pin
float temperature = sensor.getCelsiusHundredths()/100;
float humidity = sensor.getHumidityPercent();
Blynk.virtualWrite(5, temperature);
Blynk.virtualWrite(6, humidity); // virtual pin
int16_t lux = lightMeter.readLightLevel();
Blynk.virtualWrite(4, lux);
int bp = bmp.readPressure();
Blynk.virtualWrite(9,(float)bp/100,2);
//float ba = bmp.readAltitude();
//Blynk.virtualWrite(7, ba);
float bt = bmp.readTemperature();
Blynk.virtualWrite(12, bt);
float dst = bmp.readSealevelPressure(520)/100;
Blynk.virtualWrite(13, dst);
myNextion.setComponentText("t5", String(lux));
myNextion.setComponentText("t2", String(bp));
myNextion.setComponentText("t1", String(dst));
myNextion.setComponentText("t3", String(temperature));
myNextion.setComponentText("t4", String(humidity));
//myNextion.setComponentText("t0", String(co2_ppm));
delay(1000);
}
void loop()
{
Blynk.run();
timer.run();
}
Wow so many different sketches. I just start checking one and you send another.
I’ll leave it with you for 48 hours or so until you decide what you are trying to do.
I need only add CO2 sensor to my last sketch…
Can i have together;?
SoftwareSerial HMISerial(12,14,false,256);//RX-D1 5 , TX-D2 6
Nextion myNextion(HMISerial, 9600);
and
//D4 - TX sensor, D3 - RX sensor
#define CO2_TX D4
#define CO2_RX D3
SoftwareSerial co2Serial(CO2_TX, CO2_RX);
co2Serial.begin(9600);
co2Serial.flush();
thanks
You can’t have this duplication.
Do you have a link to the CO2 sensor you are using?
But this : sensor.begin(4,5);
Wire.begin(4,5); is me working…
So all right. SoftwareSerial co2Serial(CO2_TX, CO2_RX);
SoftwareSerial HMISerial(12,14,false,256);//RX-D 5 , TX-D 6
Nextion myNextion(HMISerial, 9600);
this together working good. THank you for
your answers