fatal error: No such file or directory

So yeah i am trying to get the PM particle sensor to work, what i did was basically just download the github files, put them in the same folder, open all the files in tabs, but when i try to compile i’m getting error;
fatal error: SDS011.h: No such file or directory

#include <SDS011.h>

^

compilation terminated.

Github repo: https://github.com/ricki-z/SDS011

Any suggestions how could i solve this?

Where do you have SDS011.h installed?

Hello,

Libraries need to be copied to correct folders.

under Documents folder in Arduino folder(where you save sketch) (assuming you are using Windows), there is libraries folder.

create a folder SDS011 , copy SDS011.cpp and SDS011.h files into libraries\SDS011 folder.

Eg: folder Documents\Arduino\libraries\SDS011

Thank You Suds

Thanks very much for noob-friendly instructions. I did it and i no longer get the same error, however i have another problem

"SDS011_example:15: error: 'D1' was not declared in this scope

my_sds.begin(D1,D2);

^

SDS011_example:15: error: 'D2' was not declared in this scope

my_sds.begin(D1,D2);"

But i basically just copied the github repository, am i supposed to do something else as well? I know some C, but as far as microcontrollers goes i know close to nothing.. i just want to get this air quality sensor running :D

konkaucion: Thanks very much for noob-friendly instructions. I did it and i no longer get the same error, however i have another problem

"SDS011_example:15: error: 'D1' was not declared in this scope

my_sds.begin(D1,D2);

^

SDS011_example:15: error: 'D2' was not declared in this scope

my_sds.begin(D1,D2);"

But i basically just copied the github repository, am i supposed to do something else as well? I know some C, but as far as microcontrollers goes i know close to nothing.. i just want to get this air quality sensor running :D

In order for anyone to help with this issue, you will need to post your entire sketch. Please read How to use this forum before posting your code.

DangerToMyself: In order for anyone to help with this issue, you will need to post your entire sketch. Please read How to use this forum before posting your code.

I have included the whole "sketch"

I just copied all the files from the github repository, exactly the same https://github.com/ricki-z/SDS011

konkaucion: I have included the whole "sketch"

No. You have only given a link to the files. Who wants to go through the hassle of chasing a file down, extracting it, etc when you could just take 20 seconds (if that) and post the thing?

DangerToMyself:
No. You have only given a link to the files. Who wants to go through the hassle of chasing a file down, extracting it, etc when you could just take 20 seconds (if that) and post the thing?

thought so it would be easier to view on Github.

Anyways, main .INO file;

// SDS011 dust sensor example
// -----------------------------
//
// By R. Zschiegner (rz@madavi.de).
// April 2016

#include <SDS011.h>

float p10,p25;
int error;

SDS011 my_sds;

void setup() {
	my_sds.begin(D1,D2);
	Serial.begin(9600);
}

void loop() {
	error = my_sds.read(&p25,&p10);
	if (! error) {
		Serial.println("P2.5: "+String(p25));
		Serial.println("P10:  "+String(p10));
	}
	delay(100);
}

SDS011.cpp

// SDS011 dust sensor PM2.5 and PM10
// ---------------------
//
// By R. Zschiegner (rz@madavi.de)
// April 2016
//
// Documentation:
//		- The iNovaFitness SDS011 datasheet
//

#include "SDS011.h"

static const byte SLEEPCMD[19] = {
	0xAA,	// head
	0xB4,	// command id
	0x06,	// data byte 1
	0x01,	// data byte 2 (set mode)
	0x00,	// data byte 3 (sleep)
	0x00,	// data byte 4
	0x00,	// data byte 5
	0x00,	// data byte 6
	0x00,	// data byte 7
	0x00,	// data byte 8
	0x00,	// data byte 9
	0x00,	// data byte 10
	0x00,	// data byte 11
	0x00,	// data byte 12
	0x00,	// data byte 13
	0xFF,	// data byte 14 (device id byte 1)
	0xFF,	// data byte 15 (device id byte 2)
	0x05,	// checksum
	0xAB	// tail
};

SDS011::SDS011(void) {

}

