Sensor selection

Sensor selection


Updated 2021-12-17: updated recommendations

Sensor selection is the main driver for the BOM (bill-of-materials) of this project. While for our purposes any sensors would be fine due to the rise of the IOT (and HVAC) industry sensors are continuously being improved and the cost is driven down. So usually picking the a sensor boils down to picking the latest sensor of the vendor that fits your budget.

Sensors

For selecting the sensors I have set myself some budget constrains which rule out progressional grade sensors. Within the available budget we aim for accurate and stable (low noise) sensors; response time (we log coarsely), precision (lowest is usually sufficient), size and power efficiency (plugged into a wall socket) are less of a concern. If there are no affordable sensors available which are accurate enough they are omitted, no data is better than unreliable data1. Fortunately our indoor environment requirements are very gentle, e.g. indoor temperature, where I live, only ranges from 15-45°C for which one can find plenty, and cheap, sensors compared to measuring the temperature inside a platinum furnace (melting point of 1768.3°C) or rocket engine exhaust. Let alone the hostile environment of outer-space, ocean floor, corrosion, radiation, … some industries have to deal with. Almost all sensors will be within specification for our use-case.

For those not familiar with the difference between these two concepts, here is an illustration: the bullseye represents the true value while the black dots represent the actual measurements.

Source: antarcticglaciers.org

High precision and high accuracy is usually not in our price range, in case of a trade-off high accuracy is preferred over high precision. This will result in more noise in the data but because we only care about measurements over a longer period of time we can average them “out”2.

As stated in the previous article, i will be using a Raspberry Pi (4B3) and use the breakout board4 version of the sensors; i don’t mind some soldering. Sensor redundancy is not in scope.

Sensor selection, as rookie amateur, is quite hard because data sheets often hype up the specifications and/or leave out important details (calibration set-up). Since i have no reference equipment at my disposal i will have to take their word for it though. Going for well known trusted brands does help but, as expected, usually comes with a higher cost. This also applies for the suppliers, if a sensor is damaged but still provides output (or has drifted from laying on the shelve for years) i will have no way of knowing it is out of spec. Therefore i will effectively be buying blind.

In general all sensors within our budget should be considered “toys” after all, they are not comparable to professional grade, well calibrated, equipment. One could therefore argue you could go for the cheaper ones; although that is not what i did in the end.

The breakout board manufacturer generally does not matter and you can buy them from your favorite brand/supplier. You will have to a take a leap of faith and assume the breakout boards are implemented according to specification of the sensor5. There are also a couple of sensor “eco-systems” available which are usually compatible with the Raspberry Pi through a converter (or can be made compatible with some soldering). If you use SparkFun for example you will need a converter to talk to the Pi, e.g. the SparkFun Qwiic SHIM (or SparkFun Qwiic pHAT V2.0 if you have multiple); or do some soldering.

For each type of sensor i will briefly go trough: why i want to measure said variable, how the sensors work and finally the sensor i have picked (and alternatives). For an overview of the uses sensors you can skip straight to the bill of materials.

Particle matter

What. Particle matter sensors detect matter that is floating around in the air (think smoke, dust, pollen, bacteria, mold, …). The matter is measured by the particle’s diameter, the standard measured sizes are <2.5μm (PM2.5) and <10μm (PM10). Typically reported in μg/m³. These sizes have the most impact on human health because they can get deep into our lungs and possibly bloodstream. Recommended levels are <100 μg/m³, over 500 μg/m³ are considered hazardous. We are looking for a reliable, affordable, indoor sensor.

How. The low-cost sensors, in 2020, typically measure by principle of light scattering. Particles pass through a light source (laser) upon which the light is scattered by the particles which is detected. From these measurements the reported results are estimated using proprietary algorithms. PM10 estimations are usually rather poor. For these low-cost sensors measurements will be affected by high humidity (+70%) since it will start to detect fluid particles instead, so keep in mind to get a humidity (and temperature) sensor as well (some sensors have these build in). To combat noise sensors often, internally, already average the results and therefore do not have an instantaneous response time (typically 6-10sec). Dust accumulation and backflow (particles passing through the sensor multiple times) are some of challenges with these sensors. If they are calibrated it is only for one particular aerosol6 (e.g. wood smoke, fine potassium salts, …), at our price range they are not calibrated to handle every aerosol type. This matters since the sensors only estimate the particles but not directly measure them . Therefore if your situation is significantly different for their calibration conditions you might need to apply corrections7. You can expect a ±10-30% accuracy and service time of 1-8 years (depending on the model/manufacturer). Air pollution is a rather hot topic and there are plenty of research papers out there that do field tests8 on these low-cost sensors. There even exists a (Korean) industrial test standard (SPS‐C KACA 0027‐7269:2018) specifically for low cost sensors. Professional grade sensors may use other, more advanced measuring techniques, have higher accuracy and have a longer service time. They range between xxxx and xx,xxx USD however (for a complete product).

Sensor. I have opted to use the Sensirion SPS30, calibrated (potassium crystals), relative new sensor, small, uses HEPA filter for incoming air, very low measurement variability, the PM10 measurements are unfortunately very inaccurate (unusable), 8 year service time (continuous). UART and I²C. Good open source arduino driver (also has an official one available). The primary reason is its advertised life span, the biggest downside its price. If you are more on a budget i would suggest the Plantower PMS7003/PMS5003 instead.

Alternatives

  • Alphasense OPC-N3 expensive (XXX-XXXX USD. Close to low end professional grade accuracy), measures 0.35-40μm in 24 bins, real-time histograms, ISO 9001:2015 certified, measures PM1.0, PM2.5 and PM10. Relatively big.
  • Honeywell HPMA115C0-004 (the newer version of the HPMA115S0) new, calibrated, ±15% accuracy, PM1 PM2.5 PM4 and PM10, 20k service hours. UART.
  • Panasonic SN-GCJA5L new, ±10% accuracy, PM2.5, PM10 and PM1, 5 year service time (continuous @ 25°C 60% RH). UART or I²C.
  • Telaire SM-UART-04L new, ±10% accuracy, PM2.5, PM10 and PM1, 40k service hours before recalibration. UART.
  • Plantower PMS7003 (or PMS5003) chinese, very popular, calibrated (wood smoke), 3 year service time. UART or I²C.
  • Nova Fitness SDS011 chinese, very popular, good price/performance, only 8k service hours. UART.
  • ( MyPart (UC Berkeley) not assembled (DIY), open source, good accuracy. Project seems dead.)

Form-factors between the sensors differ and must be accounted for when picking a sensor for your project.

You can also use multiple sensors and combine their results, PurpleAir has done so with good results. By combining two Plantower PMS5003 detectors it achieves a remarkable accuracy (of course still not comparably with professional grade equipment).

Temperature

What. Well a temperature sensor measures the temperature ( thermal energy) in °C (or K). Our requirements are very easy to satisfy, measure the (indoor) air temperature (which is between 10-50°C). Assumed the sensor is not placed in direct sun light (which would reach higher temperatures). Precision and response time are less of a concern.

How. We will be looking for a thermistor sensor since these are cheap, abundant and fit our requirements. They work by having a material which resistance correlates with temperature changes.
For a DIY budget the best accuracy you can find at the moment is ±0.1°C but ±0.25-0.5°C is more common. Often the (peak) accuracy is only for a part of their operating range. Given these sensors are cheap those constrains are not bad at all, and we are in luck since usually their most precise range falls within our requirement. New sensors are still being developed and their accuracy keeps improving together with reduced power consumption and price. A ±0.1°C accuracy was unthinkable, in DIY affordable digital chips, about 8 years ago, yet here we are.

Sensor. I will not be using a dedicated temperature sensor and use a combined sensor to get the temperature; see the Hygrometer section. Otherwise i would have gone for the Texas instruments (TI) TMP117 due to its excellent performance, only SparkFun has a breakout board available at the time of writing.

Alternatives

If you want to cut costs, and maybe offer up some accuracy, you can search for a sensor which combines multiple measurements, due to their way of measuring: barometers, hygrometer and gas detectors need to know the temperature as well and often come with a build-in temperature sensor. Examples are: Sensirion SHT31-D (temp and humidity), Bosh BME280 (humidity, pressure, temp), … or buy a PCB/sensor board with multiple sensors; temperature is always included. This will be cheaper than buying each breakout board individually but gives you less sensor selection flexibility and combined sensor PCB’s tend to be a bit harder to find (less choice).

Barometer

What. Barometers measure the atmospheric pressure in their environment. Pressure is measured in pascal (N/m²) or “standard atmosphere” (atm) which corresponds to 101, 325 Pa (average sea-level pressure, see later). There are 2 reference points used for barometers. Atmospheric/absolute/barometric pressure, used in science and industrial applications, which defines the pressure as the weight of a column of air(/gas) compared to the same column as a vacuum. Therefore the atmospheric pressure in a vacuum is always 0Pa. Relative pressure, or mean sea-level pressure (MSLP), is the pressure your location would have if located at sea-level. It is higher than the atmospheric pressure if you live above sea-level and lower if you live below sea-level. It is typically used in aviation and whether reports.
The average value of surface pressure on Earth is 985, 000Pa, the differences due to regular weather events is usually of a few 100Pa. Temperature and humidity affects the atmospheric pressure. Atmospheric pressure is correlated to altitude, the higher your are in earths atmosphere the less dense the atmosphere becomes, hence the less it weights and thus the lower the atmospheric pressure.

How. The sensors in our budget are usually based on the piezoresistive effect. A material (semiconductor/metal) is chosen that changes resistance based on applied mechanical strain (air pressure in this case), and there you have your barometer (or weight scale). The principle has already known for a long time9 and due to rise of handheld devices, and IOT, sensors are becoming more efficient, accurate and cheaper over time. Professional grade barometers are relatively cheap and range between xxx and xxxx USD.

Sensor. Atmospheric pressure is of lesser importance for me, i do not expect any changes other than weather effects. I went for the Bosh BMP388 relative accuracy ±8Pa, absolute accuracy ±50Pa, temperature ±0.5°C, long term drift 33Pa, has onboard storage. I²C and SPI. Due to its price and availability. Bosh announced an improved version, the BMP390, with better specifications but it is not available yet at the time of writing.

Alternatives

  • Infinion DPS310 relative accuracy ±6Pa, absolute accuracy ±100Pa, temperature ±0.5°C, onboard storage of 32 results. I²C and SPI.
  • Hoperf HP303B relative accuracy ±6Pa, absolute accuracy ±100Pa, temperature ±0.5°C, onboard storage of 32 results. I²C and SPI
  • ST LPS22HB relative accuracy ±10Pa @ 25°C, absolute accuracy ±10Pa (if one point calibrated, otherwise ±100Pa), RMS noise 7.5Pa, temperature ±1.5°C.
  • NXP MPL3115A2 relative accuracy ±100Pa, absolute accuracy ±40Pa, temperature ±1-3°C, has on board storage, long term drift ±100Pa. I²C.

Humidity (Hygrometer)

What. Humidity is the concentration of water in the air. There are multiple ways of defining it, absolute humidity is defined as the total mass of water vapor in a volume of air (and ignores temperature). In earths atmosphere it ranges from near ~0-30 gr/m³ when the air is saturated at 30°C. Relative humidity (ϕ) is defined as: for a given temperature (and pressure) take the ratio of the current absolute humidity compared to the highest possible absolute humidity and is expressed in percentage. When 100%, the daw point, the water will start to form droplets (i.e. rain). The same amount of water vapor results in higher relative humidity in cool air compared to warm air. It is an important metric in weather forecasts.
Specific humidity is the ratio of water vapor mass in the total mass of the air. Following the ideal gas law humidity is ways influenced by temperature and pressure.

For humans relative humidity is important because it affects our ability to cool our bodies through sweating. If the relative humidity is high it will feel hotter than it actually is (by a few degrees); and vice versa. Usually between 30-50% is preferred, therefore in some parts of the world (de)humidifiers are quite popular.

How. There are multiple ways of measuring the humidity where capacitive and resistive are in scope for our budget. Resistive hygrometers consist of a material which electrical resistance changes based on the humidity, said material is most of the time also influenced by temperature so these sensors always have at temperature sensor as well. Capacitive based sensors measure the dielectric constant10 (or relative permittivity) of a polymer in a metal oxide11. They usually drift ≤0.25 RH%/year. Both methods only measure relative humidity with an accuracy up to ±1.5-3%.

Sensors. Due to finding a good deal i went with the otherwise expensive Sensirion SHT85, ±1.5% 0-80 RH (±2% otherwise), temperature accuracy ±0.1°C 20-50°C (±0.25°C otherwise), 0.25%/year drift. Uses I²C. It has great performance though and i will be using it as a temperature sensor as well. Unfortunately it is only ±0.1°C accurate from 20°C and above which does not cover the whole range we are interested in, 10-50°C; alas. Otherwise i would have gone for the Sensiron SHT3x due to its good performance and availability; but all of the available sensors listed below ar rather similar and would perform roughly the same.

Alternatives

If you want a, real life, amateur, comparison of hygrometers liutyi has been comparing various sensor outputs over a rather long period of time (also adding new sensors when they become available). He often has multiple sensors of the same type and different breakout board (branded vs non-branded) of the same sensor.

Gas

Gas sensors, e.g. to measure O₂, CO, H, N, … are quite problematic in a DIY setting. Gas concentrations are measured in parts per million (ppm) and usually sensors can only measure in a limited range (e.g. 0-10k ppm = 0-1% saturation). The affordable sensors work electrochemically which means they have a (usually heated) reactant which will erode over time. The reactant generates an electrical current when the targeted gas undergoes a chemical reactions with it. These sensors usually only have a life span of 1-3 years (11 years in the ideal conditions). It also depends on how often, and with what concentration, they are exposed to their target gas. Oxygen sensors are the most problematic since oxygen is everywhere in rather high concentrations so the sensors will wear out even while in storage. The real cheap sensors often react to more than the only the target gas and are not calibrated which makes them more suitable for detection of sudden concentration changes instead of absolute measurements (in ppm) (so more a detector than a sensor). All these sensors are also influenced by relative humidity and temperature. While the more expensive, calibrated, sensors are more reliable they still have the same life span problems. There are of course other measurement techniques, which are much more accurate and do not suffer from lifetime problems, but they are far above a DIY budget and are not compact.

Ideally we would be able to measure the concentration of O₂, CO, CO₂ and volatile organic compounds (VOC)12. But of those only CO₂ sensors have a decent life span and accuracy. That is because they do not work electrochemically but by infrared light. VOC sensors are readily available but unfortunately are not accurate in our price range. Therefore i will only include a CO₂ sensor.

CO₂

What. Carbon dioxide can lead to unpleasant effects when the concentration becomes too high, e.g. racing heart, blurred vision and impaired consciousness. Typically, indoor and outdoor, levels are 350-2000 ppm (usually around 430ppm). Where higher concentrations can start to cause side effects. Since these concentrations are rather low, and indoor air will not have a significant higher concentration, we can limit ourselves to low concentration sensors (0-5k ppm; 0-0.5%).

