I need to read a humidity sensor whose output is given in Hz, but the values are higher than 10KHz and below 20KHz, I would like to know the most appropriate way to do this value measurement with a STM32F4 discovery. All I want is to print the frequency on the IDE console or a hypertherminal.
Are you sure that the humidity sensor outputs some values in [Hz] ? This seems very unlikely. Unless you talk about the frequency of sampling? In that case, you won't find easily any humidity sensor able to output new sample at more than a few [Hz]. Humidity is something that does not vary quickly.
Could you explain in details what you want to do? Could you also share the documentation of your humidity sensor?
If you want to measure the frequency of a signal that fast then you're probably best off using the hardware that's built into the STM32F4.
There's a page on how to do that here: http://www.espruino.com/STM32+Peripherals
It pretty much walks you through all the code you need to use the hardware to count the amount of times the pin changes state - then you could just sample and reset that register every second using setInterval and you've got yourself a frequency measurement in Hz.
Thanks to the support, this humidity sensor was developed in my teacher's lab, it is a capacitive circuit board with a conditioning circuit that contains an IC 555. It has a 5V power cable, a ground and an out, whose the values are given in frequency.
I got satisfactory results with the oscilloscope but the desire to get this data with the espruino.
Thanks for the details.
As a first try you can use the setWatch function. When the given callback is called, the parameters lastTime and time are passed to it. by doing 1/(time-lastTime) you get the frequency value.
The limitation could be the processing time of the callback, but you can go up to 1kHz easily as far as I remember. Then you can maybe adjust the RC constant of your 555 circuit in order to decrease the maximal output frequency.
Yep - setWatch is nice and easy (and accurate on STM32F4), but being JS execution is slowish you'll struggle at much above 1kHz - but as @Jean-Philippe_Rey points out you may be able to modify your circuit to lower the frequency.
The link I posted above should be pretty much copy/paste and will give you nice accurate results for the higher frequencies though
thank you very much :))
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem