Coding for vape sensor with Seeeduino cloud- please help!

Hi there,

I am creating a vape sensor for a school project... like a smoke detector but for vapes using the Gas Sensor and HCHO sensor. When the level of HCHO reaches 7 ppm, I want it to go off. I have it in the code as this:
return ppm(7)
But I get this error message:
Arduino: 1.8.13 (Windows 10), Board: "Seeeduino Wio Terminal, Master, Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off, On"

C:\Users\126939\Desktop\Fab Lab\Vape Sensor\2021_Seeed_SensorsExample\2021_SensorExample\2021_SensorExample.ino: In function 'double Get_HCH0()':

2021_SensorExample:32:10: error: 'ppm' was not declared in this scope

return ppm(0.5)

      ^~~

C:\Users\126939\Desktop\Fab Lab\Vape Sensor\2021_Seeed_SensorsExample\2021_SensorExample\2021_SensorExample.ino:32:10: note: suggested alternative: 'pwm'

return ppm(0.5)

      ^~~

      pwm

2021_SensorExample:33:1: error: expected ';' before '}' token

}

^

exit status 1

'ppm' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Can anyone help? Please?

I guess I should give you guys all the code. Here:
#include <math.h> //We need some math operations in the code
#include <Wire.h> //I2C Library
#include "MutichannelGasSensor.h"

//Sensors port definitions
//Note: The Multichannel Sensor doesnt need to be declared here, it is I2C
#define MQ3 A0
#define R0_MQ3 -0.02 //Note:Please run the calibrarion MQ3 code before to use this code//define calibration value for MQ3 here

#define HCHO A2 //Note:Please run the calibrarion HCH0 code before to use this code
//From that calibrarion you need to get the R0 value printed
#define Vc 4.95
#define R0_HCH0 -0.02 //Edit this to you own calibration value from the calibration code HCH0

double Get_HCH0(){ //Just call the function to get the value

int sensorvalue = analogRead(HCHO);
double Rs = (1023.0/sensorvalue)-1;

delay(500); //Adjust this value to your application
return ppm(7)
}
float Get_GasRatio_MQ3()
{

float sensor_volt;
float RS_gas; // Get value of RS in a GAS
int sensorValue = analogRead(MQ3);
sensor_volt=(float)sensorValue/1023*5.0;
RS_gas = (5.0-sensor_volt)/sensor_volt;
return RS_gas;

}
float Get_ratio_MQ3(float RS_gas)
{

float ratio = RS_gas/R0_MQ3;

return ratio;
}
void Multichannel_init()
{
gas.begin(0x04);//the default I2C address of the slave is 0x04
gas.powerOn();
Serial.print("Firmware Version = ");
Serial.println(gas.getVersion());
}
void Multichannel_Data_generation()
//This is going to print the values, if you want to handlee it
//You need to extract the variable C and send whatever you need
{

float c;

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

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

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

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

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

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

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

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

delay(1000);

}
void setup() {
Serial.begin(9600);
Multichannel_init();

}
//You just need to get focus in this part, the functions works alone, the data handle is
//what you need
void loop() {
double HCH0_sensor = Get_HCH0();
Serial.print("HCH0 ppm = ");
Serial.println(HCH0_sensor);

float MQ3_sensor = Get_GasRatio_MQ3();
Serial.print("MQ3 Gas ratio = ");
Serial.println(MQ3_sensor);

float MQ3_ratio = Get_ratio_MQ3(MQ3_sensor);
Serial.print("MQ3 ratio = ");
Serial.println(MQ3_ratio);

Multichannel_Data_generation(); //Print the values from the Multichannel

delay(1000);
}

No need to guess. Read the forum guide. That will tell you what you need to post and how you need to post it, in order for the forum members to be able to help you at all. So please read it and edit/fix both your posts above.

double Get_HCH0(){ //Just call the function to get the value

int sensorvalue = analogRead(HCHO);
double Rs = (1023.0/sensorvalue)-1;

delay(500); //Adjust this value to your application
return ppm(7)
}

