ArduinoGeneral

Help Software serial

userHead Account cancelled 2019-08-02 21:32:24 2767 Views4 Replies
Hiiii, I have the sensor Air Quality Monitor (PM 2.5, Formaldehyde, Temperature & Humidity Sensor), but when I compile I have an error in the linea 2 (SoftwareSerial Serial1(10,11)), Its shows:

exit status 1
conflicting declaration 'SoftwareSerial Serial1'

I changed (10,11) for (19, 18) but the code shows the same error so I need to help with this problem
Thanks

#include <SoftwareSerial.h>
SoftwareSerial Serial1(10, 11); // Software RX, TX
char col;
unsigned int PMSa = 0,FMHDSa = 0,TPSa = 0,HDSa = 0,PMSb = 0,FMHDSb = 0,TPSb = 0,HDSb = 0;
unsigned int PMS = 0,FMHDS = 0,TPS = 0,HDS = 0,CR1 = 0,CR2 = 0;
unsigned char buffer_RTT[40]={}; //Serial buffer; Received Data
char tempStr[15];
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);

}

void loop()
{
while(!Serial1.available());
while(Serial1.available()>0) //Data check: weather there is any Data in Serial1
{
for(int i=0;i<40;i++)
{
col =Serial1.read();
buffer_RTT=(char)col;
delay(2);
}

Serial1.flush();

CR1 =(buffer_RTT[38]<<8) + buffer_RTT[39];
CR2 = 0;
for(int i=0;i<38;i++)
CR2 += buffer_RTT;
if(CR1 == CR2) //Check
{
PMSa=buffer_RTT[12]; //Read PM2.5 High 8-bit
PMSb=buffer_RTT[13]; //Read PM2.5 Low 8-bit
PMS=(PMSa<<8)+PMSb; //PM2.5 value
FMHDSa=buffer_RTT[28]; //Read Formaldehyde High 8-bit
FMHDSb=buffer_RTT[29]; //Read Formaldehyde Low 8-bit
FMHDS=(FMHDSa<<8)+FMHDSb; //Formaldehyde value
TPSa=buffer_RTT[30]; //Read Temperature High 8-bit
TPSb=buffer_RTT[31]; //Read Temperature Low 8-bit
TPS=(TPSa<<8)+TPSb; //Temperature value
HDSa=buffer_RTT[32]; //Read Humidity High 8-bit
HDSb=buffer_RTT[33]; //Read Humidity Low 8-bit
HDS=(HDSa<<8)+HDSb; //Humidity value
}
else
{
PMS = 0;
FMHDS = 0;
TPS = 0;
HDS = 0;
}
}

Serial.println("-----------------------uart--------------------------");
Serial.print("Temp : ");
sprintf(tempStr,"%d%d.%d",TPS/100,(TPS/10)%10,TPS%10);
Serial.print(tempStr);
Serial.println(" C"); //Serial pring Temperature
Serial.print("RH : ");
sprintf(tempStr,"%d%d.%d",HDS/100,(HDS/10)%10,HDS%10);
Serial.print(tempStr); //Serial print humidity
Serial.println(" %");
Serial.print("HCHO : ");
Serial.print(FMHDS);
Serial.println(" ug/m3"); //Serial print formaldehyde, unit: ug/m³
Serial.print("PM2.5: ");
Serial.print(PMS);
Serial.println(" ug/m3"); //Serial print PM2.5, unit: ug/m³
Serial.println();
}
2021-09-15 23:38:25 I am also facing the same problem (SoftwareSerial Serial1(10,11)), refer to cookie clicker for more variables on this code. userHeadPic aricjoshua44
2021-09-03 19:41:42 Hello, I am having an issue with the sensor sms notification. When I compile it has a line error in SoftwareSerial Serial1(10,11) that shows conflicting declaration 'SoftwareSerial Serial1'. After changing (10,11) for (19,18), the code still displays this same error message so I need help understanding what is going on here. Thanks! userHeadPic anonymous
2019-09-12 19:03:11 Hello, I compile your codes, but it has some bugs, I can not compile successfully.
But the sample codes in the wiki(viewtopic.php?f=8&t=17167&tdsourcetag=s_pcqq_aiomsg) is right, I compile succssfully. I suggest you try the sample code again.
userHeadPic Youyou