Libelium library
It is mandatory to include the 4-20 mA library when using this board. The following line must be introduced at the beginning of the code:
1
#include <currentLoop.h>
Copied!
Waspmote's API 4-20 mA files:
  • currentLoop.cpp
  • currentLoop.h
API's functions
Public functions:
Action realized:
uint8_t ON(uint8_t powerSupply)
Powers on the 4-20 mA supply (5 V or 12 V)
uint8_t OFF(uint8_t powerSupply)
Powers off the 4-20 mA supply (5 V or 12 V)
int readChannel(uint8_t channel)
Gets the sensor value in integer format
float readVoltage(uint8_t channel)
Gets the sensor value as a voltage
readCurrent(uint8_t channel, float offSet)
Gets the sensor value as a current in mA and introduce an offSet correction factor
float readCurrent(uint8_t channel)
Gets the sensor value as a current in mA
uint8_t isConnected(uint8_t channel)
Checks if the current loop is well connected
When using the Plug & Sense! 4-20 mA model, the correspondence between the board channels and the external sockets is defined like this:
  • channel 1 → socket A
  • channel 2 → socket B
  • channel 3 → socket C
  • channel 4 → socket D
This way, a Plug & Sense! user with a sensor on socket A (channel 1 of the 4-20 mA sensor board) will use the next line to read it:
1
int value = currentLoopBoard.readChannel(SOCKET_A);
Copied!
Last modified 1yr ago
Copy link