making sensors from scratch

Thread Starter

ag-123

Joined Apr 28, 2017
294
This is more a rant and a discussion. Practically, nearly any microcontroller projects that interact with our environment ultimately interface a sensor. And that these days, it seemed for 'convenience', or 'practicality' it is easier to simply 'buy sensors' than making sensors from scratch. Not in the sense of making the sensors from nothing, but that our world is really analog and I keep stumbling into the notion that turning analog into digital is still very much a challenge even though many 'modern' microcontrollers these days has pretty good ADCs e.g. like 12 bits on many ARM based and other microcontrollers.

The examples are like such:
- measuring temperature - well, in most cases the 'easiest' analog means is simply the thermistor
https://en.wikipedia.org/wiki/Thermistor
a thing is in the 'online flea markets' one can find lots of (cheap) '3950' NTC thermistors with practically no specs about their expected behavior. The main things stated are probably the resistances, and more than once I searched 'elsewhere' for 3950 NTC thermistors for 'similar specs' to attempt to map a likely behavior. The trouble is, this can end up with wildly *different behaviours* from the expected behavior.
In the end, one ends up buying a high quality sensor with known specs in an attempt to *** calibrate *** the 'cheap' sensors e.g.
DS18B20
https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf
MCP9808
https://www.microchip.com/en-us/product/mcp9808

- measuring humidity
the 'better quality' ones I'd guess is built around capacitive sensing
https://en.wikipedia.org/wiki/Capacitive_sensing
e.g. a piece of paper perhaps sensitized with some higher relative permittivity materials e.g. TiO2 would probably detect capacitance changes related to changes in relative humidity and temperature.
I actually ended up researching how one could *** calibrate *** capacitance changes with relative humidity, and along that way find that one needs a means to *measure* the relative humidity and temperature accurately while doing all that *calibration*. that in itself is no small challenge, in terms of finding the devices to measure it and the *calibration* task itself.
in the end, one still goes back to DHT11 and the likes as that is probably the simplest way forward
https://learn.adafruit.com/dht/overview

- measuring currents
this is one I thought is 'easy', e.g. take an opAmp, take a small resistance, amplify that voltage read it from ADC, and I = V / R, until I realized the challenges of high side current sensing
https://www.allaboutcircuits.com/techni ... e-sensing/
confronting the high side current sensing challenge is again difficult and it bring us back to at least those made for purpose *high side current sensors*, e.g. INA169, which fortunately these days there are affordable ones to confront the high side current sense challenge.
https://www.ti.com/product/INA169
and eventually things like ina219 wins out as it directly gives i2c *digital* outputs and has programmable gains op amps + high side sensing all built into it
https://www.ti.com/lit/ds/symlink/ina219.pdf
then comes the *chip shortage*
"As of Sept 22, 2022 - due to the severe chip shortage, we've had to update this design to use either the INA219A or INA219B and in SOT-23 or SOIC package - whatever we are able to get on the market! The A version is ±1% total max current measurement error over the entire temp range (±0.5% max at 25*C) and the B version is ±0.5% total max current measurement error over the entire temp range (±0.3% max at 25*C). Overall functionality is otherwise the same."
oh by-the-way, the *cheap* way is *low side current sensing* which can be done with 'relatively cheaper' / 'generic' opAmps e.g. LMV358 and the likes (not LM358 as LMV385 is rail-to-rail and has better characteristics)
https://www.ti.com/product/LMV358
just that for 'low side sensing' one needs to be careful that the supply power isn't 'shorted to elsewhere'.

- AQI PM2.5 sensing
this is an even bigger challenge, and the same issue is *calibration*
I went a huge round into research into *light scattering* going into Rayleigh scattering (answers why is the sky blue) complicated stuff like Mie scattering and it turns out a 'simplest' rather empirical way is the Nephelometer
https://en.wikipedia.org/wiki/Nephelometer
https://gml.noaa.gov/aero/instrumentati ... _desc.html
https://www.bmglabtech.com/en/nephelometry/
"Theories and concepts on light scattering were initially undertaken at the end of the 19th and beginning of the 20th century, mainly by Rayleigh, Mie, and Debye."
but that the 'simplest' of those theories seem to be
https://en.wikipedia.org/wiki/Beer–Lambert_law

log(I0/I) is proportional to ε l c
where - ε is the molar attenuation coefficient or absorptivity of the attenuating species
l - ℓ is the optical path length
c - c is the concentration of the attenuating species
which again is emprical but probably 'simplest'
this probably is how all the 'cheap' light scattering AQI sensors are made
the challenge is again measurements pm2.5 in ug / m3 which probbably requires a mass spectrometer and other sophisticated instruments to even measure it accurately.

