Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Simplify IoT Development.

Moderators: lily.li, violet, seth.welday

Post Reply
luqman
Pre-kindergarten
Pre-kindergarten
Posts: 1
Joined: Sun Mar 03, 2019 3:58 pm

Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Post by luqman » Fri Apr 12, 2019 12:58 am

Hi,

I try to interface multichannel gas sensor using Wio GPS/GSM Tracker (based on ATSAM21D). I setup a very basic source code copied from example
and make some modification on serial channel (from Serial to SerialUSB). However, it looks like the Wio GPS Tracker failed to operate. No output from serial monitor. Here is my source code.

Code: Select all

#include <Wire.h>
#include "MutichannelGasSensor.h"

#define SENSOR_ADDR 0X04

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(115200);
  SerialUSB.println("Setup");
  gas.begin(SENSOR_ADDR);
}

void loop() {
  // put your main code here, to run repeatedly:
  float R0_NH3, R0_CO, R0_NO2;
    float Rs_NH3, Rs_CO, Rs_NO2;
    float ratio_NH3, ratio_CO, ratio_NO2;
    
    R0_NH3 = gas.getR0(0);
    R0_CO  = gas.getR0(1);
    R0_NO2 = gas.getR0(2);
    
    Rs_NH3 = gas.getRs(0);
    Rs_CO  = gas.getRs(1);
    Rs_NO2 = gas.getRs(2);
    
    ratio_NH3 = Rs_NH3/R0_NH3;
    ratio_CO  = Rs_CO/R0_CO;
    ratio_NO2 = Rs_NH3/R0_NO2;
    
    SerialUSB.println("R0:");
    SerialUSB.print(R0_NH3);
    SerialUSB.print('\t');
    SerialUSB.print(R0_CO);
    SerialUSB.print('\t');
    SerialUSB.println(R0_NO2);
    
    SerialUSB.println("Rs:");
    SerialUSB.print(Rs_NH3);
    SerialUSB.print('\t');
    SerialUSB.print(Rs_CO);
    SerialUSB.print('\t');
    SerialUSB.println(Rs_NO2);
    
    SerialUSB.println("ratio:");
    SerialUSB.print(ratio_NH3);
    SerialUSB.print('\t');
    SerialUSB.print(ratio_CO);
    SerialUSB.print('\t');
    SerialUSB.println(ratio_NO2);

    SerialUSB.println("------------------------");
    delay(1000);
}

bill.yu
Elementary-4
Elementary-4
Posts: 420
Joined: Mon Apr 02, 2018 11:05 am

Re: Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Post by bill.yu » Thu Apr 18, 2019 5:27 pm

HI there,

It is related with wire library compatibility issue. I did several changes, but it still does not work. I just post it here and if any other people can help solve the issue. My sensor is version 1, i modify the code and library. the com port can display the message, but the reading is invalid. I did not get the wire working. thanks.

1. please comment out the version checking in gas.begin() and the whole library. 
2. please make sure the cpp file also changes the serial. to serialusb. 
3. I just take a quick look that the code missed the gas.powerOn.   
4. If you want to use the on-board Grove connector, please use digitalWrite(12, HIGH) to open 3V3_B. Otherwise you can't provide power to Grove modules.

Code: Select all

#include <Wire.h>
#include "MutichannelGasSensor.h"

void setup()
{
    digitalWrite(12, OUTPUT);
    digitalWrite(12, HIGH);
    SerialUSB.begin(115200);  // start serial for output
    SerialUSB.println("power on!");
    delay(5000);
    gas.begin(0x04);//the default I2C address of the slave is 0x04
    gas.powerOn();
    delay(5000);
    SerialUSB.print("Firmware Version = ");
    SerialUSB.println(gas.getVersion());
}

void loop()
{
    float c;

    c = gas.measure_NH3();
    SerialUSB.print("The concentration of NH3 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_CO();
    SerialUSB.print("The concentration of CO is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_NO2();
    SerialUSB.print("The concentration of NO2 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_C3H8();
    SerialUSB.print("The concentration of C3H8 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_C4H10();
    SerialUSB.print("The concentration of C4H10 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_CH4();
    SerialUSB.print("The concentration of CH4 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_H2();
    SerialUSB.print("The concentration of H2 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    c = gas.measure_C2H5OH();
    SerialUSB.print("The concentration of C2H5OH is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");

    delay(1000);
    SerialUSB.println("...");
}
https://github.com/SeeedDocument/forum_ ... %20(3).zip

Post Reply