Introduction
In this post, it will be seen how to calculate the value raised to a power. Basically, this function takes a number(base) and it raises to another number(exponent).
The function for calculating the value raised to a power using Arduino IDE is pow(). This function is used to raise a number to a certain exponent.
Function
pow(base, exponent)
Parameters
base: the number (float)
exponent: the power to which the base is raised (float)
Example
float i=0;
long result;
void(setup){
Serial.begin(9600L);
}
void(loop){
Serial.println("Base 2: ");
for(i=0;i<50;i++){
result=pow(2,i);
Serial.println(result);
}
Take it further
Calculations are useful when they run on real signals. See three examples that turn raw readings into values: a current clamp, energy meters and 4-20 mA sensors.
Case study
Read the current with a clamp. Cut it at the limit.
A clamp sensor on an analog input, one Arduino based PLC with a relay that cuts the current on an anomaly, and a Panel PC.
Read the case study
Simulator
Read your energy meters from a PLC, per machine and per shift
An ESP32 PLC 21 CORE reads six machine meters over Modbus RTU and the main meter over Modbus TCP, and splits the kWh by shift.
Open the simulator
PLC Solution Library
Reading 4-20 mA pressure and temperature sensors on an ESP32 PLC
A two-line linear map converts the raw readings to engineering units, and any sensor whose loop current drops below 4 mA is flagged.
See the example