How. CO₂ sensors in our price range use Non-Dispersive Infrared (NDIR). An infrared (IR) light source, with 4.2 micron band, passes through a tube of air and is caught by a detector. When CO₂ particles pass through the light it is adsorbed13 which means the detector will detect less light than send out by the source. Unfortunately the absorption band of a gas is more like a range and for some gasses their range overlaps, so some cross interference is unavoidable with this method (for CO₂ it is HO₂, SO₂ and NO₂). As usual the sensors are influenced by its environment like pressure and temperature. Many sensors also have auto-calibration features which depends on having “clean air” (400ppm for CO₂) available once every 1-12 days; results are mixed.

Sensor. Sensirion SCD40 new, compact, uses photoacoustics14 instead of NDIR, includes humidity and temperature sensors, calibrated, range 0-40000ppm, accuracy ±(30 ppm + 3% MV). I²C. Unfortunately at the time of writing it is not available for purchase yet; announced end 2019. I expect it to be cheaper than the SCD30. We will have to see how well this new approach works. Otherwise i would go for the Sensirion SCD3015 which is unfortunately quite expensive.

Alternatives

  • Senseair K30 range 0-5000ppm, accuracy ±30ppm ±3% of reading, lifespan >15 years, auto calibration. I²C and UART. Rather high peak power consumption (300mA). Field test. Good webshop firstbyte.
  • Senseair Sunrise SE-11 (or SenseAir S8) range 400-5000ppm, accuracy ±30ppm ±3% of reading, lifespan >15 years, ESD sensitive, build in alerts. I²C and UART.
  • Winson MH-Z14A (or MH-Z19B) ±50ppm or 5% of reading, lifespan >5y, 120s response time. UART. Should be calibrated regularly (6 months). Its auto calibration does not seem to work well.
  • Sensirion SCD30 range 0-10kppm, accuracy ±30ppm + 3% of reading, auto calibration (±50ppm drift). Includes temp and humidity sensor. I²C and UART.
  • Telaire T6613 range 400-2000ppm, accuracy ±30ppm or 3% of reading (400-1250ppm). I²C and UART.
  • GSS CozIR®-Blink range 0-5000ppm, accuracy ±45ppm + 3% of reading, auto calibration. I²C and UART.

Due to how these sensors operate, the “higher-end” models, contain a humidity and temperature sensor as well wich could justify their price more. I would advice not to use the cheaper metal oxide semiconductor (MOS) based sensors since they do not actually measure but just approximate CO₂ and are not accurate at all. Although in the end they are both toys and the NDIR sensors are considerably more expensive; so it depends on your use-case.

Light

What. Many different aspects of light can be measured (split into human and physical centric units). We are interested in its illuminance (in layman terms, intensity), color temperature and, optionally, full electromagnetic spectrum. We will primarily focus on visible light, which is defined as the electromagnetic radiation wavelengths between 400-700nm, and ultra violet (UV) light (10-400nm).
Illuminance is expressed in Lux, lumen per sq. meter or lm/m² and is calibrated for human perception. It typically ranges from 0.0001 (moonless, clouded night) to 130k lx in direct sunlight and is used to determine how well something is lid (e.g. an office).
Color temperature is also focussed on human perception and only applies to visible light. It is defined as the temperature of an ideal black-body that radiates light of a color comparable to that of the light source and is expressed in Kelvin (K)16. It only makes sense to talk about color in the range of red-orange-yellow-white-blue light. It is used in photography, publishing, manufacturing, horticulture (subset of agriculture) and can often be found when buying new light bulbs/leds.
The spectrum, measured with a spectrometer, is the breakdown of the electromagnetic source in its wavelengths frequencies. It applies to the whole spectrum, so more than just the visible light. Same principle as how a prism works. Having this decomposition of the light is used in chemestry, astrophysics and biology to name a few fields. Unfortunately the single chip solutions, for a DIY budget, currently available only break down the spectrum in 6-16 buckets of 50nm which is not that useful (<1nm is more desired). While you(click) can(click) make(click) your own spectrometer that is more accurate (has a higher resolution) they unfortunately take up a bit of space. Since i did not want my sensors to become too bulky and the spectrum is only a gimmick for this project i have opted to not include it at all. A professional grade spectrometer will set you back xxx-xxxx USD (complete product).

How. Lux sensors are based on a photodiode, they convert light to electrical current. Just like a solar panel. The current is generated by the absorbed photons. They often already calculate the lx for you. There are many, good, cheap sensors available. Professional grade Lux meters are fairly cheap and can be found for XXX USD (complete product). Some come with IR filters. Same applies to UV sensors.
Color temperature sensors work on the same principle but use filters over the detector to filter particular wavelengths of the light. Often the sensors have to be calibrated though. I would not get too exited about them but they are also cheap so worth a shot.

Sensor. While the color temperature is just a gimmick for our purposes i included it since the sensors are so cheap, the Ams TCS34725 outputs clear, R, G, B, has an IR filter. I²C. Primary reason is its availability, price and popularity. For lux we will go with the Vishay VEML7700 range 0.0072-120klx, resolution 0.0036 lx/step. I²C. Mostly due to it availability (Adafruit) and good range (most sensors go up to 80klx). For UV i will use Vishay VEML6075; which is retired by Vishey but was still readily available on breakout boards.

