How to connect a fertilizer meter to Raspberry Pi

We’re new to Raspberry Pi and would like to ask how we can connect a fertilizer meter to Raspberry Pi.
The meter is a mechanical unit which sends an electric pulse every X seconds.
We’d like connect to it - open it (like a solenoid) and after Y pulses close it.
The meter pulse output current is 4-20 milliampere.
Thank you, Ruth

To interface a 4-20mA current loop device to a MCU you need to know the voltage used to drive that current loop. Then you can calculate the resistance required across the output to create the voltage drop that the MCU responds to - either 3.3V or 5V. The values don’t have to be exact because the MCU inputs have a fairly wide response range, but you need to be careful that the voltage does not exceed the maximum input voltage allowed for the MCU. If you can measure the output voltage of that meter then someone can calculate a suitable resistance for whatever MCU you choose.
For the solenoid to open and close the spreader the detail part is the mechanical design of the shutter. Operating the solenoid is relatively simple - See here for a description:

The process is essentially the same for any of the popular MCUs.

1 Like

Hi, which fertilizer meter do you wish to use? Is there any link?

Hi Jeff
I think if the 4 - 20mA loop is done properly the source voltage will adjust to suit the loop resistance, ie; a constant current supply.
Therefore if your high level is 5V you would need a 250Ω resistor to drop 5V @ 20mA which would be 1V @ 4mA so you would see a change from 1V to 5V at the MCU input.
If you are nervous about this insert another resistor in series with the 250Ω and the supply will adjust to compensate and will still supply 20mA as long as it is still in the range of the original supply. But whatever you do you will need 250Ω to obtain 5V or 165Ω will provide 3.3V to 0.66V swing.
Cheers Bob

Sorry, must have had some sort of a brain snap. The above would only work if the negative side of the loop is grounded which you probably could not guarantee.
The safest method to interface would be an opto coupler. Connect the opto LED into the loop making sure that it is capable of 20mA then use this output to switch a local 5V or 3.3V to the MCU. If the opto LED is more sensitive and does not require the 20mA, a resistor will have to be calculated to connect IN PARALLEL across the LED to bypass excess current. The TOTAL must be 20mA.

Hi Ruth,

Can you maybe send a link of the Fertilizer meter you plan on using for this project? Knowing the exact meter you plan on using will make it easier for someone to make a good input.