1

I try to design a moisture sensor for the Raspberry Pi. To get a more stable measurement my idea was to use the 555 to generate a frequency depending on the capacitance. The circuit looks as follows:

Moisture sensor

I'm new to electronics, and I'm a bit worried since the circuit uses 5 V and the Raspberry Pi only handles 3.3 V. I've therefor added this voltage divider in the lower left corner for the output JP1 Pin2 which should transform the voltage of the output pin to a max of 3.3 V.

Is this enough or do I have to take other measures to translate the voltages?

  • It should work, but this isn't really a good solution to measuring capacitance. You have replaced this by the problem of measuring frequency. If you search there are articles using the Pi as a poor man's ADC which measures the time to discharge the capacitor. – Milliways May 26 '15 at 23:35
0

That will be fine. As long as the input voltage is less than 5 V, the output voltage (to JP1-2) will be less than 3 V.

1

Measuring capacitance indirectly as a function of frequency is perfectly valid. The pulse width modulated signal from the 555 timer circuit can be fed into an I/O pin of a microcontroller dedicated or configured as an input to a timer or counter. In the case of using a timer, the I/O pin would be configured to trigger an interrupt service routine when it detects a rising edge of a pulse. The interrupt service routine could stop a timer, copy its value to a global variable, clear the timer count and restart the timer. This would effectively measure the time between interrupts triggered by rising edges of the input pulsed waveform. The alternative method is to use the I/O pin as the input to a timer configured as a counter. A simple routine which stops the counter, sets its count to zero, starts the counter and allows it to accept input pulsed for a brief but long enough time before stopping it would allow the counter register to be used to store the measured number of pulses in the given brief delay period this simple routine would provide. This count would then indirectly represent the value of the unknown sensor capacitance (or resistance if your 555 timer circuit had a constant capacitance but a variable resistance - I.e. a variable resistance sensor). Spencer Yeralan and Helen Emery give some examples of this in their book "The 8051 Cookbook for Assembly and C with Experiments in Mechatronics and Robotics" by Rigel Press first edition Feb 2000. Adapting this to a Raspberry Pi with a voltage divider circuit is a great suggestion from the poster of the original question!

  • Welcome to the Raspberry Pi StackExchange! Your answer seems very detailed, and contains good references, but is very difficult to read since it isn't formatted. If you could break the question into a few paragraphs, it would tremendously improve the quality of your answer. – Jacobm001 Dec 27 '15 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.