MKR1310 serial ports

Hi,
I am using the MKR1310 for sending data from a BME280 (temp, pressure, humidity) and a SDS011 (particles) to TheThingsNetwork. The BME280 uses the I2C on the MKR1310 and is no problem. Tae data arrives at the TTN server. The SDS011 on the otherhand uses the serial port. Lora uses also a serial port. When I add the SDS011 tot the RX/TX on the MKR1310, it isn't working

Question: How do I connect the SDS011 sensor (and read the values in the code) to get all the data to the TTN network?

Hi,
Have you been successful?
I am trying to do exactly the same - but I´m kinda new and not very successful.
I manage to get one or the other Sensor to work, but once I try to connect the second sensor nothing works...
Maybe you can help me out with how you wire it and some hints with the code. I would really appreciate!

Thank you
Valentin

No I haven't been succesfull. I have no sollution for you.

Hi Ron, Valentin,
This is from a few months ago, and you may have solved it, but I think that your problem is that the SDS2011 requires a serial port, also needed for Serial println. The Atmega328P in the Arduino UNO and Nano only so many of the SDS2011 libraries use a software serial port to interface to the SDS2011. The SAMD21 microcontrollers have a second on-chip serial port available, but many of the SDS2011 libraries can't use it.

I installed the Nova Fitness dust sensors libraries by Pawel Kolodziejczyk and I successfully ran his example programs.

I'm not sure if this library has been fully tested on MKR boards but it was tested on Leonardo boards, which also have a second serial port, and it worked for my MKR1500. It should work just as well with a MKR1310.

Best,
Ciaran

#include "SdsDustSensor.h"

// tested on Arduino Leonardo with Serial1
SdsDustSensor sds(Serial1); // passing HardwareSerial& as parameter

void setup() {
Serial.begin(9600);
sds.begin(); // this line will begin Serial1 with given baud rate (9600 by default)

Serial.println(sds.queryFirmwareVersion().toString()); // prints firmware version
Serial.println(sds.setQueryReportingMode().toString()); // ensures sensor is in 'query' reporting mode
}

void loop() {
sds.wakeup();
delay(30000); // working 30 seconds

PmResult pm = sds.queryPm();
if (pm.isOk()) {
Serial.print("PM2.5 = ");
Serial.print(pm.pm25);
Serial.print(", PM10 = ");
Serial.println(pm.pm10);

// if you want to just print the measured values, you can use toString() method as well
Serial.println(pm.toString());

} else {
Serial.print("Could not read values from sensor, reason: ");
Serial.println(pm.statusToString());
}

WorkingStateResult state = sds.sleep();
if (state.isWorking()) {
Serial.println("Problem with sleeping the sensor.");
} else {
Serial.println("Sensor is sleeping");
delay(60000); // wait 1 minute
}
}

Should read
The Atmega328P in the Arduino UNO and Nano only have one on-chip serial port so many of the SDS2011 libraries use a software serial port to interface to the SDS2011.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.