Noiasca Current Loop
A light weight Arduino library to read from current loop sensors (4mA - 20mA).
Public Member Functions | List of all members
CurrentLoopSensor Class Reference

Current Loop Sensor class. More...

#include <NoiascaCurrentLoop.h>

Public Member Functions

 CurrentLoopSensor (uint8_t pin, uint16_t resistor, byte vref, uint16_t maxValue, uint16_t adcResolution=1024)
 constructor for current loop sensor More...
 
int begin ()
 initialize sensor More...
 
void check ()
 check routine More...
 
int getAdc ()
 return result More...
 
int getValue ()
 return result do the measurement and return the result More...
 

Detailed Description

Current Loop Sensor class.

Constructor & Destructor Documentation

◆ CurrentLoopSensor()

CurrentLoopSensor::CurrentLoopSensor ( uint8_t  pin,
uint16_t  resistor,
byte  vref,
uint16_t  maxValue,
uint16_t  adcResolution = 1024 
)

constructor for current loop sensor

This constructor is used for a simple current loop sensor connected to one pin.

Parameters
pinthe GPIO
resistorthe Ohm value of the used resistor
vrefthe reference voltage of the ADC (i.e. the system voltage)
maxValuethe maximal output value of the sensor
adcResolutionthe resolution of the ADC. In case of an Arduino Uno 1024. Default 1024

Member Function Documentation

◆ begin()

int CurrentLoopSensor::begin ( )

initialize sensor

Start the sensor in setup()

Returns
1 on success

◆ check()

void CurrentLoopSensor::check ( )

check routine

run this function once to check the validity of your values

◆ getAdc()

int CurrentLoopSensor::getAdc ( )

return result

return the previous measured raw ADC value (for test purposes only)

Returns
the raw sensor reading from ADC

◆ getValue()

int CurrentLoopSensor::getValue ( )

return result do the measurement and return the result

Returns
the calculated sensor reading