a thing is has anyone else (attempted to) confront 'making sensors from scratch' i.e. deal with the analog world ?

it seemed that one of the areas with microcontrollers is electromagnetism, which doesn't seem very well explored in the 'hobbyist' world . e.g. a coil as a sensor and a magnet moving near it that produce the inputs as well as the reverse for it to become an actuator. this again is filled with (complicated) physics equations, maths etc. and in addition calibration against real world data.
 

Ya’akov

Joined Jan 27, 2019
10,226
You say this is a “rant” and it reads like one, but also a “discussion” and I can’t figure out what that discussion is supposed to be about. On the face of it, I see statements of facts—not easy to map onto your (apparent) conclusions that don’t seem to be factual at all.

Could you directly lay out what you want to discuss with no vague quote enclosed phrases? What is, precisely, the basis and point of the discussion you want to have?
 

Jerry-Hat-Trick

Joined Aug 31, 2022
796
I've used an ordinary silicon diodes to measure temperature - with 100uA flowing the junction voltage varies by about 2mV per degree Celsius so connect in series with two resistors, diode in the middle, across known voltage to pass around 100uA and amplify to get a good A/D resolution. This is actually a reasonably practical example.

Years ago, I used a circular tobacco tin with a plate near the lid to make a rudimentary capacitive pressure sensor. Also a rudimentary inductive displacement sensor with a nail in a ballpoint pen tube for coil former. Two sheets of strip board, copper sides facing, with thin plastic film between, sliding one over the other, make an accurate capacitive displacement sensor combining counts of peaks and capacitance in between for large displacements.

Interesting ideas to play with but in practice, if you actually want a reliable accurate reading then components designed for the purpose are largely pretty good and relatively inexpensive.
 

Papabravo

Joined Feb 24, 2006
22,061
This is more a rant and a discussion. Practically, nearly any microcontroller projects that interact with our environment ultimately interface a sensor. And that these days, it seemed for 'convenience', or 'practicality' it is easier to simply 'buy sensors' than making sensors from scratch. Not in the sense of making the sensors from nothing, but that our world is really analog and I keep stumbling into the notion that turning analog into digital is still very much a challenge even though many 'modern' microcontrollers these days has pretty good ADCs e.g. like 12 bits on many ARM based and other microcontrollers.

The examples are like such:
- measuring temperature - well, in most cases the 'easiest' analog means is simply the thermistor
https://en.wikipedia.org/wiki/Thermistor
a thing is in the 'online flea markets' one can find lots of (cheap) '3950' NTC thermistors with practically no specs about their expected behavior. The main things stated are probably the resistances, and more than once I searched 'elsewhere' for 3950 NTC thermistors for 'similar specs' to attempt to map a likely behavior. The trouble is, this can end up with wildly *different behaviours* from the expected behavior.
In the end, one ends up buying a high quality sensor with known specs in an attempt to *** calibrate *** the 'cheap' sensors e.g.
DS18B20
https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf
MCP9808
https://www.microchip.com/en-us/product/mcp9808

- measuring humidity
the 'better quality' ones I'd guess is built around capacitive sensing
https://en.wikipedia.org/wiki/Capacitive_sensing
e.g. a piece of paper perhaps sensitized with some higher relative permittivity materials e.g. TiO2 would probably detect capacitance changes related to changes in relative humidity and temperature.
I actually ended up researching how one could *** calibrate *** capacitance changes with relative humidity, and along that way find that one needs a means to *measure* the relative humidity and temperature accurately while doing all that *calibration*. that in itself is no small challenge, in terms of finding the devices to measure it and the *calibration* task itself.
in the end, one still goes back to DHT11 and the likes as that is probably the simplest way forward
https://learn.adafruit.com/dht/overview

- measuring currents
this is one I thought is 'easy', e.g. take an opAmp, take a small resistance, amplify that voltage read it from ADC, and I = V / R, until I realized the challenges of high side current sensing
https://www.allaboutcircuits.com/techni ... e-sensing/
confronting the high side current sensing challenge is again difficult and it bring us back to at least those made for purpose *high side current sensors*, e.g. INA169, which fortunately these days there are affordable ones to confront the high side current sense challenge.
https://www.ti.com/product/INA169
and eventually things like ina219 wins out as it directly gives i2c *digital* outputs and has programmable gains op amps + high side sensing all built into it
https://www.ti.com/lit/ds/symlink/ina219.pdf
then comes the *chip shortage*
"As of Sept 22, 2022 - due to the severe chip shortage, we've had to update this design to use either the INA219A or INA219B and in SOT-23 or SOIC package - whatever we are able to get on the market! The A version is ±1% total max current measurement error over the entire temp range (±0.5% max at 25*C) and the B version is ±0.5% total max current measurement error over the entire temp range (±0.3% max at 25*C). Overall functionality is otherwise the same."
oh by-the-way, the *cheap* way is *low side current sensing* which can be done with 'relatively cheaper' / 'generic' opAmps e.g. LMV358 and the likes (not LM358 as LMV385 is rail-to-rail and has better characteristics)
https://www.ti.com/product/LMV358
just that for 'low side sensing' one needs to be careful that the supply power isn't 'shorted to elsewhere'.

