4-20ma current loop transmitter: RaspberryPi

Does anyone have any example code using the 4-20ma current loop transmitter with RaspberryPI?
I do not find any reference material for the device control codes anywhere. I am a newby, so sorting through what seem to be unrelated documents has been frustrating, to say the least!

I am trying to use the PR33-26, 1-channel 4-20mA current loop transmitter I2C mini module with PR2-1 I2C shield for Raspberry PI on a Pi3+. The tranmitter shows up at 0x60 as expected, but I do not seem to be able to generate current. I am uncertain of the address to use for reg_write_dac in my command:
bus.write_i2c_block_data(0x60, reg_write_dac, answer)

Any help will be appreciated.

Here is an arduino code which can be converted into python to use with pi.

you can find the wiring diagram on the product page under resources tab.


Dear Bhaskar,
My question is more or less the same as the one Paul1 asked back in Oct '18. But my limited abilities does not allow me to interepret the Arduino code in terms of Python code and dac addreses (and how to find them).

In this post: Pr38 / pecmac6xxx, you have linked to a piece of code which seems to do more or less the same as in the example above, but 1) in python using SMbus and 2) with another DAC.

Will you be able to provide any pointers or hints on how to get this up and running on Rpi?

I’ve got myself one of these: https://store.ncd.io/product/1-channel-isolated-4-20ma-current-loop-transmitter-with-power/


I believe this code should work


Dear Bhaskar,

Thank you very much - that code does indeed run. However I do not measure anything on the output sockets.

According to the Arduino example you provided above in your first reply to this post, it is mentioned that the data should be between 290 and 4095 and be incremented in steps of 100 for a 4-20mA output range. I have have modified your example above to this (the one above did not generate any output either):

import smbus
import time

bus = smbus.SMBus(1)
while True:
for i in range(290,4095,100):
data1 = (i>>4)
data2 = (i&15)<<4
data = [data1, data2]
bus.write_i2c_block_data(0x60, 0x41, data)
print ("Writing on DAC %d DAC value " %i)

I have access to a bus analyser which provides me with this:

Do I need to move the pull up jumpers?

Again any hint or pointer to where I should look or do to get a 4-20mA output on the out sockets will be greatly appreciated.


i will recommend checking your wiring. A wiring diagram can be found on product pager under wiring or resources section.


Turns out the error is on my side :roll_eyes: - it works as intended. Apparently I got the SKU: PR33-26 and not the SKU: PR33-49. So after attaching a power supply as per the “correct” wiring diagram it works quite well.

So now it is just a matter of adjusting the DAC input to get the desired values out.

However - the next question about the broken board still stands.

Edit: Removed post exposing the noobness of yours truly.

Hi Bhaskar,

When I placed my order I ordered two shields and two transmitters. I have now tried with the second transmitter. First I wanted to make sure that I got the correct address for the device so I ran “i2cdetect -y 1” adn got the address to 0x61. So I changed the above code accordingly and ran it. It ran for a few seconds before returning with an I/O error (121). So I ran the i2cdetect again and got the address 0x60. Doing this again and again gave me this (notice the seconds on the data command output):

Is this, the second, board broken?


Not sure why its doing this …
I will recommend installing the address jumper and running the code with 0x61.