Snippet Tag: Arduino MQ4 gas sensor working code

MQ4 Arduino code

#include <Wire.h> #include <ADC121C_MQ4.h> ADC121C_MQ4 mq4; void setup(void) { Serial.begin(9600); // The address can be changed making the option of connecting multiple devices mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_DEFAULT_ADDRESS); // 0x50, 1010000 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_FLGND); // 0x51, 1010001 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_FLVA); // 0x52, 1010010 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_GNDFL); // 0x54, 1010100 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_GNDGND); // 0x55, 1010101 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_GNDVA); // 0x56, 1010110 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_VAFL); // 0x58, 1011000 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_VAGND); // 0x59, 1011001 // mq4.getAddr_ADC121C_MQ4(ADC121C_MQ4_ADDRESS_VAVA); // 0x5A, 1011010 // The Automatic Conversion Mode, Alert Hold, Alert Flag Enable, // Alert Pin Enable and ALERT pin Polarity // can be changed via the following functions mq4.setCycleTime(CYCLE_TIME_32); // Tconvert x 32, 27 ksps

Read More »