I NEED HELP FOR A PROJECT ASAP PLEASE!! IT'S DUE IN 4 DAYS!!

Maybe wise to try to understand printing to BT first before you use the above sketch.

There is a SoftwareSerialExample in the IDE.
Change the code to the Arduino pins you have used for the BT module, or move the BT wires to pin 10 and 11.
Adjust the BT baud rate in the sketch (mySerial.begin) to the rate of the BT module (9600 ?).

If that all works, then merge the BT sketch with the gas sensor sketch.
Leo…

Ok I'll do that, but I have one quick question. Can I add a 9V battery to Arduino just like that? Without any special resistors or anything? This device needs to be functioning without having to plug it into a computer (it's going to be portable).

I’m having some trouble merging this code with the code I put in the other post for the gas sensor. This code has to do with a different device (AirCating Monitor), but my device has only one sensor: http://habitatmap.org/habitatmap_docs/HowToBuildAnAirCastingAirMonitor.pdf

/*
Each sensor reading should be written as one line to the serial output. Lines should end
with '\n' and should have the following format:
<Measurement value>;<Sensor package name>;<Sensor name>;<Type of measurement>;<Short type of measurement>;<Unit name>;<Unit symbol/abbreviation>;<T1>;<T2>;<T3>;<T4>;<T5>
The Sensor name should be different for each sensor.
T1..T5 are integer thresholds which guide how values should be displayed -
- lower than T1 - extremely low / won't be displayed
- between T1 and T2 - low / green
- between T2 and T3 - medium / yellow
- between T3 and T4 - high / orange
- between T4 and T5 - very high / red
- higher than T5 - extremely high / won't be displayed
*/

#include <SoftwareSerial.h> //Header for software serial communication
SoftwareSerial mySerial(7, 6); //Assign 7 as Rx and 6 as Tx

float maxv, CO, LPG, Smoke;
int humi, kelv, cel, fah, circ = 5, heat = 6;

void setup()
{
  Serial.begin(9600); //Serial communication for Arduino Serial Monitor
  mySerial.begin(9600); //Serial communcation for Aircasting Application
  pinMode(circ, OUTPUT);
  pinMode(heat, OUTPUT);
}

void GetTemp()
{
  float val2 = analogRead(A2);
  val2 = (val2 * 5.0)/1023;
  val2 = (val2 - 0.5)*100;
  cel = val2;
  kelv = val2 + 273.15;
  fah = ((val2 * 9)/5.0) + 32;
}

void loop()
{
  //call up the calculation functions
  GetHumi();
  GetTemp();
  GetCO();
  GetLPG();
  GetSmoke();

  //Display of humidity
  mySerial.print(humi);
  mySerial.print(";InsertSensorPackageName;HIH4030;Humidity;RH;percent;%;0;25;50;75;100");
  mySerial.print("\n");
  Serial.print("Humidity: ");
  Serial.print(humi);
  Serial.print("% ");

  //Display of CO gas sensor
  mySerial.print(CO);
  mySerial.print(";InsertSensorPackageName;TGS2442;CO Gas;CO;response indicator;RI;0;25;50;75;100");
  mySerial.print("\n");
  Serial.print("CO Gas: ");
  Serial.print(CO);
  Serial.print("% ");

  //Display of temperature in K, C, and F
  /*
  mySerial.print(kelv);
  mySerial.print(";InsertSensorPackageName;TMP36;Temperature;K;kelvin;K;273;300;400;500;600");
  mySerial.print("\n");
  mySerial.print(cel);
  mySerial.print(";InsertSensorPackageName;TMP36;Temperature;C;degrees Celsius;C;0;10;15;20;25");
  mySerial.print("\n");
  */
  mySerial.print(fah);
  mySerial.print(";InsertSensorPackageName;TMP36;Temperature;F;degrees Fahrenheit;F;0;30;60;90;120");
  mySerial.print("\n");

  Serial.print("Temperature: ");
  // Serial.print(kelv);
  // Serial.print("K ");
  // Serial.print(cel);
  // Serial.print("C ");
  Serial.print(fah);
  Serial.print("F ");

  mySerial.print(LPG);
  mySerial.print(";InsertSensorPackageName;MiCS-2710;N02 Gas;NO2;response indicator;RI;0;25;50;75;100");
  mySerial.print("\n");
  Serial.print("NO2 Gas: ");
  Serial.print(NO2);
  Serial.println("%");
}

void GetCO()
{
  digitalWrite(circ, LOW);
  analogWrite(heat, 245);
  delay(14);
  analogWrite(heat, 0);
  delay(981);
  digitalWrite(circ, HIGH);
  delay(3);
  float val1 = analogRead(A1);
  CO = map(val1, 0 , 1023, 0, 100);
}

void GetHumi()
{
  float val0 = analogRead(A0);
  float maxv = (3.27-(0.006706*cel));
  humi = ((((val0/1023)*5)-0.8)/maxv)*100;
}

void GetNO2()
{
  float val3 = analogRead(A3);
  NO2 = map(val3, 1023, 0, 0, 100);
}

float map(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

Ok I tried merging the code:

/************************Hardware Related Macros************************************/
#include <SoftwareSerial.h> //Header for software serial communication
SoftwareSerial mySerial(7, 6); //Assign 7 as Rx and 6 as Tx

#define         MQ_PIN                       (2)     //define which analog input channel you are going to use
#define         RL_VALUE                     (5)     //define the load resistance on the board, in kilo ohms
#define         RO_CLEAN_AIR_FACTOR          (9.83)  //RO_CLEAR_AIR_FACTOR=(Sensor resistance in clean air)/RO,
                                                     //which is derived from the chart in datasheet
 
/***********************Software Related Macros************************************/
#define         CALIBARAION_SAMPLE_TIMES     (50)    //define how many samples you are going to take in the calibration phase
#define         CALIBRATION_SAMPLE_INTERVAL  (500)   //define the time interal(in milisecond) between each samples in the
                                                     //cablibration phase
#define         READ_SAMPLE_INTERVAL         (50)    //define how many samples you are going to take in normal operation
#define         READ_SAMPLE_TIMES            (5)     //define the time interal(in milisecond) between each samples in 
                                                     //normal operation
 
/**********************Application Related Macros**********************************/
#define         GAS_LPG                      (0)
#define         GAS_CO                       (1)
#define         GAS_SMOKE                    (2)
 
/*****************************Globals***********************************************/
float           LPGCurve[3]  =  {2.3,0.21,-0.47};   //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent"
                                                    //to the original curve. 
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.21), point2: (lg10000, -0.59) 
float           COCurve[3]  =  {2.3,0.72,-0.34};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.72), point2: (lg10000,  0.15) 
float           SmokeCurve[3] ={2.3,0.53,-0.44};    //two points are taken from the curve. 
                                                    //with these two points, a line is formed which is "approximately equivalent" 
                                                    //to the original curve.
                                                    //data format:{ x, y, slope}; point1: (lg200, 0.53), point2: (lg10000,  -0.22)                                                     
float           Ro           =  10;                 //Ro is initialized to 10 kilo ohms
 
void setup()
{
  Serial.begin(9600);                               //UART setup, baudrate = 9600bps
  Serial.print("Calibrating...\n");                
  Ro = MQCalibration(MQ_PIN);                       //Calibrating the sensor. Please make sure the sensor is in clean air 
                                                    //when you perform the calibration                    
  Serial.print("Calibration is done...\n"); 
  Serial.print("Ro=");
  Serial.print(Ro);
  Serial.print("kohm");
  Serial.print("\n");
  
  Serial.begin(9600); //Serial communication for Arduino Serial Monitor
  mySerial.begin(9600); //Serial communcation for Aircasting Application
  pinMode(circ, OUTPUT);
  pinMode(heat, OUTPUT);
}
 
void loop()
{
   Serial.print("LPG:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_LPG) );
   Serial.print( "ppm" );
   Serial.print("    ");   
   Serial.print("CO:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_CO) );
   Serial.print( "ppm" );
   Serial.print("    ");   
   Serial.print("SMOKE:"); 
   Serial.print(MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_SMOKE) );
   Serial.print( "ppm" );
   Serial.print("\n");
   delay(200);
}
 
/****************** MQResistanceCalculation ****************************************
Input:   raw_adc - raw value read from adc, which represents the voltage
Output:  the calculated sensor resistance
Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage
         across the load resistor and its resistance, the resistance of the sensor
         could be derived.
************************************************************************************/ 
float MQResistanceCalculation(int raw_adc)
{
  return ( ((float)RL_VALUE*(1023-raw_adc)/raw_adc));
}
 
/***************************** MQCalibration ****************************************
Input:   mq_pin - analog channel
Output:  Ro of the sensor
Remarks: This function assumes that the sensor is in clean air. It use  
         MQResistanceCalculation to calculates the sensor resistance in clean air 
         and then divides it with RO_CLEAN_AIR_FACTOR. RO_CLEAN_AIR_FACTOR is about 
         10, which differs slightly between different sensors.
************************************************************************************/ 
float MQCalibration(int mq_pin) 
{
  int i;
  float val=0;
 
  for (i=0;i<CALIBARAION_SAMPLE_TIMES;i++) {            //take multiple samples
    val += MQResistanceCalculation(analogRead(mq_pin));
    delay(CALIBRATION_SAMPLE_INTERVAL);
  }
  val = val/CALIBARAION_SAMPLE_TIMES;                   //calculate the average value
 
  val = val/RO_CLEAN_AIR_FACTOR;                        //divided by RO_CLEAN_AIR_FACTOR yields the Ro 
                                                        //according to the chart in the datasheet 
 
  return val; 
}
/*****************************  MQRead *********************************************
Input:   mq_pin - analog channel
Output:  Rs of the sensor
Remarks: This function use MQResistanceCalculation to caculate the sensor resistenc (Rs).
         The Rs changes as the sensor is in the different consentration of the target
         gas. The sample times and the time interval between samples could be configured
         by changing the definition of the macros.
************************************************************************************/ 
float MQRead(int mq_pin)
{
  int i;
  float rs=0;
 
  for (i=0;i<READ_SAMPLE_TIMES;i++) {
    rs += MQResistanceCalculation(analogRead(mq_pin));
    delay(READ_SAMPLE_INTERVAL);
  }
 
  rs = rs/READ_SAMPLE_TIMES;
 
  return rs;  
}
 
/*****************************  MQGetGasPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
         gas_id      - target gas type
Output:  ppm of the target gas
Remarks: This function passes different curves to the MQGetPercentage function which 
         calculates the ppm (parts per million) of the target gas.
************************************************************************************/ 
int MQGetGasPercentage(float rs_ro_ratio, int gas_id)
{
  if ( gas_id == GAS_LPG ) {
     return MQGetPercentage(rs_ro_ratio,LPGCurve);
  } else if ( gas_id == GAS_CO ) {
     return MQGetPercentage(rs_ro_ratio,COCurve);
  } else if ( gas_id == GAS_SMOKE ) {
     return MQGetPercentage(rs_ro_ratio,SmokeCurve);
  }    
 
  return 0;
}
 
/*****************************  MQGetPercentage **********************************
Input:   rs_ro_ratio - Rs divided by Ro
         pcurve      - pointer to the curve of the target gas
Output:  ppm of the target gas
Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) 
         of the line could be derived if y(rs_ro_ratio) is provided. As it is a 
         logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic 
         value.
************************************************************************************/ 
int  MQGetPercentage(float rs_ro_ratio, float *pcurve)
{
  return (pow(10,( ((log(rs_ro_ratio)-pcurve[1])/pcurve[2]) + pcurve[0])));
}

This is the error message I'm getting

Sketch uses 6840 bytes (21%) of program storage space. Maximum is 32256 bytes.
Global variables use 427 bytes (20%) of dynamic memory, leaving 1621 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x43
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x58
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x2b
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x4b
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xc9
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x85

There’s another problem. The BT module is not turning on. Only the gas sensor is turning on.

You must have skipped several steps again.

Leo..

Wawa:
You must have skipped several steps again.

Leo..

In code or in setup? I checked everything (setup) and it seems fine. I didn't change any wires around.

Post#38
Did you try pairing, and did that work.

post#40
Did you try the BT comms sketch, and did that work.
I doubt that, because you didn't cross over TX/RX of Arduino and BT device.
Leo..

Wawa:
Post#38
Did you try pairing, and did that work.

post#40
Did you try the BT comms sketch, and did that work.
I doubt that, because you didn’t cross over TX/RX of Arduino and BT device.
Leo…

Pairing didn’t work (there is no power light on or any flashing). I didn’t try BT comms sketch. Let me try and see.

BT comms sketch doesn't work either.

jkg9:
I've never used Arduino before...

avrdude: stk500_recv(): programmer is not responding
There is an introductory section on the main page, explaining how to set up the computer's com port etc.

jkg9:
Can I add a 9V battery to Arduino just like that?

If you mean a 9volt smoke alarm battery, then NO.
Not enough current capacity for the ~200mA an Arduino(50mA) + gas sensor(150mA) draws.
A 9volt battery bank made with AA batteries, connected to the DC socket, would just be ok.
Leo..

jkg9:
BT comms sketch doesn't work either.

So pairing (step#1) does work.
And communication (step#2) does not work.
Leo..

Wawa:
So pairing (step#1) does work.
And communication (step#2) does not work.
Leo..

Both don't work.

Is there a way to tell if the BT module has burned or fried? I did smell some something burning when I first plugged the USB into the computer, but when I unplugged it, the smell went away and didn't return again.

Check if the 5volt and ground connection of the BT module is done right.
The BT module should pair with only 5volt and GND connected.
Leo..

Wawa:
Check if the 5volt and ground connection of the BT module is done right.
The BT module should pair with only 5volt and GND connected.
Leo..

I checked. Still nothing.

If the BT module won't power up and pair with just 5volt and ground connected, then you must have fried it.
Not strange with all the connection mistakes you made.
Leo..

Wawa:
If the BT module won't power up and pair with just 5volt and ground connected, then you must have fried it.
Not strange with all the connection mistakes you made.
Leo..

But the connection mistakes were made while the board was NOT plugged into the computer. It didn't receive any power. And before I plugged it in, i double-checked everything.

I only have HC-06 modules here.

A red LED is flashing when connected to 5volt/ground.
And I can search/pair with PW 1234.

Leo..