Library functions
Library constructor
To start using Waspmote 4-20 mA library, an object from class currentLoop
must be created. This object, called currentLoopBoard
, is created inside Waspmote 4-20 mA library and it is public to all libraries. It is used through this guide to show how Waspmote 4-20 mA library works. When creating this constructor, all the variables are defined with an initial value by default.
Switching the board on
The 4-20 mA Board includes a 12 V output that can be used to supply sensors, and can be controlled from the library functions, by a digital pin of Waspmote. The electronic measurement circuits use the 5 V power (so it is always mandatory to switch this option on), and is necessary to switch on this power supply before getting data from the sensors.
On the other hand, it is only necessary to switch the 12 V on when we want to power 3rd party sensors.
Example of use:
See an example of use here: https://development.libelium.com/4-20-ma-01-current-loop-basic/
Switching the board off
This function can be used to switch OFF the power supplies of the 4-20 mA Board. The 12 V and 5 V power supplies must be switched off separately as shown in the next example.
Example of use:
Reading data
The 4-20 mA library includes the necessary functions to read data in several formats. The 4-20 mA standard sends the sensor information as a current, and this information can be transformed in voltage with a simple conversion function.
Example of use:
Sometimes, it is necessary to introduce a correction factor to correct offset deviations in the measurement process. The next function can be used for this:
See an example of use here: https://development.libelium.com/4-20-ma-01-current-loop-basic/
Current loop state
One of the most important features of the 4-20 mA standard is the possibility of detecting a broken wire or failed instrument. The 4-20 mA library includes a function to detect the current state of the line.
Example of use:
See an example of use here: https://development.libelium.com/4-20-ma-02-current-loop-connection-state/
Last updated