Electrical Characteristic Sensors

 General audience classification icon  General audience classification icon
Electrical characteristic sensors measure the voltage and amperage of the electric current. When the voltage and current sensors are used concurrently, the device's consumed power can be determined. Electrical characteristic sensors can also determine whether the device's circuit is working correctly. Different sensor circuits must be used to measure direct current (DC) and alternating current (AC). For safety reasons, the parameters of the mains must be measured using transformers.

Potentiometer

A potentiometer is a type of resistor whose resistance can be adjusted using a mechanical lever. The device consists of three terminals. The resistor between the first and the third terminal has a fixed value, but the second terminal is connected to the lever. Whenever the lever is turned, a slider of the resistor is moved; it changes the resistance between the second terminal and side terminals. Variable resistance causes the change of the voltage, which can be measured to determine the position of the lever. Thus, the potentiometer output is an analogue value.
Potentiometers are commonly used as a control level, for example, a volume level for the sound and joystick position. They can also be used to determine the angle in feedback loops with motors, such as servo motors. The potentiometer symbol is present in figure 1, a device in figure 2 and a connection to the Arduino board in figure 3.

 Symbol of a potentiometer
Figure 1: A symbol of a potentiometer
 Potentiometer
Figure 2: A potentiometer
 Arduino and potentiometer circuit
Figure 3: Arduino and potentiometer circuit

An example code:

//Potentiometer sensor output is connected to the analogue A0 pin
int potentioPin = A0; 
//The analogue reading from the potentiometer output
int potentioReading;      
 
void setup(void) {
  //Begin serial communication
  Serial.begin(9600);   
  //Initialize the potentiometer analogue pin as an input
  pinMode(potentioPin, INPUT); 
}
 
void loop(void) {
  //Read the analogue value of the potentiometer sensor
  potentioReading = analogRead(potentioPin); 
  Serial.print("Potentiometer reading = "); //Print out
  Serial.println(potentioReading);
  delay(10);
}
Voltage Sensor

A voltage sensor is a device or circuit for voltage measurement. A simple DC (direct current) voltage sensor consists of a voltage divider circuit with an optional amplifier for a tiny voltage measure. For measuring the AC (alternating current), the input is connected to the rectifier diode or bridge to rectify AC to DC and a capacitor to flatten the voltage. The resulting voltage can be measured with an analogue digital converter of the microcontroller. For safety, while measuring the mains voltage, an optoelectrical isolator should be added at the output, or a transformer should lower the voltage at the input.
A voltage sensor can detect a power failure and measure if the voltage is in the range required. IoT applications include monitoring appliances, power lines, and power supplies.
Sample voltage sensor module is present in figure 4 and schematic connection to the Arduino Uno in figure 5.

 Voltage sensor module 0–25 V
Figure 4: Voltage sensor module 0–25 V
 Arduino and voltage sensor schematics
Figure 5: Arduino and voltage sensor schematics

The example code:

//Define an analogue A1 pin for voltage sensor
int voltagePin = A1; 
//The result of the analogue reading from the voltage sensor
int voltageReading;  
 
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; //  30 kΩ resistor 
float R2 = 7500.0; //  7.5 kΩ resistor
 
void setup()
{
    //Begin serial communication
    Serial.begin(9600);  
    //Initialize the analogue pin as an input
    pinMode(voltagePin, INPUT); 
}
 
void loop()
{
    //Read the value of the voltage sensor
    voltageReading = analogRead(voltagePin); 
    vout = (voltageReading * 5.0) / 1024.0;
    vin = vout / (R2/(R1+R2));
 
    Serial.print("Voltage is: ");
    //Print out the value of the voltage to the serial monitor
    Serial.println(vin); 
    delay(10); //Short delay
}
Current Sensor

A current sensor is a device or a circuit for current measurement. A simple DC sensor consists of a high-power resistor with low resistance. The current value is obtained by measuring the voltage on the resistor and applying a formula derived from Ohm's law. Other non-invasive measurement methods involve hall effect sensors for DC and AC and inductive coils (current transformer) for AC.
Current sensors determine the power consumption and detect whether the device is turned on or shorted.
Sample current sensor modules are present in figures 6 and 7, and schematic connection to the Arduino Uno in figure 8

 Current transformer module for AC
Figure 6: Current transformer module for AC
 Analogue current meter module 0–50 A
Figure 7: Analogue current meter module 0–50 A
 Arduino and current sensor module schematics
Figure 8: Arduino and current sensor module schematics

The example code:

//Define an analogue A0 pin for current sensor
const int currentPin = A0; 
//Scale factor of the sensor use 100 for 20 A Module and 66 for 30 A Module
int mVperAmp = 185; 
int currentReading;
int ACSoffset = 2500; 
double voltage;
double current;
 
void setup(){ 
 Serial.begin(9600);
}
 
void loop(){
 
 currentReading = analogRead(currentPin);
 Voltage = (currentReading / 1024.0) * 5000; //Gets you mV
 Current = ((Voltage - ACSoffset) / mVperAmp); //Calculating current value
 
 Serial.print("Raw Value = " ); //Shows pre-scaled value 
 Serial.print(currentReading); 
 Serial.print("\t Current = "); //Shows the voltage measured
 //The '3' after current allows to display 3 digits after the decimal point
 Serial.println(Current,3); 
 delay(1000); //Short delay
en/iot-open/hardware2/sensors_electric.txt · Last modified: 2024/05/27 11:58 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0