- AQI PM2.5 sensing
this is an even bigger challenge, and the same issue is *calibration*
I went a huge round into research into *light scattering* going into Rayleigh scattering (answers why is the sky blue) complicated stuff like Mie scattering and it turns out a 'simplest' rather empirical way is the Nephelometer
https://en.wikipedia.org/wiki/Nephelometer
https://gml.noaa.gov/aero/instrumentati ... _desc.html
https://www.bmglabtech.com/en/nephelometry/
"Theories and concepts on light scattering were initially undertaken at the end of the 19th and beginning of the 20th century, mainly by Rayleigh, Mie, and Debye."
but that the 'simplest' of those theories seem to be
https://en.wikipedia.org/wiki/Beer–Lambert_law

log(I0/I) is proportional to ε l c
where - ε is the molar attenuation coefficient or absorptivity of the attenuating species
l - ℓ is the optical path length
c - c is the concentration of the attenuating species
which again is emprical but probably 'simplest'
this probably is how all the 'cheap' light scattering AQI sensors are made
the challenge is again measurements pm2.5 in ug / m3 which probbably requires a mass spectrometer and other sophisticated instruments to even measure it accurately.

a thing is has anyone else (attempted to) confront 'making sensors from scratch' i.e. deal with the analog world ?

it seemed that one of the areas with microcontrollers is electromagnetism, which doesn't seem very well explored in the 'hobbyist' world . e.g. a coil as a sensor and a magnet moving near it that produce the inputs as well as the reverse for it to become an actuator. this again is filled with (complicated) physics equations, maths etc. and in addition calibration against real world data.
There is little reason to suppose that sensors built from scratch would have any noticeable advantages. Similarly, we would not expect to have to build our own tools. Once upon a time that may have been a requirement, but no longer.
 

Thread Starter

ag-123

Joined Apr 28, 2017
294
There is little reason to suppose that sensors built from scratch would have any noticeable advantages. Similarly, we would not expect to have to build our own tools. Once upon a time that may have been a requirement, but no longer.
the hardest thing about 'sensors from scratch' is simply that - calibration
which in practical terms means needing equipment or sensors that can measure the intended physical input accurately.
that said my guess is many of the 'cheap' sensors e.g. DHT11 humidity sensor
are possibly empirically determined and are not necessarily calibrated based on 'high quality laboratory' setups.
https://www.mouser.com/datasheet/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf
either way both temperature and humidity and possibility other factors can influence capacitance / resistance and things like humidity readings from a DHT11 is likely more a 'guide' than an accurate reading.

in terms of things like measuring temperature, e.g. the simplest - thermistors
if one buys them from the 'proper' distributors e.g. Digikey, Farnell, Mouser etc
it is likely those publish specs, calibrated tables and formulas etc. and if those are given against spec e.g. '3950'
one would get basically that without further calibration.
but that if one looks in the 'online flea markets' e.g.
https://www.aliexpress.com/w/wholesale-3950.html
practically every vendor claim that their sensors are '3950' giving hardly any calibrated tables and specs.
one is then practically taking a gamble that they are after all '3950' or to do your own calibration which is a rather tedious (lab) procedure and it still requires an accurate reference sensor e.g. a calibrated semiconductor sensor, thermocouple, etc to do that calibration.
 

MrChips

Joined Oct 2, 2009
34,678
I would like to offer a different perspective.

Traditionally, all sensors were analog. Tremendous effort is spent in amplification, conditioning, compensation and linearization of the analog output before converting to digital.

Today, advanced digital techniques have totally changed the landscape. The focus now is back to the physics and design of the sensor itself. There are huge advantages of digitizing the output of the sensor right at the sensor using high resolution ADCs. 24-bit ADCs can digitize a 1μV signal over a 10V dynamic range. All the analog processing can be done right at the sensor. Temperature, humidity and other environmental compensation and linearization is done at the sensor. The sensor is pre-calibrated. EMI is virtually eliminated. Digital output is transmitted serially via a 1-wire interface. You don’t need an ADC at the receiving end.
 
Top