[SOLVED] 4-20mA T Click board and Arduino (with code)

Hi all, I’ve bought a 4-20mA T Click board link and I found this sketch on LibStock:

const boolean outputToSerial = true;
const int multiplier = 1000;
const int slaveSelectPin = 10; // click SHIELD SLot 1 = D10, Slot 2 = D9
const float minCurrent = 4 * multiplier;
const float maxCurrent = 20 * multiplier;
const float minScaledCurrent = 800; //Not sure where this value came from
const float maxScaledCurrent = 4095; //four MSB of the MCP4921 are control bits, leaving 12 for data

float mAScaledF;
int mAScaled;
int mAScaledInt;
int mA;
byte mAScaled_Hi;
byte mAScaled_Lo;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  pinMode (11, OUTPUT);
  pinMode (13, OUTPUT);

  // initialize serial:
  if (outputToSerial) {

void loop() {
  for (mA = minCurrent; mA <= maxCurrent; mA++){  //Cycle from 4.000mA to 20.000mA in 0.001mA increments
    //The scaling formula below scales 4-20 to 800-4095
    mAScaledF = ((((float)mA - minCurrent) / (maxCurrent - minCurrent)) * (maxScaledCurrent - minScaledCurrent) + minScaledCurrent);
    mAScaled = (int) mAScaledF;
    mAScaled_Hi = (mAScaled >> 8) &0x0F;
    mAScaled_Hi |= 0x30;
    mAScaledInt = (mAScaled_Hi << 8);
    mAScaled_Lo = mAScaled;
    mAScaledInt |= mAScaled_Lo;
    // output values to serial port:
    if (outputToSerial) {
      Serial.print("mA = ");
      Serial.println((float)mA / multiplier);
      Serial.println(mAScaled, DEC);
      Serial.println(mAScaled, HEX);
      Serial.println(mAScaled, BIN);
      Serial.print("High Byte: ");
      Serial.print("Low Byte: ");

    // The standard Arduino SPI library cannot handle data larger than 8 bits
    // so we cannot make use of the SPI.transfer() function to send our packet.
    // Instead, we have to bit bang the value in using shiftOut().
    // Enable the slave device
    // Do this for MSBFIRST serial
    // shift out highbyte
    shiftOut(11, 13, MSBFIRST, (mAScaledInt >> 8));  
    // shift out lowbyte
    shiftOut(11, 13, MSBFIRST, mAScaledInt);
    // Disable the slave device


However, even if I’m sure that connections are good, there’s no output from the board.

I connected the VLOOP to a Proportional Valve but nothing happen (seems unconnected).

Am I supposed to provide additional voltage to the loop (between the valve and the t-click board)?

The valve itself is feeded with 24v.

Also, this image is present on the LibStock page of the board:

Valve is VPPM by FESTO;

EDIT: I had to provide Voltage to the loop, according to XTR Datasheet!

hi, i read your post about the 4-20 T click and you said you put a power supply to the loop. What voltage source did you use and how much current did it end up consuming? thanks.