Skip to content

Instantly share code, notes, and snippets.

@orelogo
orelogo / pms_5003.py
Last active March 21, 2021 03:43
Read data from Plantower PMS5003 Particulate Matter (PM) Air Quality Sensor
import serial
import datetime
from collections import namedtuple
from os import path
AirQuality = namedtuple('AirQuality', [
'pm1_standard', # PM 1.0 concentration in μg/m^3, corrected to standard atmophere conditions
'pm25_standard', # PM 2.5 concentration in μg/m^3, corrected to standard atmophere conditions
'pm10_standard', # PM 10 concentration in μg/m^3, corrected to standard atmophere conditions
'pm1_ambient', # PM 10 concentration in μg/m^3, in the current ambient conditions
// Bonfire: Truncate a string
// Author: @orelovo
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
var newStr = "";
if (num >= str.length)
newStr = str;
else if (num <= 3)