This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R: Development kit

Part Number: MSP432P401R
Other Parts Discussed in Thread: ENERGIA

I am trying to interface MQ-137 sensor to the board. I use Energia for writing the software. I found an article for Arduino board stating the calibration of the sensor which can be found here.  I have used the same code but changed the 5v reference to 3.3 and adc to 4095. However i am not able to get the value of Ro. I get it as 0.00 which is not possible. I wanted to know if anyone has interfaced MQ-137 to the kit. I have used a voltage divider to get 3.3volts out from analog output of the sensor which is then given to pin 4.5 which is an analog pin. It would be of great help if anyone has done such a project and can help.

Regards   I

  • Hello Rahul,

    I have forwarded your request to the subject matter expert. Give us some time to get back.

    Thanks,
    Sai
  • There is an issue with the addition of analog_value. The addition always results in 0. You can observe this by printing out analog_value in the loop. Not sure why this is though. The work-around is to declare analog_value as a global variable as shown in the Sketch below:

    /*
     * Program to measure the value of R0 for a know RL at fresh air condition
     * Program by: B.Aswinth Raj
     * Website: www.circuitdigest.com                                       
     * Dated: 28-12-2017
     */
    //This program works best at a fresh air room with temperaure Temp: 20℃, Humidity: 65%, O2 concentration 21% and when the value of Rl is 47K
    
    #define RL 47  //The value of resistor RL is 47K
    void setup() //Runs only once
    {
      Serial.begin(115200); //Initialise serial COM for displaying the value
    }
    
    float analog_value;
    void loop() {
    //  static float analog_value;
      float VRL;
      float Rs;
      float Ro;
      
      Serial.println("Test cycle:");
      
      for(int test_cycle = 1 ; test_cycle <= 500 ; test_cycle++) //Read the analog output of the sensor for 200 times
      {
        analog_value = analog_value + analogRead(27);; //add the values for 200
        Serial.println(analog_value);
      }
      analog_value = analog_value/500.0; //Take average
      VRL = analog_value*(5.0/1023.0); //Convert analog value to voltage
      //RS = ((Vc/VRL)-1)*RL is the formulae we obtained from datasheet
      Rs = ((5.0/VRL)-1) * RL;
      //RS/RO is 3.6 as we obtained from graph of datasheet
      Ro = Rs/3.6;
      Serial.print("Ro at fresh air = ");
      Serial.println(Ro); //Display calculated Ro
      delay(1000); //delay of 1sec
    }

  • While not strictly necessary, you might want to set analog_value to 0.0 before you get into the loop.

**Attention** This is a public forum