I am currently writing a program for LED indication of battery charge, voltage, and current consumption.
I am using beegee-tokyo/WisBlock-API as my main code
and beegee-tokyo/WisBlock-Sensor-For-LoRaWAN
Previously I used an OLED display, but now I decided that for the sake of miniaturization should use the LED indication on the motherboard (LED_GREEN & LED_BLUE).
So I wrote code FreeRTOS to “blink” two LEDs. The program works well. But I would like to hear the opinion of experienced developers: how much power consumption will increase due to one more task FreeRTOS. The official FreeRTOS documentation states that a task managed by a queue does not consume CPU resources.
Unfortunately, I do not currently have an ampere-voltmeter of sufficient accuracy to estimate energy consumption. Perhaps one of the DIY developers has already measured the power consumption of the processor when several more tasks are added to the main code.
I’m going to build two or three more tasks into the code to poll the sensors at a given time. Will this greatly increase energy consumption?
I would be grateful for your advice.
P.S. I would like to clarify further. As I understand it, the RAK1600 cannot be programmed for an interrupt; polling is only possible in a loop? I measure power to calculate battery capacity when powering a minicomputer.
Current consumption of RAK1600 during measurement: 0.7 - 1.0 mA, and with power off 6 - 15 µA.
Does it make sense to put the RAK1600 into ADC_OFF or even POWER_DOWN mode every second or will this mode of operation cause problems?
Thanks in advance for your answers.
#include "app.h"
#if RAK_LED > 0
#define LED_QUEUE_LEN 10
/* Queue structure */
TaskHandle_t HandleLED;
QueueHandle_t xQueueLED = NULL;
struct arrayLED {
u_int16_t cycles;
uint8_t LED;
u_int16_t interval;
u_int16_t pause;
} xLEDParameters;
/* The main task for LED */
void vTaskLED(void *pvParameters)
{
struct arrayLED xParameters;
for (;;)
{
if (xQueueLED != NULL)
{
if (xQueueReceive
(xQueueLED, &(xParameters),
(TickType_t) 10) == pdPASS)
{
for (int i = 0; i <= xParameters.cycles; i++)
{
digitalWrite(xParameters.LED, HIGH);
vTaskDelay(xParameters.interval);
digitalWrite(xParameters.LED, LOW);
vTaskDelay(xParameters.pause);
}
}
}
vTaskDelay(100);
}
}
bool init_led()
{
xQueueLED = xQueueCreate(LED_QUEUE_LEN, sizeof(xLEDParameters));
digitalWrite(LED_GREEN, LOW);
digitalWrite(LED_BLUE, LOW);
if (xQueueLED == NULL)
{
return false;
}
if (!xTaskCreate
(vTaskLED, "LED", 1024, NULL, TASK_PRIO_LOW,
&HandleLED))
{
return false;
}
return true;
}
void LED_indication(const u_int16_t cyclesT, const u_int8_t LED, const u_int16_t intervalT,
const u_int16_t pauseT)
{
xLEDParameters.cycles = cyclesT;
xLEDParameters.LED = LED;
xLEDParameters.interval = intervalT;
xLEDParameters.pause = pauseT;
xQueueSend(xQueueLED, (void *) &xLEDParameters, (TickType_t) 0);
}
#endif