The function you define here called Get_HCH0() calls another function called ppm(). But that function is not defined anywhere in your code, as far as I can see. Even if it was defined, I imagine it's purpose would be to transform the value read from the sensor into a reading in parts per million. But when this ppm() function is called, it is not passed the value from the sensor, it is only passed the fixed value 7, which makes no sense at all. Also, there is a ; missing from the end of that line, so even if ppm() was defined, the code would still give an error.

Can you please explain how you intended these functions to work?

Thanks very much for your help. I am trying to get the sensor to detect a certain amount of HCHO in the air, which is the Parts Per Million. Once it does, I want it to trigger the buzzer on the Wio Terminal. I just threw in 7 as an idea for how much HCHO.

Ok, let me know when you fixed your posts.

Hi there,

I am creating a vape sensor for a school project... like a smoke detector but for vapes using the Gas Sensor and HCHO sensor. When the level of HCHO reaches 7 ppm, I want it to go off. I have it in the code as this:

Here is my code:
include <math.h> //We need some math operations in the code
#include <Wire.h> //I2C Library
#include "MutichannelGasSensor.h"

//Sensors port definitions
//Note: The Multichannel Sensor doesnt need to be declared here, it is I2C
#define MQ3 A0
#define R0_MQ3 -0.02 //Note:Please run the calibrarion MQ3 code before to use this code//define calibration value for MQ3 here

#define HCHO A2 //Note:Please run the calibrarion HCH0 code before to use this code
//From that calibrarion you need to get the R0 value printed
#define Vc 4.95
#define R0_HCH0 -0.02 //Edit this to you own calibration value from the calibration code HCH0

double Get_HCH0(){ //Just call the function to get the value

int sensorvalue = analogRead(HCHO);
double Rs = (1023.0/sensorvalue)-1;

delay(500); //Adjust this value to your application
return ppm(7)
}
float Get_GasRatio_MQ3()
{

float sensor_volt;
float RS_gas; // Get value of RS in a GAS
int sensorValue = analogRead(MQ3);
sensor_volt=(float)sensorValue/1023*5.0;
RS_gas = (5.0-sensor_volt)/sensor_volt;
return RS_gas;

}
float Get_ratio_MQ3(float RS_gas)
{

float ratio = RS_gas/R0_MQ3;

return ratio;
}
void Multichannel_init()
{
gas.begin(0x04);//the default I2C address of the slave is 0x04
gas.powerOn();
Serial.print("Firmware Version = ");
Serial.println(gas.getVersion());
}
void Multichannel_Data_generation()
//This is going to print the values, if you want to handlee it
//You need to extract the variable C and send whatever you need
{

float c;

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

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

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

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

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

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

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

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

delay(1000);

}
void setup() {
Serial.begin(9600);
Multichannel_init();

}
//You just need to get focus in this part, the functions works alone, the data handle is
//what you need
void loop() {
double HCH0_sensor = Get_HCH0();
Serial.print("HCH0 ppm = ");
Serial.println(HCH0_sensor);

float MQ3_sensor = Get_GasRatio_MQ3();
Serial.print("MQ3 Gas ratio = ");
Serial.println(MQ3_sensor);

float MQ3_ratio = Get_ratio_MQ3(MQ3_sensor);
Serial.print("MQ3 ratio = ");
Serial.println(MQ3_ratio);

Multichannel_Data_generation(); //Print the values from the Multichannel

delay(1000);
}[code]

I get the following error message:

Arduino: 1.8.13 (Windows 10), Board: "Seeeduino Wio Terminal, Master, Enabled, 120 MHz (standard), Small (-Os) (standard), 50 MHz (standard), Arduino, Off, On"

C:\Users\126939\Desktop\Fab Lab\Vape Sensor\2021_Seeed_SensorsExample\2021_SensorExample\2021_SensorExample.ino: In function 'double Get_HCH0()':

2021_SensorExample:32:10: error: 'ppm' was not declared in this scope

return ppm(0.5)

      ^~~

C:\Users\126939\Desktop\Fab Lab\Vape Sensor\2021_Seeed_SensorsExample\2021_SensorExample\2021_SensorExample.ino:32:10: note: suggested alternative: 'pwm'

return ppm(0.5)

      ^~~

      pwm

2021_SensorExample:33:1: error: expected ';' before '}' token

}

^

exit status 1

'ppm' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Any help is greatly appreciated, I am very new to this.