I have a cable-extension position transducer (more info here: transducer manual). I would like to read off the inches or mm that the cable extends. The question I have is more about the way that you connect a 2 wire 4-20ma and read it off through the photon. Specifically the place for reading an analog signal from the circuit. This page is helpful but I haven’t been able to implement it yet.
The main problem I see is the device runs on 8-40 Vdc on the red wire, so I guess the photon isn’t able to power this application. Which means untill I take care of that this may not work. Although I’m new to the photon so maybe i’m wrong there.
Picture of the important wiring info:
If anyone knows of a good example for this type of project I would greatly appreciate that.
This is the code I have been using so far to tinker with this, although there are probably many missing or wrong things here due to my novice writing ability.
int PositionTransducerPin = A0;
int PositionReading = 0;
int LiftPosition = 0;
void setup()
{
Particle.variable("Position", &PositionReading, INT);
}
void loop()
{
PositionReading = analogRead(PositionTransducerPin);
LiftPosition = map(PositionReading, 0, 4095, 0, 255);
Particle.publish("Position", String(LiftPosition));
delay(1500);
}