亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

DIY 集水坑液位监测仪 - Arduino Nano、MPXV5010DP 与 OLED 显示

组件与物料清单

组件数量
Arduino Nano R31
Freescale MPXV5010DP 差压传感器1
0.96" OLED 显示屏1
MCP4725 DAC 模块1
继电器模块1
SMD 电容 (1µF, 0.01µF, 470pF)各1
透明项目盒 110×85mm1
Tygon 管 3/32"1

项目背景

为配合女儿家中的 Ecobee RSM-01 输入板或我的家庭监控项目,需要比超声波传感器更可靠、安装更简便的液位监测方案。选择 MPXV5010DP 差压传感器,0-5V 输出对应 0-10kPa,约 1020mm 水柱高度。

设计思路

传感器通过 Tygon 管连接伸入集水坑的铜管,监测主机可远离水面安装。

设计定制 PCB 简化接线,提供多种配置灵活性。

核心代码


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MCP4725.h>
#include <math.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

Adafruit_MCP4725 dac;

int relayPin = 5;
int analogPin = 0;
int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0, v8 = 0;
float v7 = 0;
int offSet = 40;
int maxSet = 1015;
int maxHeight = 1020;
int ranging = (maxHeight * 0.8) + offSet;
int alarmHeight = 12;
int analogPin2 = 1;
float divisor = 25.4;

void setup() {
  Serial.begin(9600);
  Serial.println("DAC test with DP sensor");
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  dac.begin(0x60);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, HIGH);
}

void loop() {
  v1 = analogRead(analogPin2);
  delay(1000);
  if (v1 < offSet) v1 = offSet;
  
  v2 = map(v1, offSet, maxSet, 0, 4095);
  dac.setVoltage(v2, false);
  
  v3 = (v1 - offSet) / 0.8;
  v7 = v3 / divisor;
  v8 = round(v7);
  v4 = map(v1, offSet, ranging, 0, 100);
  v5 = analogRead(analogPin);
  v6 = map(v5, 0, 1023, 0, 5000);
  
  printoled();
  serial();
}

void printoled() {
  display.clearDisplay();
  if (v8 > alarmHeight) {
    display.invertDisplay(true);
    digitalWrite(relayPin, LOW);
  } else {
    display.invertDisplay(false);
    digitalWrite(relayPin, HIGH);
  }
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("SUMP LEVEL");
  display.setTextSize(4);
  display.print(v8);
  display.setTextSize(2);
  println("inches");
  display.display();
  delay(500);
}

void serial() {
  Serial.print(" PS analog input: "); Serial.print(v1);
  Serial.print(" Height: "); Serial.print(v3); Serial.print(" mm ");
  Serial.print(v4); Serial.print("%");
  Serial.print(" Converted voltage: "); Serial.print(v6); Serial.println(" mV");
}

原理图

Eagle 6.5.0 设计文件:sump%20level.sch

制造工艺

  1. 血压计:设计原理、制造工艺与未来趋势
  2. 树莓派打造空气质量与气象站:InfluxDB+Grafana可视化
  3. 在 MATRIX Voice 树莓派上安装 Google Assistant:分步指南
  4. 树莓派气象站:Sense HAT 环境数据采集与 Dropbox 自动上传
  5. 远程心率监测系统:AWS IoT 告警 + 树莓派 Windows IoT 可视化
  6. 树莓派 2 运行 Windows IoT Core 打造 Rover 机器人:从入门到进阶指南
  7. 在树莓派 3 上扩展 GoPiGo v2 的 Windows 10 IoT Core 应用
  8. 用 Arduino 打造绚丽显示器 Ambilight 系统
  9. JW Machine:精密 CNC 合同制造服务专家
  10. 车床精密找平专业指南
  11. 理解 C# 变量作用域:类级、方法级与块级详解
  12. Verilog 门级建模:从硬件原理图到代码的桥梁