cambios picha
This commit is contained in:
2
hardware/.vscode/settings.json
vendored
2
hardware/.vscode/settings.json
vendored
@@ -17,7 +17,7 @@
|
||||
"initializer_list": "cpp"
|
||||
},
|
||||
"github.copilot.enable": {
|
||||
"*": true,
|
||||
"*": false,
|
||||
"plaintext": false,
|
||||
"markdown": false,
|
||||
"scminput": false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <MD_Parola.h>
|
||||
#include <MD_MAX72XX.h>
|
||||
#include <MD_MAX72xx.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
|
||||
@@ -9,8 +9,8 @@
|
||||
#define CLK_PIN 17
|
||||
|
||||
void MAX7219_Init();
|
||||
void MAX7219_DisplayText(const char *text, textPosition_t align, int speed, int pause);
|
||||
void MAX7219_StartAnimation();
|
||||
void MAX7219_StopAnimation();
|
||||
void MAX7219_DisplayText(const char *text, textPosition_t align, uint16_t speed, uint16_t pause);
|
||||
bool MAX7219_StartAnimation();
|
||||
void MAX7219_ResetAnimation();
|
||||
void MAX7219_ClearDisplay();
|
||||
void MAX7219_SetBrightness(uint8_t brightness);
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#define ANALOG_MQ7 33
|
||||
#define DIGITAL_MQ7 32
|
||||
#define HEATER_PIN 16
|
||||
#define SENSOR_PIN 34
|
||||
|
||||
void MQ7_Init();
|
||||
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue);
|
||||
void MQ7_Read(float &sensorValue);
|
||||
void pwmBitBang(int totalMs, int highPct, int cycleMs);
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "BMP280.h"
|
||||
|
||||
|
||||
void BMP280_Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint8_t BMP280_DataReady()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BMP280_Read(float &temperature, float &humidity, float &pressure, float &altitude)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "MQ7.h"
|
||||
|
||||
void MQ7_Init()
|
||||
{
|
||||
pinMode(digitalMQ7, INPUT);
|
||||
pinMode(analogMQ7, INPUT);
|
||||
}
|
||||
|
||||
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
||||
{
|
||||
analogWrite(analogMQ7, 1023);
|
||||
delay(60000);
|
||||
analogWrite(analogMQ7, (1023/5)*1.4 );
|
||||
|
||||
for(int i = 0; i<100; i++)
|
||||
{
|
||||
sensorValue = sensorValue + analogRead(analogMQ7);
|
||||
delay(90000);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
upload_port = COM3
|
||||
lib_deps =
|
||||
knolleary/PubSubClient@^2.8
|
||||
mikalhart/TinyGPSPlus@^1.0.2
|
||||
|
||||
@@ -5,21 +5,21 @@ MD_Parola display = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVI
|
||||
void MAX7219_Init()
|
||||
{
|
||||
display.begin();
|
||||
display.setIntensity(15); // 0-15
|
||||
display.setIntensity(1); // 0-15
|
||||
display.displayClear();
|
||||
}
|
||||
|
||||
void MAX7219_DisplayText(const char *text, textPosition_t align, int speed, int pause)
|
||||
void MAX7219_DisplayText(const char *text, textPosition_t align, uint16_t speed, uint16_t pause)
|
||||
{
|
||||
display.displayText(text, align, speed, pause, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
|
||||
}
|
||||
|
||||
void MAX7219_StartAnimation()
|
||||
bool MAX7219_StartAnimation()
|
||||
{
|
||||
display.displayAnimate();
|
||||
return display.displayAnimate();
|
||||
}
|
||||
|
||||
void MAX7219_StopAnimation()
|
||||
void MAX7219_ResetAnimation()
|
||||
{
|
||||
display.displayReset();
|
||||
}
|
||||
|
||||
@@ -2,25 +2,44 @@
|
||||
|
||||
void MQ7_Init()
|
||||
{
|
||||
pinMode(DIGITAL_MQ7, INPUT);
|
||||
pinMode(ANALOG_MQ7, INPUT);
|
||||
pinMode(HEATER_PIN, OUTPUT);
|
||||
pinMode(SENSOR_PIN, INPUT);
|
||||
}
|
||||
|
||||
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
|
||||
void MQ7_Read(float &sensorValue)
|
||||
{
|
||||
// preheat
|
||||
analogWrite(ANALOG_MQ7, 1023);
|
||||
Serial.println("\t - Calentando MQ7");
|
||||
digitalWrite(HEATER_PIN, HIGH);
|
||||
delay(60000);
|
||||
analogWrite(ANALOG_MQ7, (1023/5)*1.4 );
|
||||
|
||||
for(int i = 0; i<100; i++)
|
||||
Serial.println("\t - Enfriando MQ7");
|
||||
pwmBitBang(90000, 28, 100);
|
||||
|
||||
const int N = 1;
|
||||
long sum = 0;
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
sensorValue = sensorValue + analogRead(ANALOG_MQ7);
|
||||
delay(1200);
|
||||
sum += analogRead(SENSOR_PIN);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
sensorValue = sensorValue/100.0;
|
||||
sensorVolt = sensorValue/1024*5.0;
|
||||
RSAir = (5.0-sensorVolt)/sensorVolt;
|
||||
R0 = RSAir/(26+(1/3));
|
||||
sensorValue = sum / float(N);
|
||||
//sensorVolt = sensorValue * (3.3 / 4095.0); // ADC 12 bits, 3.3V
|
||||
}
|
||||
|
||||
// generamos PWM por software usando bit banging
|
||||
void pwmBitBang(int totalMs, int highPct, int cycleMs)
|
||||
{
|
||||
int onTime = cycleMs * highPct / 100;
|
||||
int offTime = cycleMs - onTime;
|
||||
int elapsed = 0;
|
||||
|
||||
while (elapsed < totalMs)
|
||||
{
|
||||
digitalWrite(HEATER_PIN, HIGH);
|
||||
delay(onTime);
|
||||
digitalWrite(HEATER_PIN, LOW);
|
||||
delay(offTime);
|
||||
elapsed += cycleMs;
|
||||
}
|
||||
}
|
||||
@@ -4,44 +4,44 @@ const uint32_t deviceId = getChipID();
|
||||
|
||||
extern HTTPClient httpClient; // HTTP client object
|
||||
String response; // HTTP Response
|
||||
float sensorVolt, sensorValue, RSAir, R0; // MQ7 vars
|
||||
float sensorVolt, sensorValue; // MQ7 vars
|
||||
float temperature, pressure, humidity; // BME280 vars
|
||||
float lon, lat; // GPS vars
|
||||
extern MD_Parola display; // Display object
|
||||
|
||||
void setup()
|
||||
{
|
||||
/*GPS_Init();
|
||||
Serial.println("GPS inicializado"); */
|
||||
Serial.begin(9600);
|
||||
|
||||
/*Serial.println("Iniciando...");
|
||||
MQ7_Init();
|
||||
Serial.println("Sensor MQ7 inicializado");
|
||||
Serial.println("Iniciando...");
|
||||
BME280_Init();
|
||||
Serial.println("Sensor BME280 inicializado");
|
||||
GPS_Init();
|
||||
Serial.println("GPS inicializado"); */
|
||||
MAX7219_Init();
|
||||
Serial.println("Display inicializado");
|
||||
MQ7_Init();
|
||||
Serial.println("Sensor MQ7 inicializado");
|
||||
|
||||
//prettyReadBME280();
|
||||
prettyReadBME280();
|
||||
testMatrix();
|
||||
//prettyReadMQ7();
|
||||
prettyReadMQ7();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
if(MAX7219_StartAnimation())
|
||||
{
|
||||
MAX7219_ResetAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void prettyReadMQ7()
|
||||
{
|
||||
Serial.println("Leyendo sensor MQ7...");
|
||||
MQ7_Read(sensorVolt, RSAir, R0, sensorValue);
|
||||
Serial.print("\t - Voltaje: "); Serial.print(sensorVolt); Serial.print("V\r\n");
|
||||
MQ7_Read(sensorValue);
|
||||
//Serial.print("\t - Voltaje: "); Serial.print(sensorVolt); Serial.print("V\r\n");
|
||||
Serial.print("\t - Valor sensor: "); Serial.print(sensorValue); Serial.print("\r\n");
|
||||
Serial.print("\t - Resistencia aire: "); Serial.print(RSAir); Serial.print("kOhm\r\n");
|
||||
Serial.print("\t - Resistencia aire: "); Serial.print(R0); Serial.print("kOhm\r\n");
|
||||
Serial.print("\t - Concentración CO: "); Serial.print(sensorValue); Serial.print("ppm\r\n");
|
||||
}
|
||||
|
||||
void prettyReadBME280()
|
||||
@@ -64,7 +64,7 @@ void prettyReadGPS()
|
||||
void testMatrix()
|
||||
{
|
||||
Serial.println("Escribiendo en el display...");
|
||||
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500);
|
||||
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 50, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user