WConstants.h - exit status 1

Hello people!
I recently bought a Gravity UART 50,000ppm CO2 sensor.
Found the code on the DFrobot website and it came back with an error message.
I wired it up on the MKR1000

And this is the code found on their website

/***************************************************
* Infrared CO2 Sensor 0-50000ppm(Wide Range)
* ****************************************************
* The follow example is used to detect CO2 concentration.
  
* @author lg.gang(lg.gang@qq.com)
* @version  V1.0
* @date  2016-6-6
  
* GNU Lesser General Public License.
* See <http://www.gnu.org/licenses/> for details.
* All above must be included in any redistribution
* ****************************************************/ 
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
unsigned char hexdata[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79}; //Read the gas density command /Don't change the order
void setup() {
  
  Serial.begin(9600);
  while (!Serial) {

  }
  mySerial.begin(9600);

}

void loop() {
   mySerial.write(hexdata,9);
   delay(500);

 for(int i=0,j=0;i<9;i++)
 {
  if (mySerial.available()>0)
  {
     long hi,lo,CO2;
     int ch=mySerial.read();

    if(i==2){     hi=ch;   }   //High concentration
    if(i==3){     lo=ch;   }   //Low concentration
    if(i==8) {
               CO2=hi*256+lo;  //CO2 concentration
      Serial.print("CO2 concentration: ");
      Serial.print(CO2);
      Serial.println("ppm");      
               }

  }   
  
 } 

 }

Any fix?

boycreeper123:
Found the code on the DFrobot website and it came back with an error message.
I wired it up on the MKR1000

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "Arduino/Genuino MK - Pastebin.com

A word of advice: you'll be more likely to get help here if you post the error messages directly to the forum (using code tags as you did with the code you posted). If the text exceeds the forum's 9000 character limit, save it to a text file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

boycreeper123:
Any fix?

Yes. The problem is that you're using the SoftwareSerial library, which is not compatible with the MKR1000. Luckily, the MKR1000 has a free hardware serial port you can use instead (which is much better anyway).

Do this:

Wire your sensor to pins 13 and 14 on the MKR1000.

Remove these lines from your code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

Replace all mentions of mySerial (the SoftwareSerial object) with Serial1 (the object for the hardware serial port on the MKR1000).

Hello there, thanks for the advice.
Unfortunately changing everthing to Serial1 still gave me an error message.

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino MKR1000"

sketch_jan27a:2: error: conflicting declaration 'SoftwareSerial Serial1'

 SoftwareSerial Serial1(13, 14); // RX, TX

                       ^

In file included from C:\Users\Korisnik\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.18\cores\arduino/delay.h:23:0,

                 from C:\Users\Korisnik\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.18\cores\arduino/Arduino.h:81,

                 from sketch\sketch_jan27a.ino.cpp:1:

C:\Users\Korisnik\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.18\variants\mkr1000/variant.h:172:13: error: 'Serial1' has a previous declaration as 'Uart Serial1'

 extern Uart Serial1;

             ^

C:\Users\Korisnik\Desktop\sketch_jan27a\sketch_jan27a.ino: In function 'void loop()':

sketch_jan27a:23: error: 'mySerial' was not declared in this scope

      int ch=mySerial.read();

             ^

exit status 1
conflicting declaration 'SoftwareSerial Serial1'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Here is the current code:

#include <SoftwareSerial.h>
SoftwareSerial Serial1(13, 14); // RX, TX
unsigned char hexdata[9] = {0xFF,0x01,0x86,0x00,0x00,0x00,0x00,0x00,0x79}; //Read the gas density command /Don't change the order
void setup() {
  
  Serial.begin(9600);
  while (!Serial) {

  }
  Serial.begin(9600);

}

void loop() {
   Serial1.write(hexdata,9);
   delay(500);

 for(int i=0,j=0;i<9;i++)
 {
  if (Serial1.available()>0)
  {
     long hi,lo,CO2;
     int ch=Serial1.read();

    if(i==2){     hi=ch;   }   //High concentration
    if(i==3){     lo=ch;   }   //Low concentration
    if(i==8) {
               CO2=hi*256+lo;  //CO2 concentration
      Serial.print("CO2 concentration: ");
      Serial.print(CO2);
      Serial.println("ppm");      
               }

  }   
  
 } 

 }

boycreeper123:
Unfortunately changing everthing to Serial1 still gave me an error message.

That's because you missed a part of pert's answer:

pert:
Remove these lines from your code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

Thank you all! <3