更直观的感受国产毫米波雷达模块!CEM5826-M11拓展OLED显示器。

发布时间:2024-12-25

国产毫米波雷达模块

CEM5826-M11 是萤火工场研发的一款高灵敏度国产24GHz 毫米波人体微动存在检测雷达模块。区别于传统雷达通过检测人体移动的大幅度动作或肢体动作来判断人体存在,本模块主要特点是在传统人体感应雷达的功能基础上,同时具备检测积累人体微动幅度的运动,来判断人体的存在的功能。因此相比传统多普勒雷达来说,具备一定范围内的存在检测,准确率更高。不易漏报。

玩家有话说

本文将基于串口打印雷达监测数据的研究,进一步扩展连接OLED屏幕,让CEM5826-M11的核心测试数据及灵敏度更直观的被观察。

显示框架

为了降低消耗,OLED屏幕采用局部刷新的方案。所需库函数Wire.h、Adafruit_GFX.h、Adafruit_SSD1306.h。

代码如下:

#include <Wire.h>#include <Adafruit_GFX.h>#include <Adafruit_SSD1306.h>#include "logo_128x64.h"#include "logo_95x32.h"

#define OLED_RESET 4Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

void setup(){  Serial.begin(115200);  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)  display.clearDisplay(); // 清屏  display.drawBitmap(0, 0, logo, 128, 64, 1); //画出字符对应点阵数据  display.display();  delay(1000);  display.clearDisplay();  /*-------------------- Display picture and text ---------------------------*/  display.drawBitmap(16, 0, logo_small, 95, 32, 1);  display.setTextColor(WHITE);  //设置字体颜色  display.setTextSize(2);  //设置字体大小 1 is default 6x8, 2 is 12x16, 3 is 18x24  display.setCursor(0,33); //设置起始光标  display.print("v=");  display.setCursor(72,33); //设置起始光标  display.print("km/h");  display.setCursor(0,49); //设置起始光标  display.print("str=");  display.display();}

void loop()


数据显示设置

将串口打印数据与OLED显示框架结合,将v和str两数据分别填充至OLED屏预留位置,即可实现雷达监测数据的对应填充显示,包括速度v和信号强度str。

代码如下:

#include <Wire.h>#include <Adafruit_GFX.h>#include <Adafruit_SSD1306.h>#include "logo_128x64.h"#include "logo_95x32.h"

#define OLED_RESET 4Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

String comdata = "";

void setup(){  Serial.begin(115200);  while (Serial.read() >= 0){}//clear serialbuffer  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)  display.clearDisplay(); // 清屏  display.drawBitmap(0, 0, logo, 128, 64, 1); //画出字符对应点阵数据  display.display();  delay(1000);  display.clearDisplay();  /*-------------------- Display picture and text ---------------------------*/  display.drawBitmap(16, 0, logo_small, 95, 32, 1);  display.setTextColor(WHITE);  //设置字体颜色  display.setTextSize(2);  //设置字体大小 1 is default 6x8, 2 is 12x16, 3 is 18x24  display.setCursor(0,33); //设置起始光标  display.print("v=");  display.setCursor(80,33); //设置起始光标  display.print("km/h");  display.setCursor(0,49); //设置起始光标  display.print("str=");  display.display();}

void loop(){  if (Serial.available() > 0)   {    char data = Serial.read();    comdata += data;    if (data == '\n')    {// type of comdata: v=1.0 km/h, str=10151      int separatorIndex = comdata.indexOf(','); // 假设分隔符为逗号      if (separatorIndex != -1)      {        String part1 = comdata.substring(0, separatorIndex); // 第一个部分        String part2 = comdata.substring(separatorIndex + 1); // 第二个部分        // 打印分割后的数据        //Serial.println(part1); // type of part1: v=1.0 km/h        //Serial.println(part2); // type of part2:  str=10151        /*------------ part1 : v=1.0 km/h ----------*/        int part1separatorIndex = part1.indexOf('='); //index of '='        if (part1separatorIndex != -1)        {          String vlc = part1.substring(part1separatorIndex + 1); // index of velocity, type of vlc is 1.0 km/h          // vlc: 1.0 km/h          int VLCseparatorIndex = vlc.indexOf(' '); // index of ' '          String v = vlc.substring(0, VLCseparatorIndex);// v only include number          float Vn = v.toFloat();          Serial.print(Vn); // print velocity number          Serial.print(',');          //display.setCursor(25,33); //设置起始光标          display.fillRect(25, 33, 60, 16, BLACK);          display.display();          display.setCursor(25,33); //设置起始光标          display.print(Vn);          display.display();        }        /*------------- part2 :  str=10151 ------------------*/        int part2separatorIndex = part2.indexOf('='); //index of '='        if (part2separatorIndex != -1)        {          String strng = part2.substring(part2separatorIndex + 1); // strng only include number          int Sn = strng.toInt();          Serial.print(Sn); // print strength number          Serial.println();          //display.setCursor(49,49); //设置起始光标          display.fillRect(49, 49, 79, 16, BLACK);          //display.setPixelColor();          display.display();          display.setCursor(49,49); //设置起始光标          display.print(Sn);          display.display();        }      }      comdata = "";    }  }}


成果展示

这里由于字体设置为2号,无法满��km/h单位��完整填充,因此被数据覆盖住一部分,可根据实际需求调整字体大小。