Hola buenas tardes, me compré este sensor de calidad del aire,
pero no logro obtener los datos correctamente, le he probado diferentes cosas y nada. ¿podrían ayudarme?
#include "SoftwareSerial.h"
SoftwareSerial mySerial(2, 3); // RX, TX for SDS011 sensor ( to keep Serial monitor available )
// Global Variables
static unsigned char buffSDS[25];// 25
unsigned int PM2_5, PM10 = 0;
void setup() {
// put your setup code here, to run once:
// Read SDS011 on Serial
mySerial.begin(9600); //
mySerial.setTimeout(200);
mySerial.readBytesUntil(0x00,buffSDS,20); // read serial until 0x00 Char received (CR)
// Serial Monitor
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
// Read SDS011
mySerial.readBytesUntil(0x00,buffSDS,20); //(AB)
// Serial monitor, print the HEX bytes received in buffSDS
// Serial.write(buffSDS,10);
for ( int8_t i = 0; i < 10 ; i = i + 1 ) //10
{
Serial.print( buffSDS*, HEX);*
- Serial.print(" ");*
- }*
- Serial.println("");*
PM2_5 = ((buffSDS[4] * 256) + buffSDS[5]) / 10; // extract PM2.5 value - Serial.print("PM2.5: ");*
- Serial.println(PM2_5);*
_ PM10 = ((buffSDS[6] * 256) + buffSDS[7]) / 10; // extract PM10 value_ - Serial.print("PM10: ");*
- Serial.println(PM10);*
- delay(500); //*
- Serial.available();*
}