measure ohm of HS15P
Fork of Frequency_counter by
This test program measures ohm of HS15P, humidity sensor.
C(micro F) with LMC555 | 0.1 | 0.15 | 0.22 | 0.33 | 0.47 | 0.68 | 1 |
CONV_KILO_OHM | 0.0072 | 0.0048 | 0.0033 | 0.0022 | 0.0015 | 0.0011 | 0.00072 |
If you get 2500 microseconds as interrupt time interval , it means 18 kilo ohm when 0.1 micro F. ( = 2500 * 0.0072 )
- ohm of HS15P is calculated from pulse interval of LMC555.
- CONV_KILO_OHM will be used.
- this program reads interval time.between interrupt in the P8.
- takes ON the P9 to oscillate LMC555 as short as enough to measure interval time
- last several interval times will be used for calculation.
- the time is defined as READ_TIMER .
- In current circit, VDD of LMC555 is about 1.55V, AC 0.4V between pins of HS15P.
- LMC555 consumes 120 micro A while oscillation, 90 micro A when level of P9 is OFF. (reset is ON)
- Total 1-2mA is consumed in the circit.
Related nootbook : https://mbed.org/users/strysd/notebook/measure_humidity_with_hs15p_and_lmc555/
main.cpp
- Committer:
- strysd
- Date:
- 2014-05-11
- Revision:
- 8:6d956be23ed8
- Parent:
- 7:42e7f18361c8
File content as of revision 8:6d956be23ed8:
//see mbed.org/users/strysd/notebook/measure_humidity_with_hs15p_and_lmc555/ #include "mbed.h" #include "main.h" InterruptIn in(p8); //connect to the Discharge of 555 DigitalOut run555(p9);//connect to the Reset of 555 DigitalOut led1(LED1);//running 555 DigitalOut led2(LED2);//not ready Timer t1; float my_interval = 0;//between interrupts in microseconds float my_freq = 0;//Hz float my_ohm = 0;//ohm for HS15P int rest_in = 0;//rest of interrupt times void flip(void) { if(rest_in < READ_TIMER){ my_interval = t1.read_us();// Get time since last interrupt } t1.reset();// Reset timer and wait for next interrupt rest_in--; if(rest_in <= 0){ //No use interrupt run555 = led1 = 0; t1.stop(); } } int main() { run555 = led1 = led2 = 0; // Set up the interrupt in.mode(PullUp); in.rise(&flip); printf("\rStarting measure\n"); while (1) { //Use interrupt my_interval = 0; t1.start(); rest_in = IN_TIMES; run555 = led1 = 1; led2 = 0; wait_ms(WAIT_IN); run555 = led1 = 0;//force stop if (my_interval < MIN_INTERVAL || my_interval > MAX_INTERVAL){ printf("\r not ready\n"); led2 = 1; } else { my_freq = ONESEC_BY_MICRO / my_interval; // Convert to Hz my_ohm = my_interval * CONV_KILO_OHM;// Convert to kilo ohm printf("\r %.0f Hz, %.0f micro sec, %.1f kilo ohm \n", my_freq, my_interval, my_ohm); } wait_ms(WAIT_NEXT); } }