Trying to get an SPI board to interface with the Arduino

Hi all,

Looking for some aid. Basically, I am trying to convert a voltage sensor input (0.5 - 4.5v) to a 4-20mA voltage loop sensor output, so the Arduino basically acts as a 4-20mA sensor. I have done research and found a device that allows for this capability, the 4-20ma Click found here: 4-20mA T Click - Add-on board with XTR116 4-20mA transmiter.

However, I am unsure how to interface each board together and write the code to get the PWM output to become the 4-20ma loop output. I have connected each board correctly together using the pins stated (CS, SCK , MISO , MOSI ) but cannot seem to get a current out.

So finally my question is; how do write the code that allows interfacing between these two boards. Please take a look at my program to see how I have attempted to do it(I have no idea :sweat_smile: )

const int analogInPin = A0;  // Analog input pin that the sensor is attached to
const int analogOutPin1 = 10; // Analog output pin

int sensorValue1HP = 0;
int output = 0;

#include <SPI.h>

void setup() {

  pinMode(SS, OUTPUT);
  Serial.begin(9600);                                     // initialize serial communications at 9600 bps:


void loop() {
  // put your main code here, to run repeatedly:
  sensorValue1HP = analogRead(analogInPin);
  Serial.print(" ------ HP: ");
  analogWrite(analogOutPin1, sensorValue1HP);


Best regards


const int analogOutPin1 = 10; // Analog output pin

analogWrite(analogOutPin1, sensorValue1HP);

Pin 10 is the default SPI chip select pin. Print the SS variable and see. Pin 10 is a poor choice to use for analogWrite because it will interfere with SPI. Change analogOutPin1 to a different PWM capable pin.

Aren't you also suppose to be using the 4-20 mA R click with it ?
That's what their webpage says.


Is that all of your code? There are parts missing. Check the SPI examples.

Currently, the SS out (after changing the PWM write to pin 9) is 10 and does not change to the input (around 200 ish).

All I need is to write the PWM voltage out to the SPI out, any help would be appreciated.

EDIT ; Looked in that other board and I confirm that it is a stand-alone board for this purpose (the receiver is used in a different circumstance.