Alternatives (Lux)

  • Silicon labs Si115x (Si1151-00-GM) range 0.0001-128klx (different modes), measures visible and IR (IR influences the visible light measurement, you have to compensate on the host), overflows are detected but must be handled by the host, angular sensitivity ±45°. I²C.
  • Ams TSL25911 range 0.000188-88klx, 600M:1 dynamic range, does not calculate Lux. I²C.

Alternatives (Color)

  • Rohm BH1745NUC new, outputs R, G, B, sensitivity: 0.005 lx/step, 0.005 - 40k lx
  • Vishay VEML3328 new, outputs clear, R, G, B and IR outputs. I²C.
  • Broadcom APDS-9960 ambient light and RGB color sensor, proximity, and gesture detection, integrated UV and IR filter. I²C.

These sensors can be omitted if you are planning to place your sensors in an occluded location.

Sound

What. Sound is an oscillation (wave) propagated through a medium (e.g. gas, water or a solid). Humans can only hear sounds with a frequency between 20-20kHz, if high it is called ultrasound (e.g. used in medical imaging), lower is called infrasound. Just like light you can measure different characteristics of sound, we are primarily interested in the sound pressure level (SPL) which is expressed in decibel (dB) and is a logarithmic scale. SPL is derived from the sound pressure (in Pa) and is used to measure hearing loss and provide guidelines to daily exposure. It is a physical unit but humans do not perceive all frequencies as equally loud (and can get more skewed if you have hearing loss), therefore in audiology they measure your sensitivity per frequency (band) in dB HL17. The loudest, natural, sound ever recorded on earth is 31018 dB SPL where >120 dB SPL can cause instant permanent hearing loss. A typical conversation is 60 dB SPL; remember it is a logarithmic scale.

How. A sound level meter comprises a microphone, a preamplifier and signal processing. The electrical signal produced by the microphone is at a very low level, so it is made stronger by a preamplifier before it is processed by the main processor. Signal processing includes applying frequency and time weightings19 to the signal as specified by international standards such as IEC 61672 -1, to which sound level meters conform. In principle it is not that hard to make on your own (only calibration and/or precision may pose a problem). A professional (handheld) sound level (or SPL) meter costs about (low) XXXX USD.

Sensor. Wensn WS1361 sound level meter, primarily for its price (25-30 USD) and fair performance. 30-130dBA or 35-130dBC, accuracy ±1.5dB, A and C (not Z) weighted, 31.5 - 8.5k Hz. It is however a full hand held device so some tinkering is required. There are many re-branded versions of this sound level meter (on Aliexpress and Amazon) which you can recognize by their identical specifications, however make sure to get a version with USB (including the cable which contains a serial converter). The range does not cover the full frequency range humans can hear20 and i would take the accuracy with a grain of salt but for this price you cannot complain and it is sufficient for the use-case. Although its lower limit of 30dBA will be above my noise floor unfortunately (~20dBA); the noise floor very much depends on you environment.
It is battery powered but will we power it through USB. The official documentation is bad, you get what you pay for. Due to its popularity21 you can find many open source projects/blogs to drive the device. Or you can reverse engineer the USB protocol yourself.

Alternatives

  • Gravity: Analog Sound Level Meter 30-130dBA, ±1.5dB, A weighted, 31.5 - 8.5KHz. For arduino. Expensive.
  • Any SPL meter with USB (and power over USB)
  • Create your own using a microcontroller and microphone (properly calibrating it might be a problem without other equipment). If you want to create your own i strongly advice to use a microprocessor instead of a Raspberry Pi since you will have to do real-time sensitive signal processing for which microcontrollers are better suited22.
  • Most cellphones have a pretty good microphone these days and can be used to measure db SPL though an app (e.g. SoundMeter). If you have an old phone laying around it might be worthwhile to use that instead. They are not as accurate, external microphones can help, as the advertised specification of the Wensn WS1361 but i would not trust those specifications.

Vibration (Accelerometer)

What Vibration/earthquake detection.

How Usually a seismograph is used which plots the movement of an inertial mass. If the ground starts shaking, so does the inertial mass which is reflected in the plot. This is the old way, modern detection comprises of thousands motion detectors from which data is aggregated and processed. However back to amateur, low cost, an accelerometer can be used as well which constantly measures acceleration (usually 0 or noise), however when an earthquake hits the sensor will feel acceleration and report it. The acceleration is measured through a piezoelectric transducer which is comprised of a mass (m) and piezoelectric element. When an input acceleration signal a is applied to the sensor, the mass m imposes a force F on the piezoelectric element, which transforms the input acceleration signal into a charge electric signal as the output of the piezoelectric transducer. This signal is further processed and converted tot he sensor output. The sensor measures acceleration signal in accordance with the Newton’s second law of motion: F = ma. Of course these sensors are primarily intended to measure acceleration and have a higher noise flow then desired for professional earthquake monitoring. A more professional sensor for the Rasperry Pi (e.g. Raspberry Shake) will set you back 500-1200 USD.

