1
0

Refactor MAX7219 initialization and update MQ7 reading delay

This commit is contained in:
Jose
2025-04-27 22:27:06 +02:00
parent 51db158354
commit cf540bdec9
4 changed files with 8 additions and 12 deletions

View File

@@ -4,7 +4,6 @@
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4 // 4 modulos 8x8
#define DATA_PIN 19
#define CS_PIN 18
#define CLK_PIN 17

View File

@@ -5,7 +5,7 @@ MD_Parola display = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVI
void MAX7219_Init()
{
display.begin();
display.setIntensity(1); // 0-15
display.setIntensity(15); // 0-15
display.displayClear();
}

View File

@@ -8,6 +8,7 @@ void MQ7_Init()
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
{
// preheat
analogWrite(ANALOG_MQ7, 1023);
delay(60000);
analogWrite(ANALOG_MQ7, (1023/5)*1.4 );
@@ -15,16 +16,11 @@ void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
for(int i = 0; i<100; i++)
{
sensorValue = sensorValue + analogRead(ANALOG_MQ7);
delay(90000);
delay(1200);
}
sensorValue = sensorValue/100.0;
sensorVolt = sensorValue/1024*5.0;
RSAir = (5.0-sensorVolt)/sensorVolt;
R0 = RSAir/(26+(1/3));
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}

View File

@@ -13,19 +13,19 @@ void setup()
{
Serial.begin(9600);
Serial.println("Iniciando...");
/*Serial.println("Iniciando...");
MQ7_Init();
Serial.println("Sensor MQ7 inicializado");
BME280_Init();
Serial.println("Sensor BME280 inicializado");
GPS_Init();
Serial.println("GPS inicializado");
Serial.println("GPS inicializado"); */
MAX7219_Init();
Serial.println("Display inicializado");
prettyReadBME280();
prettyReadMQ7();
//prettyReadBME280();
testMatrix();
//prettyReadMQ7();
}
void loop()
@@ -65,6 +65,7 @@ void testMatrix()
{
Serial.println("Escribiendo en el display...");
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500);
}
uint32_t getChipID()