博主头像
NoColor's Blog

Hodie mecum eris in paradiso.

头图

Riotee Board 无电池MCU使用体验

riotee.png
riotee.png
之前参加了杭州的Sensys 2024,拿到了一些Riotee Board的demo,在这里对作者Kai Geissdoerfer表示感谢,也顺便写一些使用体验。

什么是无电池MCU

The energy harvested by a battery-free device is often unreliable and insufficient to power the device directly. For example, a tiny solar panel may deliver only 100uW of power, while a typical low power device consumes tens of milliwatts when active. To remain operable, the device accumulates energy in tiny, sustainable capacitors. When those capacitors are charged, the device will activate and function until its capacitors are drained, at which point it will turn off until it has gathered enough energy to resume operation. This switching between on and off states can happen multiple times per second.

总之就是尽管叫无电池MCU,还是需要某种形式的供电(不可能虚空发电)。不过相比于普通MCU断电重启丢失数据,无电池MCU可以通过电容储能,在能量充足时自动开启CPU运算,在能量不足时自动休眠保存数据等到能量充足时继续运算。

买&&硬件配置

Mouser上面有售,99美刀一个,还是很贵的。
Riotee Board 主要包括一个Nordic Semiconductor nRF52833 64-MHz Cortex-M4 CPU进行运算,一个TI MSP430FR5962负责低电量休眠存储,还有一个Raspberry Pi RP2040负责烧录程序。传感器扩展板太阳能扩展板电容扩展板另售。理论上说,这些扩展板和Riotee Board均开源,PCB文件可在文档网站获取,自己找厂家打板也是一种可能。

Quick Start

Riotee Board 兼容Arduino IDE开发,只需要在Arduino IDE的文件->首选项 中添加开发板管理器https://riotee.nessie-circuits.de/arduino/package_riotee_index.json,之后在插入的串口中选择Riotee Board类型即可使用。

以下是IO接口图和点亮板载LED的程序

riotee-board-pinout.png
riotee-board-pinout.png

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
  riotee_wait_cap_charged();
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1);
  digitalWrite(LED_BUILTIN, LOW);
}

写入程序后将开发板拿到阳光下即可发现红色LED在闪烁,闪烁频率和光强正相关。

串口输出&ADC读取

程序默认没有开启串口输出而且官方文档给出的ADC读取程序有些问题,以下是自用的ADC读取和串口输出程序。

#include "riotee.h"
#include "riotee_adc.h"
#include "riotee_timing.h"
#include "riotee_uart.h"
#include "printf.h"


#define SAMPLE_COUNT 10 
#define SAMPLE_INTERVAL_US 1000




float read_adc(riotee_adc_input_t input_port) {
  int16_t adc_buffer[SAMPLE_COUNT];
  float voltage = 0.0f;
  riotee_adc_cfg_t adc_cfg = {
    .gain = RIOTEE_ADC_GAIN1_6,                                  // 增益设置为 1/6
    .reference = RIOTEE_ADC_REFERENCE_INTERNAL,                  // 使用内部参考电压 0.6V
    .acq_time = RIOTEE_ADC_ACQTIME_10US,                         // 采样时间为 10 微秒
    .input_pos = input_port,                                     // 正输入为 A1
    .input_neg = RIOTEE_ADC_INPUT_NC,                            // 负输入接地单端输入,12-bit ADC
    .res_pos = RIOTEE_ADC_RES_PULLDOWN,                          // 正输入无上拉/下拉电阻
    .res_neg = RIOTEE_ADC_RES_NOPULL,                            // 负输入无上拉/下拉电阻
    .oversampling = RIOTEE_ADC_OVERSAMPLE_DISABLED,              // 禁用过采样
    .n_samples = SAMPLE_COUNT,                                   // 采样次数
    .sample_interval_ticks32 = (SAMPLE_INTERVAL_US * 32) / 1000  // 采样间隔转换为 32kHz 时钟的 ticks
  };
  int result = riotee_adc_sample(adc_buffer, &adc_cfg);
  if (result == RIOTEE_SUCCESS) {
    //printf("ADC sampling success\r\n");
    int32_t sum = 0;
    for (int i = 0; i < SAMPLE_COUNT; i++) {
      sum += adc_buffer[i];
    }
    int16_t avg_adc_value = sum / SAMPLE_COUNT;
    //printf("ADC Raw Value: %d\r\n", avg_adc_value);
    voltage = riotee_adc_adc2vadc(avg_adc_value, &adc_cfg);
  } else {
    printf("ADC sampling failed with error code: %d\r\n", result);
  }
  return voltage;
}



void setup() {
  riotee_adc_init();
  riotee_uart_init(PIN_D1, RIOTEE_UART_BAUDRATE_115200); 
  printf("Hello...\r\n");
}

void loop() {
  riotee_wait_cap_charged();
  float voltage_a1 = read_adc(RIOTEE_ADC_INPUT_A1);
  printf("A1 Voltage: %.3f V\r\n", voltage_a1);
  float voltage_cap = read_adc(RIOTEE_ADC_INPUT_VCAP) + 5.0;
  printf("Cap Voltage: %.3f V\r\n", (voltage_cap - 5.0)/5.62*15.62);
  delay(1000);
}
Riotee Board 无电池MCU使用体验
https://nocolor.cc/index.php/archives/156/
本文作者 NoColor
发布时间 2025-05-10
许可协议 CC BY-NC-SA 4.0
发表新评论