Sensor ST LSM6DSOX primarily because it has a high accuracy and was available from Adafruit. ±2/±4/±8/±16 g full scale, ±125/±250/±500/±1000/±2000 dps full scale. Smart FIFO up to 9 kbyte, advanced pedometer, step detector and step counter, significant Motion Detection, tilt detection, programmable finite state machine: accelerometer, gyroscope and external sensors. It even has an embedded temperature sensor. Way more then we need, and it is on the expensive side ($10-15 with break-out board).

This sensor is rather useless if you are not living in a earthquake sensitive area.

Alternatives

  • Any other accelerometer and 3D gyroscope, there are many options. Make sure the noise floor is low.

Raspberry Pi

Storage

Micro SD card are not reliable when writing a lot of data, which we will do while logging the sensor data. Therefore i recommend using a 2.5" SATA23 SSD instead (or laptop HDD if you have one already) + SATA to USB 3.0 adapter. USB keys are also an option but their price is comparable to low-end 2.5" SSD’s so the latter is preferred (better performance + lifetime), it will save you an adapter however.

For SSD selection you have 2 categories, those with DRAM (more expensive) and without. DRAM will improve the lifetime and performance (acts as a cache) but comes at a cost. Therefore most people go for a cheaper, non DRAM, SSDs because it might be hard to justify spending as much on the Raspberry Pi as on an SSD. When buying an SSD also keep in mind their lifetime, and performance, degenerate if they are almost full (>70%, esp. >90%). In general smaller capacity SDDs have a lower lifespan (writes are less distributed so the same spot is overwritten more often, causing wear), so buying a bigger SSD without DRAM might be as good as a smaller SSD with DRAM wrt their lifetime. However the amount of sensor data we will store (write) every day is neglectable compared to what modern SSDs are capable of (for the MX500, ~54 GB/day) so this point might be a bit mute (sensor data is typically write “once”24, read often).

The USB3 to SATA adapters are annoying, there are many bad ones out there or counterfeit look-a-likes. If you buy the wrong one it will result in degraded performance. There is no official Raspberry Pi adapter available. For more information see this post.

Power supply

To determine which power supply to buy we should estimate how much the system will use, especially the peak current. According to the Raspberry Pi documentation the board itself uses 600mA and the USB peripheral can draw maximum 1.2A, they recommend at least 3A. The GPIO pins can draw 50mA safely, distributed across all the pins; an individual GPIO pin can only safely draw 16mA. In practice though people report 5V power pins being able to deliver much more current than documented (as much as the power supply provides.). The HDMI port uses 50mA, the camera module requires 250mA, and keyboards and mice can take as little as 100mA or over 1000mA; but we will not be using any of these.

Our biggest power consumers are the SSD (~600mA peak max, depending on the type), SPS30 (85mA peak) and possibly SCD40. All other sensors are a few mA in peak, if that. The big unknown is the SPL meter but they are usually rather power efficient so i expect it to be a 10mA (peak) tops. Therefore we should be safe with the official Raspberry Pi 4 power supply (3A); no additional or heavier power supply is required.

Be careful when using cheap power supplies, they often do not deliver what is promised and the very bad ones can get very hot. Also the cable is important and can influence the voltage and current that reach the Pi. Phonechargers are ok but the Raspberry Pi does not support any of the “quickcharge” features so they will not be used. In general i would strongly recommend to but the official charger to avoid problems in this area.

Alternatively one can opt for a power over ethernet (PoE) hat to power the pi, this will save you a cable and allows one to place the device further from a socket. You do require an ethernet cable though and a switch that can handle PoE. The official one can provide up to 2.5A and cost twice as much as the regular power supply, depending on your situation that might be worth it however my network equipment does not support PoE so i will stick to the regular USB-C power supply.

Real time clock

Because the Raspberry Pi will be permanently connected to the network a real time clock module (RTC) is not required25 for our use-case.

BOM (Bill-of-materials)

FunctionPart IDCostSupplier
PlatformRaspberry Pi 4 4Gb€53.95Sos Solutions
Charger USB-CKSA-15E-051300HE Black (official charger)€9.86Sos Solutions
StorageCrucial MX500 CT250MX500SSD1 250GB€43.67Amazon
SATA to USB3 adapterStarTech SATA to USB 3.0 Adapter (USB3S2SAT3CB)€14.54Amazon
CaseE-T3 mini-ITX case ultra slim€20.74AliExpress
Lux sensorAdaFruit 4162 (VEML7700)€9Ebay (new)
UV sensorVEML6075€3.28AliExpress
Color (temp.) sensorTCS34725 color sensor€1.54AliExpress
Sound pressure level meterWS1361 digital sound meter (with USB)€24.63AliExpress
Particle sensorSensirion SPS30€35.68AliExpress
Hygrometer + TempSensirion SHT85€16.8Ebay (new)
BarometerCJMCU-388BMP€3.49AliExpress
Co₂Sensirion SEK-SCD41€55.33Mouser
Accelerometer and GyroscopeAdafruit 4438 (LSM6DSOX)€12.25Mouser
Foam (for case)High density soundproof foam, 20x20x0.5cm€2x1.09AliExpress
Dupont cables10cm, 10x m/m m/f f/f (copper)€1.64AliExpress
Termal padCPU/GPU cooling conducting silicone pad, 20x20cm€1.2AliExpress
Heat-sinkAlu heat-sink, large€0scrap
Heat shrink tubingHeat shrink tubing, 3mm€0scrap
Screws20x M2.5 (incl nuts)€3.69Local
Electrical tape16mm, 10m, black€0.77AliExpress
Resistors300pcs pack 10-1M Ohm€1.28AliExpress
PTFE0.1mm sheet€1.83Ebay (new)
Eth cableRJ45 Cat6 30cm€1.73AliExpress
Usb 2 to mini usb cable30cm foil + braided 5P€0.63AliExpress
GPIO header5x 2x20 pin 90 degree M/F€1.08AliExpress
4pin cable10x JST GH 15cm female single connector€0.83AliExpress
4pin Qwiic cableAdafruit 150 mm Qwiic 4pin to female€0.98Mouser
Hot glue gun20W Hot glue gun + 30x glue stick€5.26AliExpress

