/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: Sensor Display - Source Code compiled for: Arduino Uno - Source Code created on: 2024-01-11 08:20:49 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* To make arduino uno on and collect mq2, mq4, */ /* mq7,mq135 values and display in 16x2 lcd screen, */ /* and also sent those values to blynk iot */ /* application through esp8266 wifi module */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include #include #include /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); /***** DEFINITION OF I2C PINS *****/ const uint8_t Hii_LCD1602I2C_I2C_PIN_SDA_A4 = A4; const uint8_t Hii_LCD1602I2C_I2C_PIN_SCL_A5 = A5; const uint8_t Hii_LCD1602I2C_I2C_SLAVE_ADDRESS = 39; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ MQ135 mq135_sensor(A2); // Instantiate MQ135 object float temperature = 21.0; float humidity = 25.0; void setup(void) { // put your setup code here, to run once: Serial.begin(9600); // Initialize LCD screen Wire.begin(); Wire.beginTransmission(Hii_LCD1602I2C_I2C_SLAVE_ADDRESS); Wire.write(0x00); Wire.endTransmission(); } void loop(void) { // put your main code here, to run repeatedly: float rzero = mq135_sensor.getRZero(); float correctedRZero = mq135_sensor.getCorrectedRZero(temperature, humidity); float resistance = mq135_sensor.getResistance(); float ppm = mq135_sensor.getPPM(); float correctedPPM = mq135_sensor.getCorrectedPPM(temperature, humidity); Serial.print("MQ135 RZero: "); Serial.print(rzero); Serial.print("\t Corrected RZero: "); Serial.print(correctedRZero); Serial.print("\t Resistance: "); Serial.print(resistance); Serial.print("\t PPM: "); Serial.print(ppm); Serial.print("\t Corrected PPM: "); Serial.print(correctedPPM); Serial.println("ppm"); // Display values on LCD screen Wire.beginTransmission(Hii_LCD1602I2C_I2C_SLAVE_ADDRESS); Wire.write(0x80); // Set cursor to first line Wire.write("MQ135 RZero: "); Wire.write(String(rzero).c_str()); Wire.write("\t Corrected RZero: "); Wire.write(String(correctedRZero).c_str()); Wire.write("\t Resistance: "); Wire.write(String(resistance).c_str()); Wire.write("\t PPM: "); Wire.write(String(ppm).c_str()); Wire.write("\t Corrected PPM: "); Wire.write(String(correctedPPM).c_str()); Wire.endTransmission(); delay(300); }