Open rudvfaden opened 1 year ago
I have a similar issue, I cannot get my sensor (PMS5003) to interface with my Nano and output to Serial Monitor. I have a DHT sensor interfacing also to verify that the code is working. From the PMS5003 the Tx -> D3, Rx -> D2. Also the fan kicks on so I know the sensor is receiving power but I am not sure why I can't get it to read at all, let alone reading from the sensor.
Here is my code:
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial Serial1(3,2); // RX, TX PMS pms(Serial1); PMS::DATA data;
void setup() { Serial.begin(9600); Serial.println(F("DHTxx test!"));
dht.begin();
Serial1.begin(9600);
Serial.println("Warming up");
}
void loop() { // Wait a few seconds between measurements. delay(2000);
float h = dht.readHumidity(); // Read temperature as Celsius (the default)
// Check if any reads failed and exit early (to try again). if (isnan(h)) { Serial.println(F("Failed to read from DHT sensor!")); return; }
Serial.print(F("Humidity: ")); Serial.println(h);
if (pms.read(data)) { Serial.println("PM reading good"); //This is the real problem area, I can't even get the code to output anything } }
@Just-ice-E you can't block main loop like these:
// Wait a few seconds between measurements. delay(2000);
Please use examples provided with library. You can also use passive mode and then you will be able to block with the main loop.
Thank you for the library.
I have issue getting output on Arduino r3. I have connected my rxd to pin6 and txd to pin 4 and I use this code.
I was hoping you could guide me in the right direction.