// --------------------------------------------------------
// SDS011:read
// --------------------------------------------------------
int SDS011::read(float *p25, float *p10) {
	byte buffer;
	int value;
	int len = 0;
	int pm10_serial = 0;
	int pm25_serial = 0;
	int checksum_is;
	int checksum_ok = 0;
	int error = 1;
	while ((sds_data->available() > 0) && (sds_data->available() >= (10-len))) {
		buffer = sds_data->read();
		value = int(buffer);
		switch (len) {
			case (0): if (value != 170) { len = -1; }; break;
			case (1): if (value != 192) { len = -1; }; break;
			case (2): pm25_serial = value; checksum_is = value; break;
			case (3): pm25_serial += (value << 8); checksum_is += value; break;
			case (4): pm10_serial = value; checksum_is += value; break;
			case (5): pm10_serial += (value << 8); checksum_is += value; break;
			case (6): checksum_is += value; break;
			case (7): checksum_is += value; break;
			case (8): if (value == (checksum_is % 256)) { checksum_ok = 1; } else { len = -1; }; break;
			case (9): if (value != 171) { len = -1; }; break;
		}
		len++;
		if (len == 10 && checksum_ok == 1) {
			*p10 = (float)pm10_serial/10.0;
			*p25 = (float)pm25_serial/10.0;
			len = 0; checksum_ok = 0; pm10_serial = 0.0; pm25_serial = 0.0; checksum_is = 0;
			error = 0;
		}
		yield();
	}
	return error;
}

// --------------------------------------------------------
// SDS011:sleep
// --------------------------------------------------------
void SDS011::sleep() {
	for (uint8_t i = 0; i < 19; i++) {
		sds_data->write(SLEEPCMD[i]);
	}
	sds_data->flush();
	while (sds_data->available() > 0) {
		sds_data->read();
	}
}

// --------------------------------------------------------
// SDS011:wakeup
// --------------------------------------------------------
void SDS011::wakeup() {
	sds_data->write(0x01);
	sds_data->flush();
}

void SDS011::begin(uint8_t pin_rx, uint8_t pin_tx) {
	_pin_rx = pin_rx;
	_pin_tx = pin_tx;

	SoftwareSerial *softSerial = new SoftwareSerial(_pin_rx, _pin_tx);

	//Initialize the 'Wire' class for I2C-bus communication.
	softSerial->begin(9600);

	sds_data = softSerial;
}

SDS011.h

// SDS011 dust sensor PM2.5 and PM10
// ---------------------------------
//
// By R. Zschiegner (rz@madavi.de)
// April 2016
//
// Documentation:
//		- The iNovaFitness SDS011 datasheet
//

#if ARDUINO >= 100
	#include "Arduino.h"
#else
	#include "WProgram.h"
#endif

#include <SoftwareSerial.h>


class SDS011 {
	public:
		SDS011(void);
		void begin(uint8_t pin_rx, uint8_t pin_tx);
		int read(float *p25, float *p10);
		void sleep();
		void wakeup();
	private:
		uint8_t _pin_rx, _pin_tx;
		Stream *sds_data;		
};

Any ideas?
Also “instructions”

Usage

    Define SDS object:
    SDS011(uint8_t pin_rx, uint8_t pin_tx);
    i.e. SDS011 mySDS(pinRX,pinTX);

    Start object:
    void begin(void);
    i.e. mySDS.begin();

    Read values:
    int read(float *p25, float *p10);
    i.e. error = mySDS(pm25,pm10);

Reads the PM2.5 and PM10 values, return code is 0, if new values were read, and 1 if there were no new values.

What is D1 & D2 supposed to represent?

konkaucion: Thanks very much for noob-friendly instructions. I did it and i no longer get the same error, however i have another problem

"SDS011_example:15: error: 'D1' was not declared in this scope

my_sds.begin(D1,D2);

^

SDS011_example:15: error: 'D2' was not declared in this scope

my_sds.begin(D1,D2);"

But i basically just copied the github repository, am i supposed to do something else as well? I know some C, but as far as microcontrollers goes i know close to nothing.. i just want to get this air quality sensor running :D

Hi, The problem you're getting now is related to D1 and D2, which are undefined in your code.

The way my_sds.begin() is being called, and looking at the function definition, it seems that

D1 is the Rx pin (receive pin from micro controller perspective) D2 is the Tx pin (transmit pin from micro controller)

You have to decide which digital pins you want to use to communicate with your sensor over UART Serial.

Have a look at the writeup for SoftwareSerial at the URL below.

https://www.arduino.cc/en/Reference/SoftwareSerial

Please pay close attention to the limitations on which pins can be used as Rx pins (i.e. they support change interrupts), only certain ones can be used.

Once you make a decision on which pins to use, you can define the directives at the top of your sketch.

For example say if you want to use pin 10 for Rx and pin 11 for Tx, you do this

define D1 10

define D2 11

at the top of your sketch below all your includes.

From the wiring perspective you want to have the sensor connected so

SensorTx connects to ArduinoRx (10) SensorRx connects to ArduinoTx (11)

This should get the UART communication established between your sensor and micro controller.