Skip to content

Create probe code #1

@FernandoCZanchetta

Description

@FernandoCZanchetta

Task description

In this task, the probe code need to be developed. The probe consists in an ESP32-S3-DevKitC-1 connected to the following sensors and peripherals:

  • GNSS NEO-M8N
  • BME280
  • MPU6050
  • DHT22
  • Buzzer

The probe also has an ESP32-WROVER-DEV with an OV8258 camera.

The probe firmware need to be developed in the branch firmware.

The firmware for the ESP32-S3 will be an RTOS that will collect all the sensors data using some parse tasks, so, for each sensor the code must include a setup_{sensor} and parse_{sensor} functions, the first function will be called in the code setup() and the second will be the function callback of the RTOS Tasks . The buzzer need to indicate the complete setup of the code by playing some melody. All of the data collected in the parse tasks need to be sent to our MQTT server in the correspondent topic.

All the constants and other global values need to be put in the code via defines (#define {CONST} {VALUE}). Some recommended libraries will be in the next sections of this task. The data that will be collected from the sensors are:

  • latitude
  • longitude
  • altitude
  • year
  • month
  • day
  • hour
  • minutes
  • seconds
  • pressure
  • altitude_BME
  • humidity_BME
  • aceleration_x
  • aceleration_y
  • aceleration_z
  • angle_x
  • angle_y
  • anglo_z
  • temperature_mpu
  • humidity_dht
  • temperature_dht
  • heat_index

The firmware for the other ESP board can be a simple setup() and loop() code, since the only function of that microcontroller will be to take pictures. To keep the standard, there will need to be a setup_camera() and parse_camera() functions, the first to configure the camera and the second to take the picture. The picture will be sent to our MQTT server too, in the correspondent topic. This firmware also need to wait for a photo request, that will come from a specific MQTT topic, so the code must include the subscription to this topic, and the necessary steps to wait for the callbacks.

Portuguese 🇧🇷

Nessa tarefa, o código da sonda deve ser desenvolvido. A sonda consiste numa ESP-32-S3-DevKitC-1 conectado aos seguintes sensores e periféricos:

  • GNSS NEO-M8N
  • BME280
  • MPU6050
  • DHT22
  • Buzzer

A sonda ainda conta com uma ESP32-WROVER-DEV com uma câmera OV8258.

O firmware da sonda deve ser desenvolvido na branch firmware.

O firmware da ESP32-S3 deve consistir num RTOS que irá coletar os dados dos sensores utilizando algumas parse tasks, então, para cada sensor, o código deve conter as funções setup_{sensor} e parse_{sensor}. A primeira função será chamada na função setup() do código, já a segunda, será a função de callback das tasks do RTOS. O buzzer deve indicar o setup completo do código ao tocar alguma melodia. Todos os dados coletados pelas parse tasks deve ser enviado para nosso servidor MQTT nos tópicos correspondentes.

Todas as constantes e outros valores globais devem ser colocados no código por meio de defines ( #define {CONST} {VALUE}). Algumas bibliotecas recomendadas estão presentes nas próximas seções dessa tarefa.

Os dados que serão coletados dos sensores são:

  • latitude
  • longitude
  • altitude
  • ano
  • mes
  • dia
  • hora
  • minuto
  • segundo
  • pressão
  • altitude_BME
  • umidade_BME
  • aceleração_x
  • aceleração_y
  • aceleração_z
  • angulo_x
  • angulo_y
  • angulo_z
  • temperatura_mpu
  • umidade_dht
  • temperatura_dht
  • sensação_termica

O firmware para outra placa ESP pode ser simplesmente um código setup() and loop(), já que q única função deste microcontrolador será de tirar fotos com a câmera. Para manter o padrão, deverá haver as funções setup_camera() and parse_camera(), a primeira para configurar a câmera e a segunda para tirar a foto. A foto será enviada também para nosso servidor MQTT, no tópico correspondente. Esse firmware também deve aguardar por um pedido de foto, que virá a partir de um tópico MQTT específico, então, o código deve incluir a subscrição a este tópico e os passos necessários para esperar pelos callbacks.

References

Relevant/related links:

Example snippets

RTOS Example in Arduino IDE:

TaskHandle_t ParseSensorTaskHandle;

#include "Sensor_Library.h"
...
#include "Other_Library.h"

#define SENSOR_GPIO 1
...
#define PARSE_SENSOR_TASK_PRIORITY 5

void parse_Sensor (void *pvParameters) {
    for( ; ; ) {
        //Implement task here
    }
}

void setup() {
    //Variables

    //Call setup functions
    setup_Sensor();

    //Start creating RTOS Taks
    UBaseType_t uxHighWaterMarkParseSensor = 100 * configMINIMAL_STACK_SIZE;

    if ((xTaskCreate(parse_Sensor, "Parse Sensor", uxHighWaterMarkParseSensor, &SensorParameters, PARSE_SENSOR_TASK_PRIORITY, &ParseSensorTaskHandle)) == pdPASS) {
        Serial.println("Tarefa 'Parse Sensor' criada com sucesso!\n");
    }
    
}

void loop() {

    //The loop must be empty, since the RTOS scheduler will handle the task order and calls

}

void setup_Sensor() {
    //Some sensor variable

    //Some sensor setup code
    sensor.begin(SENSOR_GPIO);
    ...
    sensor.config();
    
}

Metadata

Metadata

Labels

criticalNeeds to be done ASAP

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions