Sensor and microprocessor

Has anyone been able to successfully use the sensor MP-7217-TC to find methane content in gas?

Interesting question, as I would suggest the manufacturer is best able to answer that question. Looks like it would be finicky, but then many sensors are. What circuit configurations have you tried? Or are you asking before you purchase one?

I bought the sensor last year and tried connecting it to an arduino. I couldn't manage to get a reading from it that made sense. There were some previous posts but unable to contact the authors directly so I am hoping they might see it and get in contact.

I followed their circuit configuration
arduino|690x477

The sensor info is here: https://www.sgxsensortech.com/content/uploads/2014/08/AN151-MP-7217-TC-Build-and-Operation.pdf

also using this dc-dc step down moduel

How did you power it and how did you connect it to your Arduino? (schematic pls) Which Arduino?

Did you notice that sensor is a Wheatstone bridge, with differential output from 0 mV to 120 mV, and a common mode voltage of 1.5v?

Hi, @mahullc
Welcome to the forum.

@mahullc diagram

Did you have any Methane to test the sensor?

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi Dave! Thanks for your reply.
I should probably clarify that my understanding of electronics is very limited, I am able to connect sensors to an arduino and find documentation online to use them but anything outside of that is new territory for me. I am using an arduino mega. I will have to read a bit more about this wheatstone bridge since this is a new concept to me.

This is the schematic with my little understanding so I hope it makes sense.


The parts are:

  1. Relay: https://www.jaycar.co.nz/arduino-compatible-5v-relay-board/p/XC4419?pos=3&queryId=05cdd913a3fb8213ad9e4806f3c855c6&sort=relevance&searchText=relay
    2.Gain amplifier: ADS1015 12-Bit ADC - 4 Channel Programmable Gain Amplifier - Adafruit | Evelta
  2. DC-DC converter: DC-DC Adjustable Step-Down Module - LM2596 IN 4.5-40V OUT 1.5-35V - Sound Division & Surplustronics

I used this code:

#include <Adafruit_ADS1X15.h>

//Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use this for the 12-bit version */

void setup(void)
{
  Serial.begin(9600);
  //Serial.println("Hello!");

  Serial.println("Getting single-ended readings from AIN0..3");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");

  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV

  if (!ads.begin()) {
    Serial.println("Failed to initialize ADS.");
    while (1);
  }
}

void loop(void)
{
  int16_t adc0, adc1, adc2, adc3;
  float volts0, volts1, volts2, volts3;
  ads.setGain(GAIN_TWO);
  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);

I had help putting this together, but don't have access to it anymore. I am going back to this and trying to see if i can make it work. When I tried this last year, I placed the sensor in contact with natural gas and then flushed with nitrogen. I was trying to get a stable reading, but eveytime I did this I would get a different reading from both pure nitrogen and natural gas.

Hi Tom! Australia cool, I'm in New Zealand, small world afterall.
I have just posted the hand drawn schematic in my latest comment, hope it helps. I have access to both natural gas and methane in a bottle with a known concentration. I am also able to have access to this instrument to compare readings: https://nzsafetyblackwoods.co.nz/en/geotech-portable-landfill-gas-anaylser-each--481337?gclid=CjwKCAiAl9efBhAkEiwA4ToripAAHlFwbqYwNNwSOqVvawXhgI5RPcGFFhqXzXr6y30ThYAU1fZ02BoClx4QAvD_BwE

I just want to have this up an running before I calibrate it. Any help is much appreciated

Hi,
Thanks for the diagram,
Your circuit does not show the resistor divider the typical circuit for your sensor shows for the gas output,

You really need to go back to basics and write simple code for each sensor input.
Is there a reason to got to 12bit ADC?

What is PGA?
Replace the sensor with a 10K potentiometer so you can aplly constant values and make sure your code and hardware are stable.

I presume you are using a UNO controller.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Thanks for your help Tom.

My understanding of electronics is very basic so please bare with me. I am actually not sure that we did the resistor divider part in the circuit. Unless the ADS1115 acts as a resistor divider? How would you recommend adding the divider to the circuit?
We used 12bit ADC to get better precision of the values. Not sure what PGA stands for it was just part of the component name.

I will try the potentiometer, would something like this suit? https://www.jaycar.co.nz/10k-ohm-linear-b-single-gang-24mm-potentiometer/p/RP3510
What are the pin connections normally, 5V, GND and signal or something else?

I am using a MEGA controller, but have access to a UNO if that helps in any way.

Thanks Tom

Hi,
Yes that pot would be fine.
Mega is okay.

What is the accuracy of your sensor, it would be a waste of resources if your sensor was 1% accurate and you wanted 0.01% precision.

Tom.. :smiley: :+1: :coffee: :australia:

Hi,
I'm no expert but the sensor can only work on one mode at a time.

So are you selecting Temp mode then reading the temp signal.
Then selecting Gas then reading the gas signal.

To make things easier to help develop your project, I would remove the 12bit ADC and use the Mega ADC to get your code working at selecting the two modes and reading the appropriate Mega analog input.

Your code would be simpler, which is what you need when developing code, do it in stages.

Tom... :smiley: :+1: :coffee: :australia:

For best results:

  • add a resistor divider (R1 and R2) as shown in the screenshot below from the datasheet. Use precision resistors with low temperature coefficient.
  • add the zero adjust (R3, 4, 5) later if needed
  • connect both parts of the "output" to your ADS1115: the center of the resistor divider goes to one ADS pin, and pin 1 of the sensor goes to another ADS pin
  • use the ADS1115 in differential mode

image

PS:

  • No, the ADS1115 doesn't act as a resistor divider. You need to add that, as shown in the screenshot.
  • PGA = programmable gain amplifier... The "gain" is set in your code.
  • Note the datasheet also says:
    image
  • For testing the sensor, I would temporarily eliminate the relay and code related to the relay. Once you get the sensor working, then add those back in.
  • Note the Absolute Maximum = 3.2 v Be very careful not to exceed that.
    image

Hi Tom, the sensor is 3% +/- . I am not in look for a 1% precision, mainly a guideline of content which it is ok for it to be this precise.

@DaveEvans

I went ahead and connected the resistors as you suggested with some normal resistors just to give it a go while I wait for the high precision low temperature coefficient ones to arrive. It seems to be within a reasonable reading range the difference between the wheatstone bridge voltage and the sensor voltage.

In terms of temperature, the sensor has given me readings of 30 to 50 C which I know are not correct as I have a thermometer that shows me the ambient temperature. Would this setup with the new resistors have any influence in this temperature reading? I wouldn't think so but I am trying to understand why I am getting this temperature reading.

No. See the figure in post #6. There's no connection between the two outputs.

How are you reading the temperature output? Probably the simplest way would be use the Arduino's stable internal analog 1.1v reference voltage, and then calibrate (since although the internal reference is stable, it is not necessarily accurate). That should help.

The ADC unit has 4 analog ports. I have A0 connected to the methane output, A1 to the Wheatstone bridge, A2 connected to GND and A3 connected to temperature. The GND reading is 0.26 V and the temperature output is 0.74V. By using the formula given:
image
with 0.74V I get 50.56 C.
This is my code

#include <Adafruit_ADS1X15.h>

//Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
Adafruit_ADS1015 ads;     /* Use this for the 12-bit version */

void setup(void)
{
  Serial.begin(9600);
  //Serial.println("Hello!");

  Serial.println("Getting single-ended readings from AIN0..3");
  Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");

  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
  // ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV

  if (!ads.begin()) {
    Serial.println("Failed to initialize ADS.");
    while (1);
  }
}

void loop(void)
{
  int16_t adc0, adc1, adc2, adc3;
  float volts0, volts1, volts2, volts3;
  ads.setGain(GAIN_TWO);
  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);

  volts0 = ads.computeVolts(adc0);
  volts1 = ads.computeVolts(adc1);
  volts2 = ads.computeVolts(adc2);
  volts3 = ads.computeVolts(adc3);

  Serial.println("-----------------------------------------------------------");
  Serial.print("AIN0: "); Serial.print(adc0); Serial.print("  "); Serial.print(volts0); Serial.println("V");
  Serial.print("AIN1: "); Serial.print(adc1); Serial.print("  "); Serial.print(volts1); Serial.println("V");
  Serial.print("AIN2: "); Serial.print(adc2); Serial.print("  "); Serial.print(volts2); Serial.println("V");
  Serial.print("AIN3: "); Serial.print(adc3); Serial.print("  "); Serial.print(volts3); Serial.println("V");

  delay(1000);
}

No thanks. This is not a nudist forum...

Uncomment this line in setup(), and remove the one from loop().
Gain_two (~2volt) might be too low for the sensor.

I would use a 3volt LDO to power this sensor, powered from 5volt, not a noisy/unstable switching converter. I would not use a voltage divider for the bridge, but simply subtract a fixed value to zero the sensor. I would not use a relay. A voltage divider (level converter) to 3volt will do the same. Could use 10k:15k. I would read the temp sensor with another channel of the ADS.

Seems irrelevant. If you want to know gas percentage and temperature, then convert direct from A/D value to % and degrees.
Leo..

Edit:
The fixed value to subtract (not using a half-bridge) for an ADS1015 (11-bit single-ended) is

2048 (11-bit) / 2 (half-bridge) * 3.0 (if supply is 3volt) / 4.096 (gain_two) = 750.

Then this line is all you need.
int sensorValue = ads.reawdADC_SingleEnded(0) - 750;

@Wawa thanks for the post. I have ordered the parts. I am unclear as to what you mean by read the temp sensor with another channel of the ADS? There are only 4 inputs and I am using methane and temperature on 2 different ones.

:confused:

According to the datasheet, the differential voltage across the "OUTPUT" of the bridge shown in post #13 varies from -20mV to +120mV.

So with the ADS in differential mode, as I suggested, a gain of 16 could be used (FSR +/-0.256 mV), for which the LSB is 0.125mV, giving 1120 steps across full scale (140/0.125).

And presumably the voltage at pin 1 in post #13 WRT to ground varies from 1.48v to 1.62v (1.5 - 0.02 and 1.5 + 0.12), so in single-ended mode with a gain of 2 (FSR 0v to 2.0v), for which the LSB is 2 mV, there will be only 280 steps across full scale.

And with a gain of 1 (not necessary unless grossly unbalanced), only 140 steps.

So it seems the recommended circuit shown in post #13 with the ADS operated in differential mode would give much better resolution than as half bridge with single-ended.

What am I missing?