1
0

Add hardware support for GPS, MAX7219, BME280, and MQ7 sensors

- Implemented GPS functionality with initialization and reading latitude and longitude.
- Added MAX7219 display support, including initialization, text display, animation control, and brightness settings.
- Integrated BME280 sensor for reading temperature, pressure, and humidity.
- Developed MQ7 sensor interface for reading gas concentration values.
- Created HTTP client for GET and POST requests.
- Implemented MQTT client for message handling and connection management.
- Added JSON serialization and deserialization functions for sensor and actuator data.
- Established WiFi connection setup for network communication.
This commit is contained in:
Jose
2025-04-25 22:29:57 +02:00
parent 0c09fcd913
commit 51db158354
18 changed files with 441 additions and 303 deletions

View File

@@ -2,17 +2,70 @@
const uint32_t deviceId = getChipID();
// instances
HTTPClient httpClient;
extern HTTPClient httpClient; // HTTP client object
String response; // HTTP Response
float sensorVolt, sensorValue, RSAir, R0; // MQ7 vars
float temperature, pressure, humidity; // BME280 vars
float lon, lat; // GPS vars
extern MD_Parola display; // Display object
// HTTP Request
String response;
void setup()
{
Serial.begin(9600);
// MQ7
float sensorVolt, sensorValue, RSAir, R0;
Serial.println("Iniciando...");
MQ7_Init();
Serial.println("Sensor MQ7 inicializado");
BME280_Init();
Serial.println("Sensor BME280 inicializado");
GPS_Init();
Serial.println("GPS inicializado");
MAX7219_Init();
Serial.println("Display inicializado");
// BMP280
float temperature, pressure, altitude;
prettyReadBME280();
prettyReadMQ7();
testMatrix();
}
void loop()
{
}
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");
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()
{
Serial.println("Leyendo sensor BME280...");
BME280_Read(pressure, temperature, humidity);
Serial.print("\t - Presión: "); Serial.print(pressure/100); Serial.print("hPa\r\n");
Serial.print("\t - Temperatura: "); Serial.print(temperature); Serial.print("°C\r\n");
Serial.print("\t - Humedad: "); Serial.print(humidity); Serial.print("%\r\n");
}
void prettyReadGPS()
{
Serial.println("Leyendo GPS...");
GPS_Read(lat, lon);
Serial.print("\t - Latitud: "); Serial.print(lat); Serial.print("\r\n");
Serial.print("\t - Longitud: "); Serial.print(lon); Serial.print("\r\n");
}
void testMatrix()
{
Serial.println("Escribiendo en el display...");
MAX7219_DisplayText("Prueba de texto", PA_LEFT, 100, 500);
}
uint32_t getChipID()
{
@@ -22,28 +75,4 @@ uint32_t getChipID()
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
return chipId;
}
void setup()
{
Serial.begin(9600);
/*// WiFi Connection
if(setupWifi() != 0)
{
Serial.print("Error connecting to WiFi");
}
// test get
getRequest(httpClient, "http://172.20.10.7:8082/api/v1/sensors/1/values", response);
deserializeSensorValue(httpClient, httpClient.GET()); */
BME280_Init();
}
void loop()
{
Serial.println(temperature);
Serial.println(pressure);
}
}