功能简述:使用推荐的AD7606C18FMCZ远程采集数据,并使用ADI的ACE软件采集数据并生产数据采集端口。端口数据推送到Http服务器的数据接口。数据可以通过树莓派无线读取并远程监控。
采用的硬件为XIAO ESP32C3 开发板作为主控,该电路板附带一个外部天线,以增加无线应用程序的信号强度。 它还具有小巧精致的外形,并结合了单面表面贴装设计。 它配备了丰富的接口,具有11个数字I/O,可作为PWM引脚和4个模拟I/O,可作为ADC引脚。支持**UART、I2C、SPI等4种串行接口。
采用基于 XIAO 的多功能扩展板所配套的OLED实现显示功能。
采用AD7606进行高速数据采样。
2.2 程序设计流程图如下,
具体程序设计流程如下
运行的控制台输出和前端显示如下
三、各部分功能说明
- 这个功能主要在主控芯片ESP32C3实现,包括自定义SPI串口数据读取,数据显示,和无线上传三个模块。
- 前端芯片AD7606C18FMCZ实现8通道高速采集。
- 后台采用手机,台式机都作为客户端,直接读取http server服务,实现无线示波器的展示功能。
具体在上述软件流程中详细描述。
代码AD7606_ESP32_Osillator.ino ,下载链接如下:https://download.eeworld.com.cn/detail/%E5%8C%97%E6%96%B9/630351
具体代码如下:
#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>
#include <WiFi.h>
#include <AD7606.h>
#define DB7 D10
#define DB8 D9
#define RD D8
#define CS D7
#define CVA_CVB D2
#define RESET_AD7606_BTN D1
#define BUSY D0
#define RESERVE D6
#define OLED_SDA D5
#define OLED_SCL D4
#define BEEP D3
#define SAMPLING 64
const char* ssid = "honor";
const char* password = "digikey9";
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ OLED_SCL, /* data=*/ OLED_SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
AD7606_18_Serial AD(DB7, DB8, RD, CS, CVA_CVB, CVA_CVB, BUSY, RESET_AD7606_BTN);
WiFiServer server(80);
void init_AD7606(void){
Serial.println("Init AD7606.");
pinMode(RESERVE, OUTPUT);
pinMode(BEEP, OUTPUT);
}
void init_OLED(void){
Serial.println("Init OLED.");
u8x8.begin();
u8x8.setFlipMode(1); // set number from 1 to 3, the screen word will rotary 180
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.setCursor(0, 0);
u8x8.print("Oscillat Digikey");
}
void init_wifi(){
Serial.println("Init Wifi.");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected. ");
Serial.println(WiFi.localIP());
server.begin();
u8x8.setCursor(0, 7);
u8x8.print(WiFi.localIP());
}
String getAD7606(void){
int32_t Data[8];
//Serial.println("Get AD7606.");
AD.read(Data);
String reading=String("var xy=["+String(Data[0]));
for (int32_t i = 2; i < SAMPLING; i++)
{
AD.read(Data);
reading=String(reading+","+String(Data[0]));
}
AD.read(Data);
reading=String(reading+","+String(Data[0])+"];");
Serial.println(reading);
delay(1);return reading;
}
//void html_head(void){__nop()}
void getWifi(void){
WiFiClient client = server.available(); // listen for incoming clients
//const char* url="\"http://httpbin.org/range/16\"";
if (client) { // if you get a client,
Serial.println("New Client."); // print a message out the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row. that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println();
// the content of the HTTP response follows the header:
client.print(" <html><head><script src=\"https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js\" ></script><img src=\"https://www.eeworld.com.cn/huodong/digikey_iot_contest_2023/image/banner.jpg\" width=\"100%\"/></head>");
client.print("<body><div id=\"main\" style=\"width: 100%;height:600px;\"></div>! ");
client.print("<script>var my=echarts.init(document.getElementById('main'));");
client.print(getAD7606());client.print("option={visualMap:[{show:false,type:'continuous',seriesIndex:0,min:0,max:400}],title:[{left:'center',text: 'Oscillator Digikey'}],tooltip:{trigger:'axis'},");
client.print("xAxis:[{data:[]}],yAxis: [{}],grid:[{bottom:'60%'}],series:[{type:'line',showSymbol: false,data: xy}]};my.setOption(option);");
client.print("function refresh(){fetch(\"http://httpbin.org/range/16\").then((response) => response.text());};");
client.print("window.setInterval(refresh,2000);");
client.print("</script></body></html>");
// The HTTP response ends with another blank line:
client.println();
// break out of the while loop:
break;
} else { // if you got a newline, then clear currentLine:
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
// Check to see if the client request was "GET /H" or "GET /L":
u8x8.setCursor(2, 3);u8x8.print("Oscillat On.");
//if (currentLine.endsWith("GET /ON")) { u8x8.print("Oscillat On. "); digitalWrite(5, HIGH); client.print("Click <a href=\"/H\">here</a> to turn the LED on pin 5 on.<br>"); }
//if (currentLine.endsWith("GET /OFF")) { u8x8.print("Oscillat OFF. ");digitalWrite(5, LOW); //client.print("Click <a href=\"/L\">here</a> to turn the LED on pin 5 off.<br>"); }
}
}
// close the connection:
client.stop();
//Serial.println("Client Disconnected.");
};
delay(10);
}
/*************************************************************/
void setup()
{
Serial.begin(115200);
delay(500);
init_AD7606();
init_OLED();
init_wifi();
Serial.println("Start Oscillator AD7606.");
}
void loop()
{
getWifi();
Serial.println("Refresh 2000ms.");
delay(2000);
主要功能搞得比较清晰,就是各个模块初始化,然后直接启动wifi并提供一个运行的服务器供远程读取AD7606数据。虽然ESP32C3身体小,但是可以嵌入javascript实现各种互动,使用浏览器的DOM,还使用了echarts的js模块,可以低代码实现动态的数据可视化。
2 项目启动的视频如下。
VID20231225112805
可以看到顺序执行,并且自动刷新。这个刷新不是在主控芯片实现的,而是由远程的client自动刷新,用http GET的方式实现数据推送,这里设定是2000毫秒,实际上可以设定为更小,实现高性能刷新。这个同时也实现了显示和联网,
五、作品功能演示视频
作品视频如下,从上电,启动,启动服务器并接受客户端访问。
VID20231225112617
六、项目总结
6.1 这个过程采用了多种设备和数据采集技术,充分发挥了AD7606的高性能数据采集功能。同时结合ESP32C3的智能联网功能,可以实现智慧物联网的功能。这次项目,用无线示波器的方式展示了类似的基本架构和实现方式,可以作为原型设计的参考方案。
6.2 分享链接汇总:
1.【DigiKey创意大赛】EVAL-AD7606C18FMCZ开箱贴 - DigiKey得捷技术专区 - 电子工程世界-论坛 (eeworld.com.cn)
https://bbs.eeworld.com.cn/thread-1265488-1-1.html
2. 【DigiKey创意大赛】无线示波器检测系统 #1——AD7606C18FMCZ数据采集成功
https://bbs.eeworld.com.cn/thread-1267593-1-1.html
3. 【DigiKey创意大赛】无线示波器检测系统 #2——AD7606C18FMCZ配网和显示通过
https://bbs.eeworld.com.cn/thread-1267799-1-1.html
七、其他
7.1 提交文档的word版本如下
7.2 代码如下
7.3 参考的AD7606资料如下
7.4 参考逻辑图文件