SDS011 and arduino dfrobot leonardo

I am trying to read air quality from SDS011 but i am not getting any readings from the sensor. I know that the sensor works fine beacause i have tested it on an RPi. My code is:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// most of the code is based on code from www.inovafitness.com and
// www.dfrobot.com

// set the LCD address to 0x2? for a 16 chars and 2 line display
// use a i2c scanner to detect the real address!
LiquidCrystal_I2C lcd(0x21, 20, 4);

long previousMillis = 0;
const int analogInPin = A0;
int latch = 8;
int srclk = 9;
int ser = 10;

unsigned char displayTemp[8];
unsigned int Pm25 = 0;
unsigned int Pm10 = 0;

void ProcessSerialData()
{
uint8_t mData = 0;
uint8_t i = 0;
uint8_t mPkt[10] = {0};
uint8_t mCheck = 0;
while (Serial.available() > 0)
{
// from www.inovafitness.com
// packet format: AA C0 PM25_Low PM25_High PM10_Low PM10_High 0 0 CRC AB
mData = Serial.read();
delay(2);//wait until packet is received
Serial.println(mData);
Serial.println("*");
if (mData == 0xAA) //head1 ok
{
mPkt[0] = mData;
mData = Serial.read();
if (mData == 0xc0) //head2 ok
{
mPkt[1] = mData;
mCheck = 0;
for (i = 0; i < 6; i++) //data recv and crc calc
{
mPkt[i + 2] = Serial.read();
delay(2);
mCheck += mPkt[i + 2];
}
mPkt[8] = Serial.read();
delay(1);
mPkt[9] = Serial.read();
if (mCheck == mPkt[8]) //crc ok
{
Serial.flush();
Serial.write(mPkt, 10);

Pm25 = (uint16_t)mPkt[2] | (uint16_t)(mPkt[3] << 8);
Pm10 = (uint16_t)mPkt[4] | (uint16_t)(mPkt[5] << 8);
if (Pm25 > 9999)
Pm25 = 9999;
if (Pm10 > 9999)
Pm10 = 9999;
Serial.println(Pm25);
Serial.println(Pm10);
//get one good packet
return;
}
}
}
}
}

void setup() {
// lcd.init(); // initialize the lcd
// lcd.backlight();

// Print a message to the LCD.
// lcd.backlight();
Serial1.begin(9600, SERIAL_8N1);
Serial.begin(9600, SERIAL_8N1);
// Serial.begin(9600);
Pm25 = 0;
Pm10 = 0;
}

void loop() {
ProcessSerialData();

// lcd.setCursor(0, 0);
// lcd.print("PM 2.5 -> ");
// lcd.print(float(Pm25) / 10.0);
// lcd.setCursor(0, 1);
// lcd.print("PM 10 -> ");
// lcd.print(float(Pm10) / 10.0);

Serial.println();
Serial.print("Pm2.5 ");
Serial.print(float(Pm25) / 10.0);
Serial.println();// Display();
Serial.print("Pm10 ");
Serial.print(float(Pm10) / 10.0);
Serial.println();

Serial1.println();
Serial1.print("Pm2.5 ");
Serial1.print(float(Pm25) / 10.0);
Serial1.println();// Display();
Serial1.print("Pm10 ");
Serial1.print(float(Pm10) / 10.0);
Serial1.println();

delay(2000);
}

I want to view the readings in my serial monitor, but the only thing i get there is :

Pm2.5 0.00
Pm10 0.00

over and over again..

Can please anyone take a look at this and give me some input if they can find any errors in my code?

I connected the rx (sds011) to tx1 and tx (sds011) to rx1. And 5V --> 5V, GND --> GND

arduino_sds011.jpg

Manufacturer's page : 山东诺方

On that page is no datasheet, but on their website is the "Laser PM2.5 Sensor specification". Goolgle finds two of those, version 1.0 and version 1.3.
You need version 1.3, it is more specific.

The Arduino Uno is a 5V board, but the sensor uses TTL level of 3.3V for the RX and TX. That means you have to convert the voltages.

The data packages are at a rate of 1Hz. Does that mean that data will come out of it, without command ?

The datasheet does not specify if RX or TX is the output or input. I assume you need to connect RX to TX and TX to RX. I'm pretty sure of it.

Can you just dump the incoming data to the serial monitor ?

Thank you! I think a level converter is needed. I didnt realize that the tx rx are 3.3V.. That definitely sounds like the problem, and also the reason why the sensor works smoothly on my RPi which operates on 3.3V.

i have a arduino uno with pm sensor sds011, i used this code
but it does not work( funca), have a error avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
I'm chileno and my english not very good.

I would appreciate any help