Equations for DO Sensor

HI! I just started using arduino recently and am trying to program the Arduino Uno board do calculate Dissolved Oxygen from a sensor with analog output. The DO depends on temperature so there is also a temperature equation that has an output of integer T. (The variables used are currently arbitrary numbers in order to get rid of error messages regarding those undefined letters!). Any help with formatting this equation would be great, here is the code:

#include <math.h>
int T (int RawADC) {
double Temp;
Temp=log(10000.0*((1024.0/RawADC-1)));
// = log(10000.0/(1024.0/RawADC-1))
Temp=1/(0.001405+(0.0002368+(0.0000001013TempTemp))*Temp);
Temp= Temp - 273.15;
return Temp;
}

double Oxygen (){
const int U=analogRead(1);
#define X 0.2095
#define N 1013
#define V 2
#define S 5
#define E 3
#define a 11
#define L X/N
#define W 200
#define K 273
float e=2.7182818284590452353602874713527;
b=e^((-173.4292)+((249.6339)(100/T))+(143.3483(ln(T/100)))-((21.8492)((T/100)))+((S)-0.033096+0.014259)-((0.0017)((T/100)^2)));
c=(a((analogRead(U)-V)(E))*((b)/(X(N-W))K));
i=(a((analogRead(U)-V)(E))
((100%)/(X(L-W))K));
W=(141.082
e^((3840.7)/(T))-((216961)/(T^2)));

}

Thank You!

What is the problem?

How is an analog reading const?

You also need to declare b,c,i,w.

   b=e^(

I can't believe an exclusive OR belongs there. Have a look at pow()

Please remember to use code tags when posting code

The exponential function is called exp(x), don't use pow....

floats only have 7 digits of precision. e is available as M_E as is pi as M_PI

[ Complex math is something other than you think BTW! ]

to use the M_E function, do i just put that in place of the e variable?

And for the exp(x) how do i use that function for a long equation like the ones I have with many variables and functions in the exponent?

The analog is reading analogPin 1 and using the output as a variable within the equation - i guess it is not a constant, but rather just an integer…

#include <math.h>
 int T (int RawADC) {
    double Temp;
    Temp=log(10000.0*((1024.0/RawADC-1)));
    //  = log(10000.0/(1024.0/RawADC-1))
    Temp=1/(0.001405+(0.0002368+(0.0000001013*Temp*Temp))*Temp);
    Temp= Temp - 273.15;
    return Temp;
  }

#include <math.h>
  double Oxygen (){
    int U=analogRead(1);
    #define X 0.2095
    #define N 1013
    #define V 2
    #define S 5
    #define E 3
    #define a 11
    #define L X/N
    #define W 200
    #define K 273
    float e=2.7182818284590452353602874713527;
    int b=e*exp((-173.4292)+((249.6339)(100/T))+(143.3483(ln(T/100)))-((21.8492)((T/100)))+((S)[-0.033096+0.014259](T/100))-((0.0017)((T/100)^2)));
    int c=(a((analogRead(U)-V)(E))*((b)/(X(N-W))*K));
    int i=(a((analogRead(U)-V)(E))*((100%)/(X(L-W))*K));
    int W=(141.082*e^((3840.7)/(T))-((216961)/(T^2)));
      
}

The main problem is that I am getting this as a return error, and I do not know how to solve it:

possible_profiler_code:23: error: invalid operands of types ‘int’ and ‘int ()(int)’ to binary ‘operator/’

You are stating that the function T returns an integer, but your return statement attempts to return a floating point value. Change one or the other to match.

int b=e*exp((-173.4292)+((249.6339)(100/T))+(143.3483(ln(T/100)))-((21.8492)((T/100)))+((S)[-0.033096+0.014259](T/100))-((0.0017)((T/100)^2)));
    int c=(a((analogRead(U)-V)(E))*((b)/(X(N-W))*K));
    int i=(a((analogRead(U)-V)(E))*((100%)/(X(L-W))*K));

The answer for b is unlikely to be meaningful as an int.

You should read the analog input once, and then use the number you get from that to calculation both c and i.

You seem to be calling a function called a( ), which doesn’t seem to exist in your code.

Unless there is a very special reason not to, your #include and #define directives should be at the top of your program.

What do you expect this part of the expression to mean

((249.6339)(100/T))

If you want to multiply things in C/C++, you have to use the multiply operator, *
You can’t just write two terms in your equation next to each other and expect them to be multiplied for you.

Instead of wasting your time and ours writing random gibberish, read a basic textbook or online tutorial on C/C++ language and syntax.

annmariehulver: to use the M_E function, do i just put that in place of the e variable?

And for the exp(x) how do i use that function for a long equation like the ones I have with many variables and functions in the exponent?

M_E is a constant, not a function, its e, the Euler's number (a.k.a. the base of natural logs)

exp(x) is the C way to say e-to-the-x

In C the '^' operator is nothing to do with exponentials, its bitwise XOR