4-20me sensor into photon or electron

Hi all.

Firstly would like to say a big thanks to everyone on here who has helped me with my projects. Without your support I would proberbly still be blinking an led. :blush:

Ok so I would like to connect a 4-20ma pressure sensor in to my photon. Now the sensor is powered by 24volts and the photon takes 3.3volts as we know. So is it possible to just use a resistor to stop the voltage down to the required when though it will be a diffrent supply than what the photon is using or would I have to get some sort of concertos or sheild.

Thanks againโ€ฆBen


Hi @benjiiiiuk

I would recommend a linear opto coupler. That will also provide electrical isolation which you may or may not need.

Try these app notes for ideas:



Its been a long time since I have played with 4 - 20 ma transmitters. The sender will apply what every voltage is needed to develop the current that represents the data. For example a pressure transmitter that can read 0 to 100 psi will output 4 ma for 0 psi and 20 ma for 100 psi.

We can then read the voltage drop across a resistor that is in series with the current signal (i.e. 4 to 20 ma). I used to use a 100 ohm resistor and read the voltage drop with a voltmeter. Voltage = Current * Resistance.

4 ma x 100 ohm = 0.4 volts
20 ma x 100 ohm = 2.0 volts

The negative side of the resistor has to be tied to ground, the positive side to and Analog read pin.

AS ALWAYS check the voltage across the resistor with a voltmeter before hooking to a Photon, Just in case I am wrong or you make the wrong connections

You can then use a MAP function to change 0.4 to 2.0 volts to 0 to 100 psi.

Also like BKO said an opto isolator can provide a lot of protection.

Normally you donโ€™t see the 24 vdc unless you put the current through a say 1000 ohm resistor which would give you a 20 volt drop and fry the Photon.


Hi Ben, I am very new to the forum but found this link on the site I thought you would find useful. I just ordered my first kit and look forward to the struggle ahead. I am trying to do something similar and was wondering if you could share a link to the code you used to setup your Photon? I am so new any help is appreciated. Thank you so much, Tom

Link to particle post about 4-20ma

Link to product purchased to use on my test.