Total €327.88 (+ €25.20 shipping26)

Ouch that is pretty steep… however the cost can easily be reduced by taking a cheaper Raspberry Pi (2GB), cheaper SSD and less, or cheaper sensors (e.g. particle and hygrometer). If you only want to capture sensor data, and don’t run other services, a Raspberry Pi Zero W would have been sufficient. The case in itself is not that expensive but relative to the total it is providing no real functionality (a wood/carboard/defect appliance case would have been just as good).
The SSD is quite expensive (almost as much as the Rapberry Pi!) partly because its price rose due to COVID-19 and partly because it is a relative fast one with cache. A Kingston A400 is a more budget friendly alternative.
The list above includes everything as I pretty much had nothing to start from. Often people already have parts laying around that can be reused (e.g. scrap from previous projects). Another way to save is wait for sales, the case dropped to 11 Euro during a sale (after i had already bought it).

Shipping cost will depend on your location, since there are quite a bit of parts it might be worthwhile to buy as much as possible from a single supplier. You can even let your sensor choice depend on it. For me shipping was quite cheap on Aliexpress, even from multiple suppliers but i think that might have been a promotion. If you have access to non-public discounts (e.g. being a partner, business account, …) or buy as a business (i.e. no taxes) you can greatly reduce the cost by shopping in the common EU/US part stores (e.g. Digikey, Mouser, …); alas i’m a mere consumer.

