Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SI units? #47

Open
MartinMalinda opened this issue May 21, 2015 · 4 comments
Open

SI units? #47

MartinMalinda opened this issue May 21, 2015 · 4 comments

Comments

@MartinMalinda
Copy link

I cant find any information what is the format of the audio and light data. Is it possible to convert that value somehow to lux and Bel values? Is it possible to use the module in a way to measure light and noise responsibly, e.g. is it precise? If so it would be great addition to the climate module for me.

Thanks in advance for any response.

@jiahuang
Copy link
Contributor

The values are read by calling analog read on the corresponding audio/light sensor. This is then normalized according to the max analog read (1024).

You could technically convert this to lux/bel values by getting a lux meter and mapping the values. Not sure if there's a better way to do it. @ekolker any ideas?

@ekolker
Copy link
Member

ekolker commented May 21, 2015

Way ahead of you, Jia.

Background: I did the hardware design, @johnnyman727 did most of the firmware. SI units weren't something we designed for explicitly, but that doesn't mean you can't make some measurements to calibrate the device or solve for the transfer functions. Right now, we basically aim to provide resolution on the order of "is it loud/bright?"

The module's schematic is here. You'll also probably need the datasheet for the phototransistor and the microphone.

The phototransistor's current passes through a 1k resistor, then a buffer and a filter, neither of which should change its amplitude.

The sound side of the module is a fair bit more complicated, but it has the added benefit of being adjustable (this also means that, statistically, it's less likely to be uniform from one board to another, but also that you can compensate for this fact). I actually did a presentation on how it works, complete with some LT SPICE simulations, but the basic steps on the signal path are below:

  • mic voltage multiplied by 100
  • multiplied by adjustable gain (initially set to 1, adjustable via potentiometer R6 on the schematic)
  • filtered
  • shifted such that the signal is centered on 0.3V
  • peak detected with a silicon diode, which effectively cuts out the bottom 0.6V (~6mV of the raw mic signal) worth of range
  • slow bleed with a time constant of 1 second

The second to last part means that, sadly, the system is nonlinear in the Signals And Systems sense of the term because it has that DC offset. That said, in a mathematical sense, there should be a y = ax + b-style linear relationship between the mic signal and the value you get out with our API.

All the while, the signal needs to stay within the 3.3V rail (plus whatever our op amp needs) or it will saturate.

@ekolker
Copy link
Member

ekolker commented May 21, 2015

Also worth mentioning that all the resistors on that board are 5%. This basically just means that the best and fastest way to figure all this out is to calibrate everything to a known-good source...which you should probably do anyway.

@MartinMalinda
Copy link
Author

Thank you so much. Luckily the light measuring is much more important for me than sound.
It looks like the spectral sensitivity is quite different than that of human eye. It peaks at 900nm while human eye does at 555nm, that could produce higher values in the mornings and evenings when the light wavelengths are higher. Unfortunately my hardware skills are still super basic so I am left with software solutions mostly. I will try some calibrations and mappings and see if I can produce any reliable values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants