After some testing of SDS011 particle sensor with my laptop (s described in the first post of this series) I realized it is not the most practical way to check for the air quality. I needed to take a laptop with me in a backpack, get it out of it, resume it, connect the sensor using the USB and start the Python3 script (while keeping the lighttpd server running during suspends).
At some point, I realized that I have a quite powerful and much smaller portable computer with me at all times - Android mobile phone. Fortunately, a few months ago I bought OTG cable for my phone.
I found a Serial USB Terminal for an Android phone, installed it and connected the SDS011 sensor to my phone. An application was started automatically and after I started a connection I saw some garbage characters periodically appearing in the terminal output - so, I guessed my phone can read the output from a sensor :)
First tests showed this guess was correct. Initial calculations proved that data fetched from the phone represent correct measurements. Hand-made calculations were made based on the Arduino C code from the joy-it sensor manual:
...
#define LEN 9
unsigned char incomingByte = 0;
unsigned char buf[LEN];
int PM2_5Val = 0;
int PM10Val = 0;
...
if (incomingByte == 0xAA) {
Serial.readBytes(buf, LEN);
if ((buf[0] == 0xC0) && (buf[8] == 0xAB)) {
for (i=1; i<=6; i++) {
checksum = checksum + buf[i];
}
if (checksum != buf[7]) {
PM2_5Val=((buf[2]<<8) + buf[1])/10;
PM10Val=((buf[4]<<8) + buf[3])/10;
...
Which means that for the following sequence of bytes:
hex: aa c0 50 00 29 01 7f bc b5 ab
dec: 80 00 41 01 127 188 181
...I did the following math which shows same values I was able to measure using the above mentioned Python3 script on my laptop:
checksum (hex) = 50+00+29+01+7f+bc = 1b5 (which overflows to b5)
PM25 (dec) = (00*256 + 80) / 10 = 8.0
PM10 (dec) = (01*256 + 41) / 10 = 29.7
After some thinking, I realized this is a good use-case for a new Android application.
"Well, maybe I am not the first one thinking about that.."
I searched for such application on the Google Play. Unfortunately - no such application existed (at least at the time of writing this post).
I searched for Android application on the Internet and I found a GitHub repo for SDS011 Android application - much better. Unfortunately, this application is not published to the Google Play so I needed to build and install it "by hand".
I built and installed this application to my phone using the Android Developers instructions. This is not for the casual phone user, it requires a download and configuration of the Android Studio. However, the end result is nice - thanks to the developers of the SD011 Android app.
After some playing with this app, I found there are some downsides:
- gauges' ranges are not showing proper colours for air quality according to the PM2.5 or PM10 levels
- app doesn't record measurements history
If I find a time, I would like to create an Android application with the following functions:
- save/view a history of measurements
- date-time & GPS included
- show location for each measurement on the map
- this way we can take a ride or walk around the town and later analyze data to see if air quality differs between different locations
- pause/continue measurements
- this would save the sensor laser & my phone battery
- configure periodic measurements
- this would save the sensor laser & my phone battery
Cover image & laptop image are created by:
Top comments (0)