While i have no issue with buying low cost sensors from China27 i do trust branded, western, companies (Adafruit, SparkFun, …) more than the Chinese boards. Also for sensitive sensors i’m wondering what, if any, damage shipping28 will do (as long as i get output from the sensors i have no way of knowing whether or not they are still within specifications). However for me the price difference between buying sensors from the US/EU was too big, e.g. a 5 USD Adafruit sensor could cost 10-15 Euro + shipping vs a 3-6 USD sensor from China (incl shipping). Only Digikey has fair prices for Adafruit (same as on Adafruit’s website) unfortunately their (Sensirion) particle and Co₂ sensors are very expensive and shipping outside of the “free shipping limit” was expensive for me (for small orders).


  1. the humans brain comes with quite a list of (cognitive) biases. Humans tend to add more weight to early information, believe previously learned misinformation even after it has been corrected ( continued influence effect), judgement biases “as an overweighting of some aspects of the information and underweighting or neglect of others”. So if the sensor is not accurate enough to be useful i prefer to have no measurement data at all. ↩︎

  2. by using signal averaging. Of course this will not work well if the conditions suddenly change. ↩︎

  3. careful when using a Raspberry Pi before the 4th generation since I²C clock stretching, required by some sensors, was wrongly implemented and required to lower the speed of I²C for all attached sensors. This was fixed in 4B however. ↩︎

  4. A minimal PCB for a single component is called a breakout board. The purpose of a breakout board is to “break out” the leads of a component on separate terminals so that manual connections to them can be made easily. Hence you can easily solder wires between different components. Source Wikipedia↩︎

  5. or check the circuit yourself and assume is it soldered under the proper conditions, if you want to be absolutely sure you are most likely better of designing your own PCB instead. ↩︎

  6. an aerosol is a suspension of fine solid particles or liquid droplets in air or another gas. Source Wikipedia↩︎

  7. but this is hard to do in practice without access to calibrated equipment. ↩︎

  8. or this one. Researchers would like to have a low cost sensors which they can use in their research to lower the cost of measuring the air quality in a whole city for example. ↩︎

  9. The change of electrical resistance in metal devices due to an applied mechanical load was first discovered in 1856 by Lord Kelvin. With single crystal silicon becoming the material of choice for the design of analog and digital circuits, the large piezoresistive effect in silicon and germanium was first discovered in 1954 (Smith 1954). Source Wikipedia↩︎

  10. Relative permittivity is also commonly known as the dielectric constant, a term still used but deprecated by standards organizations in engineering as well as in chemistry. Source wikipedia↩︎

  11. a material with high permittivity polarizes more in response to an applied electric field than a material with low permittivity, thereby storing more energy in the electric field. In electrostatics, the permittivity plays an important role in determining the capacitance of a capacitor. The relative permittivity of a material is its (absolute) permittivity expressed as a ratio relative to the vacuum permittivity. The relative permittivity of air changes with temperature, humidity, and barometric pressure. Sensors can be constructed to detect changes in capacitance caused by changes in the relative permittivity. Most of this change is due to effects of temperature and humidity as the barometric pressure is fairly stable. Using the capacitance change, along with the measured temperature, the relative humidity can be obtained using engineering formulas. Source wikipedia↩︎

  12. they can have an impact on your health. The ability of organic chemicals to cause health effects varies greatly from those that are highly toxic, to those with no known health effects. At present, not much is known about what health effects occur from the levels of organics usually found in homes. Source Wikipedia↩︎

  13. described by the Beer-Lambert law CO₂ will absorb the light of that specific wavelength and convert it to internal energy. This principle is also used in astronomy and chemistry to determine the composition/concentration of elements. ↩︎

  14. Narrow-band light matching the absorption bands of CO2 molecules is emitted into a predominantly closed measuring cell. CO2 molecules in the measuring cell absorb a part of the irradiated light, whereas other molecules cannot contribute to absorption due to the spectrum of the emitted light. The more molecules present in the measuring cell, the larger the absorbed energy. The absorbed energy of the CO2 - molecules excites mainly molecular vibrations, which results in an increased translational energy of the molecules and, due to the closed measuring cell, in an increase of pressure in the cell. A modulation of the light source causes a periodic pressure change in the measuring cell, which can be measured with a microphone. The signal of the microphone thus serves as a measure of the number of CO2 molecules present in the measuring cell and can be used to calculate the CO2 concentration. Source Sensirion↩︎

  15. the Senseair K90 would also be a good candidate but the Sensirion SCD30 has dual wavelengt sensor which reduced drift over time. The K30 (single wave) relies on its auto calibration algorithm (expects to be exposed to 400ppm air in a set period of time) which is most likely less precise in practice. ↩︎

  16. the flame color is determined by the temperature (and fuel). From colder to hotter: red, orange, white, blue. For more info see Wikipedia flame and color temperature ( https://en.wikipedia.org/wiki/Color_temperature)↩︎

  17. they use dB HL (devibel hearing level) which has the same scale as db SPL but is normalized where 0 db HL corresponds to 20 dB SPL (the average sound level humans can hear). So you “can” hear negative dB HL if you have above average hearing. For dB SPL 0 means there is physically no sound at all. ↩︎

  18. the 1883 eruption of Krakatoa it was loud enough to be heard 5,000 kilometres away. It was so powerful that it ruptured the eardrums of sailors 64 km away on ships in the Sunda Strait, and caused a spike of more than 8.5 kPa in pressure gauges 160 km away, attached to gasometers in the Batavia gasworks, sending them off the scale. ↩︎

  19. the standard offers multiple way of defining these weights (which are all exponential averaging), you have Fast, Slow and Impulse (or ‘F’, ‘S’ and ‘I’) time weightings. Environmental assessment standards usually specify which time weighting to use.
    You also have frequency weighting which comes in A, C or Z. A-weighting adjusts a signal in a way that resembles the human ear’s response at medium-range levels. The response of the human ear varies with the sound level. C frequency weighting corresponds to the 100 dB equal loudness curve, that is to say, the human ear’s response at fairly high sound levels. ‘Zero’ frequency weighting is a flat frequency response between 10 Hz and 20 kHz ±1.5 dB excluding microphone response. Today, the A-weighting network is the most widely used frequency weighting. Source Brüel & Kjær↩︎

  20. human speach (voice frequency) is usually between 300-3400Hz, so well within range, but for music higher tones will not be taken into account. ↩︎

  21. since there are not many, equally cheap, alternatives it is quite popular in the DIY Raspberry Pi and Arduino communities. ↩︎

  22. in theory you can run a real-time operating system on the Raspberry Pi but a microcontroller will still be better suited. ↩︎

  23. the alternative would be a M2 SSD + adapter M2 to USB3 adapter but M2 driver tend to get hotter and use more power compared to a SATA SSD so if you have one around you can certainly use it but if you need to buy a new one i would recommend SATA. ↩︎

  24. in practice the data might get relocated on the disk or compressed by the database but conceptually it is only written once to disk. ↩︎

  25. the Raspberry Pi 4 does not have a dedicated internal clock and its clock will drift over time if not correct. It can synchronize its clock from the internet (ethernet or wireless) or get it from a (hardware) real time clock connected to the Pi. Usually when logging data a time stamp is included so this is important for our purposes. ↩︎

  26. i always opted for the most economical shipping option; so i had to wait quite a long time for items to arrive. Also sometimes items are more expensive but include free shipping so this is either way not a fair comparison. ↩︎

  27. many of their boarddesigns are copied from western companies (often Adafruit) which is unfair competition so some people argue one should not buy from them; fair enough. If i did not buy a sensor from Adafruit i will not look at their code/resource is a rule i have set for myself. ↩︎

  28. for example i’m wondering if the Sensirion SPS30’s effectiveness will be affected due to (cheap) shipping from China. ↩︎

Noticed an error in this post? Corrections are appreciated.

© Nelis Oostens