Go Down

Topic: How to Calibrate LM35 / DHT11 / ACS712 -5A  (Read 5372 times) previous topic - next topic

abdullahmohamed

 Hi every body

how are you

I have an experiment using LM35 and ACS712  and DHT11  and i want to know what is the easiest method to calibrate each one of them . please?????????


DHT11 ill connect it directly to the bread board
LM35  i use it with wire  2 meter length - of course i use 2 resistance of 100 ohms each also capacitor 100nf

ACS712 - 5A also this one ill connect it directly to the breadboard .

thank you so much

TomGeorge

Hi,
If you look at the specs for each you will find that they have been factory calibrated to certain limits.

So if you read the specs they will tell you the output characteristics.

Tom..... :)
Everything runs on smoke, let the smoke out, it stops running....

abdullahmohamed

Hi,
If you look at the specs for each you will find that they have been factory calibrated to certain limits.

So if you read the specs they will tell you the output characteristics.

Tom..... :)
thanks for reply

actually i read the datasheets for all and i see that they are calibrate in factory but i mean what if i add wire for LM35  for 2 meter length ,,,, i think thats effect on the reading ( output voltage ) as the factory calibrated that 10mv for each 1C and when i compare the reading that i get from another equipment with the Vout i see that the Vout is less than should be with about (11-12 mv) .
so that im looking if there is any way or method that used from any one here before to calibrate such these sensor ????

TomGeorge

Hi,
If you have a thermometer to compare your reading with, and you believe it to be accurate, then use its value  and compare it to what your program says,

Do this at two or three different temperatures, one near 0DegC the other say at 30DegC.

If the difference is always the same amount of DegC then you modify your sketch to add or subtract the offset amount to get the correct temperature displayed.

If it the difference is not the same , then use the  map function to get a calibrated output, 
You will have to do some multiplication x10 before the map and /10 after the map if you are looking at 0.1DegC resolution, as map is an integer function.

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Wawa

#4
Jul 31, 2015, 11:57 pm Last Edit: Aug 01, 2015, 03:34 am by Wawa
Reading an LM35 is not influenced by 2meter of wire.

Don't expect an LM35 to be accurate below ~5 degrees C and above ~100 degrees C.

Don't use the "map" function.

The program used converts the digital value to degrees at some point.
There is a formule there. Change the value of that furmule.

The formule might look like: tempC = total * 0.00207617;

The number used was calculated for an ideal Aref, but your Arduino might be slightly different.
Change the last one, two, or maybe even three digits, to get the perfect reading.

Or MEASURE Aref, and calculate it.
It's in the code (0.001953125 * Vref in volts).
Enter the result in temp conversion the formule.
Leo..

abdullahmohamed

Reading an LM35 is not influenced by 2meter of wire.

Don't expect an LM35 to be accurate below ~5 degrees C and above ~100 degrees C.

Don't use the "map" function.

The program used converts the digital value to degrees at some point.
There is a formule there. Change the value of that furmule.

The formule might look like: tempC = total * 0.00207617;

The number used was calculated for an ideal Aref, but your Arduino might be slightly different.
Change the last one, two, or maybe even three digits, to get the perfect reading.

Or MEASURE Aref, and calculate it.
It's in the code (0.001953125 * Vref in volts).
Enter the result in temp conversion the formule.
Leo..
Thank you so much for reply
Please can you give me example for that .. Cuz i use the analog input for the arduino for all the sensor

Thank you again and i appreciate that

Wawa

#6
Aug 01, 2015, 06:40 am Last Edit: Aug 01, 2015, 06:42 am by Wawa
I don't know which sketch you have choosen to use.

Post it again, with all the changes you made.

If you use (INTERNAL) or (INTERNAL1V1), I have to know the exact voltage between Aref and ground.
Measured with a digital multimeter, set to 2volt DC.
It will be between 1.000 volt and 1.100 volt.

If you're NOT using (INTERNAL), but default Aref, then I also have to know that voltage, but it will be ~5volt.
Leo..

TomGeorge

Hi,
I would use map for   uncal DegC to calDegC.
Not DegF to DegC

The DHT11 is a digital output device.

Tom...... :)
Everything runs on smoke, let the smoke out, it stops running....

Wawa

That post was for the LM35 sensor only Tom.

I wrote the code and calculated a compound number based on several variables.

OP just has to calculate the magic maths number based on one unknown variable. Aref.

No experience with the DHT11 sensor, so I won't go there.
Leo..

abdullahmohamed

I don't know which sketch you have choosen to use.

Post it again, with all the changes you made.

If you use (INTERNAL) or (INTERNAL1V1), I have to know the exact voltage between Aref and ground.
Measured with a digital multimeter, set to 2volt DC.
It will be between 1.000 volt and 1.100 volt.

If you're NOT using (INTERNAL), but default Aref, then I also have to know that voltage, but it will be ~5volt.
Leo..
Code: [Select]
#define CURRENT_SENSOR A0 // Analog input pin that sensor is attached to
 
float amplitude_current;               //amplitude current
float effective_value;       //effective current
 
#define MAX_AV_READ  500        //n. read for average
const float SUPPLY_VOLTAGE = 500; // 5V * 100 (LM35 costant)

#define tA11  11      //Arduino analog input 0 connect to +out pin
#define tA12  12      //Arduino analog input 1 connect to -out pin
float tempf1;          //A0 read temp var
float tempf2;          //A1 read temp var
float tavgf;        //var need for calc celsius degrees
#define FCORR 0.5   // only for test if we don't have precision read
                    //because supply voltage is not exactly +5v
float temp1;
float temp2;
float temp3;
float temp4;
float temp5;
float temp6;
float temp7;
float temp8;
float temp9;

int temp1Pin =A1;
int temp2Pin = A2;
int temp3Pin = A3;
int temp4Pin = A4;
int temp5Pin = A5;
int temp6Pin = A6;
int temp7Pin = A7;
int temp8Pin = A8;
int temp9Pin = A9;

#define DHT11_PIN A13

#include <dht.h>

dht DHT;


void setup()
{
    Serial.begin(9600);
    pins_init();
    analogReference(DEFAULT);  // set voltage reference at default 5.0 V for Arduino 1
  Serial.println("ABDULLAH TEST USING ARDUINO MEGA 2560 ");
      Serial.println( );

      Serial.println( );
              Serial.println( );


Serial.print ( "Tempf1    Tempf2      Tavgf     Humidity %      TRoom      Temp1      Temp2      Temp3       Temp4       Temp5      Temp6     Temp7       Temp8     Temp9   current ");
   Serial.println( );
      Serial.println( );

}

void loop()
{
   int i;
 // because at328 analog read is unstable
 // we need an average from many read
 // I found in 500 read a good solution between precision
 // and speed
 // in debug mode you can apply a multimeter at
 // pin +out -out in schema for verify mV read from Arduino
 
 for(i=0;i<MAX_AV_READ;i++){
    tempf1 += analogRead(tA11) ;    //read +out sensor pin
    delay(5);                   //atmega need 10uS delay but we preferr 5mS
    tempf2 += analogRead(tA12) ;    //for full range scale -55 to + 155 C
    }                           //must read -out pin (virtual Vss)
   
  tempf1 /=MAX_AV_READ;   //average
  tempf2 /=MAX_AV_READ;   //average

  tavgf = tempf1 - tempf2 ;  //subtract virtual ground value
 // now we can calc celsius degrees
tavgf = ( tavgf * SUPPLY_VOLTAGE /1024) - FCORR;
temp1 = analogRead(temp1Pin);
temp1 = analogRead(temp1Pin);
temp2 = analogRead(temp2Pin);
temp2 = analogRead(temp2Pin);
temp3 = analogRead(temp3Pin);
temp3 = analogRead(temp3Pin);
temp4 = analogRead(temp4Pin);
temp4 = analogRead(temp4Pin);
temp5  = analogRead(temp5Pin);
temp5  = analogRead(temp5Pin);
temp6  = analogRead(temp6Pin);
temp6  = analogRead(temp6Pin);
temp7  = analogRead(temp7Pin);
temp7  = analogRead(temp7Pin);
temp8  = analogRead(temp8Pin);
temp8  = analogRead(temp8Pin);
temp9  = analogRead(temp9Pin);
temp9  = analogRead(temp9Pin);


temp1 = temp1 * 0.497;
temp2 = temp2 * 0.497;
temp3 = temp3 * 0.497;
temp4 = temp4 * 0.497;
temp5 = temp5 * 0.497;
temp6 = temp6 * 0.497;
temp7 = temp7 * 0.497;
temp8 = temp8 * 0.497;
temp9 = temp9 * 0.497;


  // READ DATA

  int chk = DHT.read11(DHT11_PIN );
  switch (chk)
  {
    case DHTLIB_OK: 
break;
    case DHTLIB_ERROR_CHECKSUM:
break;
    case DHTLIB_ERROR_TIMEOUT:
break;
    case DHTLIB_ERROR_CONNECT:
        break;
    case DHTLIB_ERROR_ACK_L:
        break;
    case DHTLIB_ERROR_ACK_H:
        break;
    default:
break;
  }Serial.print(tempf1);           //show mV reads at A11 input
Serial.print("       ");           //print space
Serial.print(tempf2);           //show mV reads at A12 input
Serial.print("        ");           //print space

//next show temperature in Celsius scale
Serial.print(tavgf);
Serial.print(" C ");

    Serial.print("         " );

  Serial.print(DHT.humidity, 1);
  Serial.print("          ");
    Serial.print(DHT.temperature, 1);

    Serial.print( "       ");


Serial.print(temp1);
    Serial.print( "      ");

Serial.print(temp2);
    Serial.print( "      ");

Serial.print(temp3);
    Serial.print( "       ");

Serial.print(temp4);
    Serial.print( "       ");

Serial.print(temp5);
    Serial.print( "      ");
      Serial.print(temp6);
    Serial.print( "    ");
Serial.print(temp7);
    Serial.print( "      ");
    Serial.print(temp8);
    Serial.print( "    ");
    Serial.print(temp9);
    Serial.print( "    ");
   
   
        Serial.println( );
        Serial.println( );
        Serial.println( );

    int sensor_max;
    sensor_max = getMaxValue();     
    Serial.println( );
        Serial.println( );

    Serial.print("sensor_max = ");
    Serial.println(sensor_max);
    //the VCC on the Grove interface of the sensor is 5v
    amplitude_current=(float)(sensor_max-512)/1024*5/185*1000000;// for 5A mode,you need to modify this with 20 A and 30A mode;
    effective_value=amplitude_current/1.414;
    //minimum_current=1/1024*5/185*1000000/1.414=18.7(mA)
    //Only for sinusoidal alternating current
    Serial.println("The amplitude of the current is(in mA)");
    Serial.println(amplitude_current,1);//Only one number after the decimal point
    Serial.println("The effective value of the current is(in mA)");
    Serial.println(effective_value,1);
            Serial.println( );
        Serial.println( );
        Serial.println( );

}
void pins_init()
{
    pinMode(CURRENT_SENSOR, INPUT);
}
/*Function: Sample for 1000ms and get the maximum value from the S pin*/
int getMaxValue()
{
    int sensorValue;             //value read from the sensor
    int sensorMax = 0;
    uint32_t start_time = millis();
    while((millis()-start_time) < 1000)//sample for 1000ms
    {
        sensorValue = analogRead(CURRENT_SENSOR);
        if (sensorValue > sensorMax)
        {
            /*record the maximum sensor value*/
            sensorMax = sensorValue;
        }
    }
    return sensorMax;


  delay(120000);
}
//
// END OF FILE
//


this is the full code that i use

Go Up