Arduino的传感器使用教程1:PM2.5、温度和大气压传感器

2023-11-11

来自我的个人网站: http://wangbch.com

ARDUINO.SENSOR

  • Arduino: Temperature&PM2.5&Atmos
  • Arduino测定温度、PM2.5以及大气压。

Temperature Measure and SD Card Writing

1. Introduction: Two temperature measure with SD card writer writing data to a txt file. //两个温度模块测温,并将温度用SD卡读写模块写入文件中。

2. File: twoTemperatureWithSDCard.ino

3. What you need:

  • Two One-wire Temperature Sensor(DS18B20 with a Pull-up resistor) //DS18B20加上拉电阻

  • An SD card Readwrite module.

  • An SD card.

4. Connection:

  • In twoTemperatureWithSDCard.ino, we have “#define ONE_WIRE_BUS 2“, so connect “DQ” pin in DS18B20 to 2 pin in arduino. And Arudino offers us an example in “SD\examples\ReadWrite\ReadWrite.ino”, where we can find:
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4
  • Connect as the 4.1 said, attention the pin name CLK == SCL == SCK == 1, SDA == MOSI == 1, SD0 == MISO == 1, and the VCC pin need to connect to 5V power. The SD card I use is 8 GB with class6. //按照以上代码的提示进行连接,注意有些接口的名称是不同的。

5. Data:
- In this case, I wrote temperature data to two different files names “temp.txt” and “temp2.txt”. In each file, first number is time, and the second is temperature data, the time is the duration since the last run, rather than real time, you can infer from the Last Modified Time of the file, or add a Clock module in your arduino.
- Every time you reboot your arduino, the file will write “,,,,,” to show it is a now turn.
- You can use python to split data and save it as csv, or plot with matplotlib.
- //例子中将数据写入两个文件,每次重新开机,会写入初始化的字符用来区分。每次写入两个数据,时间和温度,以逗号分隔,时间是距离开始测量经过的时间,需要自行推断真实时间。

6. About Code:

  • For SD card writer:
    • We use File <name> to initial, use <name> = SD.open("<filename>.txt", File_Write) to prepare for writing data, then use <name>.print() or <name>.println() to write string to .txt. Finally use .close() to release.
      In void setup() we should write a initial information, such as “measure begins”.
  • For One-Wire Sensor:
    • #define ONE_WIRE_BUS 2 - Set the pin we use
      OneWire oneWire(ONE_WIRE_BUS);
      DallasTemperature sensors(&oneWire);
      sensors.begin();
      sensors.requestTemperatures();
      <File>.print(sensors.getTempCByIndex(0)); - We can distinguish two different one-wire sensor using different index.
      delay(500); - Set the delay between two measures, millisecond.

Atmospheric Pressure Measure and SD Card Writing

1. Introduction: Atmospheric pressure measure(BMP280) and SD card writing data to files.//利用BMP280模块进行气压测量并将气压数据用SD卡读写模块写入文件中。

2. File: atmoMeasureWithSDCard.ino

3. What you need:
- A BMP280 Sensor

  • An SD card Readwrite module.

  • An SD card.

4. Connection:

  • Connect the pins as the head of the file said:

5. Data:
- 3n data is the time, 3n+1 is the tempaerature, and 3n+2 is the atmospheric pressure, pa.

6. About Code:
- Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK); - read from pin;
bme.readTemperature()); - temperautre data;
bme.readPressure()); - pressure data;

PM2.5 Measure and SD Card Writing

1. Introduction: PM2.5 Measure(Sharp GP2Y1010AU0F).

2. File: PM2.5Measure.ino

3. What you need:
- A Sharp GP2Y1010AU0F Sensor.

  • An SD card Readwrite module.

  • An SD card.

4. Connect:
- pin1:(5V power for LED), with a 150 Ω resistor connected in series. Better connect a 220 uf capacitance between the resistor and GND
- pin2: LED-GND
- pin3: Connect to Arduino pin2
- pin4: GND
- pin5: Connect to Arduino A0 pin(data output)
- pin6: 5V power

5. Data:
- 4n time, 4n+1 voltage, 4n+2 dustdensity, 4n+3 ppm per cf.

Additional information

  • When you finished burn the code into your Arduino, once it been powered, the data will continuously write into your SD card, it’s convenient but risky for a small SD card.

  • You can bring your portable battery, arduino and sensors to make it mobile, e.g. , I took a PM2.5 sensor and a battery, went to city to measure how much the PM2.5 is.

  • If you successfully connect two temperautre sensor to arduino, you will find the time arudino “blink” will be longer than normal.

Measured Data

You can handle these data using Python, here are my data visualization using matplotlib(Python).

  • TopLeft: the pressure and temperature data;

  • ButtomLeft: the temperature data

  • Right: the original and sampled PM2.5 data

EOF:)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Arduino的传感器使用教程1:PM2.5、温度和大气压传感器 的相关文章

  • 在github原子编辑器中隐藏隐藏(点)文件

    我对 Github Atom 编辑器非常陌生 它总是显示隐藏文件 例如 git sass在侧窗格中 如何在atom编辑器的侧窗格中隐藏隐藏文件 点文件 编辑 gt 首选项 gt 包 在 已安装的软件包 下面的字段中 输入 树视图 该软件包有
  • 无法获取 https://gerrit.googlesource.com/git-repo/clone.bundle

    我尝试按照以下说明创建一个 git 存储库 source android com source downloading html installing repo 但是当我尝试在工作目录中初始化存储库时 使用 Ubuntu 出现以下错误 wo
  • 请求/响应的 MQTT 主题名称

    我正在设计一个包含许多设备的系统 使用 MQTT 连接到中央代理 有些主设备可以向某些从设备发送请求 来自一台主机的请求通常会发送给一台从机 请求的主题可以是 mysystem slaveId req 因此从站可以订阅该主题 并且主站可以发
  • 两个人同时在 git 中处理一个文件[重复]

    这个问题在这里已经有答案了 可能的重复 当两个对等点同时将更改推送到同一个远程时 git 如何工作 https stackoverflow com questions 4643998 how git works when two peers
  • 当我启动程序时,Arduino IDE (Win10) 崩溃

    我的 Arduino IDE Win10 上的版本为 1 8 12 在启动时崩溃 运行arduino debug exe我收到此错误消息 C Program Files x86 Arduino gt arduino debug exe Se
  • 是否可以在一台机器上使用 GitHub 和 GitLab?

    我的账户位于GitHub and GitLab 我生成了 RSA 密钥并将其添加到我的帐户中GitLab 但现在我需要与GitHub在第二个项目上 我知道GitLab和GitHub都使用git 请告诉我是否可以在一台机器上使用 GitHub
  • Markdown/Github:作为列表子项的代码块的语法突出显示

    在Github MD中 如果我们想在列表的子级时启用代码块 我们需要用8个空格来表示它 但是如何让该代码块具有语法高亮功能呢 以下代码无法按预期工作 1 foo python print bar 2 bar python print bar
  • 将 sourceforge 票证迁移到 GitHub 问题 [重复]

    这个问题在这里已经有答案了 有谁知道有什么脚本 包可以自动将 sourceforge bug 功能请求跟踪器中的票证迁移到 GitHub 问题吗 可以将 sourceforge 票证导出为 XML 所以我想应该可以编写一个脚本来自动在 Gi
  • git push origin master 失败

    我正在尝试将现有文件夹上传到 gitHub 按照说明 我在 Windows 中输入了以下内容 git remote add origin email protected cdn cgi l email protection myname m
  • 图表贡献者为空

    我在 github 上有几个项目 但其中一些项目的贡献者图是空的 即使我的 gitconfig 设置了名称和电子邮件 https github com jlengrand batchWaterMarking graphs contribut
  • 自动更改 github 文件

    我制作了一个带有白名单的应用程序 withelist 位于 github 存储库上 只有一个文件 即 withelist 每次下载我的应用程序的用户想要被允许使用该应用程序时 都必须向我发送一个消息插入白名单 现在这个过程真的很慢 我想加快
  • 如何删除“致命:松散物体”?

    我的一个克隆存储库是从 git fsck 获取的 致命 松散对象 40bda4e3b79c3d7bf598df31d9e68470f97a3f79 存储在 git objects 40 bda4e3b79c3d7bf598df31d9e68
  • GitHub Web UI 中的“base”和“head”存储库是什么?

    GitHub 的 UI 相当不直观且考虑不周 所以这里有一个问题 什么是 头 回购 什么是 基础 回购 不知道是从哪一个抄来的 基础 和 头部 这两个词的意思是相同的 链表的 头 类似于树的 基 GitHub 有叉树和文件树 Head 和
  • Github README.md 和 readme.md - 如何删除其中一个?

    不知何故 我最终在 github 上有了 README md 和 readme md 现在这两者相互影响 所以我的 GitHub app 完全混乱了 Github网站没有任何文件删除功能 如何删除这些文件之一 只需删除其中一个文件并提交删除
  • Arduino Nano 33 IoT 的软件序列号

    我计划从旧的 5V Arduino Nano 迁移到新的 Arduino Nano 33 IoT 我已经使用软件串行 SoftwareSerial h 为旧的 5V Arduino Nano 编写了一个功能代码 以便与 Sim800L 模块
  • GitHub 未显示存储库中使用的语言

    我在 GitHub 上上传了 java 的 android studio 项目 但它没有显示语言部分 如何添加语言部分 为什么 GitHub 无法检测存储库中使用的语言 存储库链接 https github com QAZIMAAZARSH
  • 使用 Arduino 来操作 Android [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 有人尝试过让 Android 和 Arduino 相互通信吗 我在网上找到了几个项目 Amarino http www amarino tool
  • 如何在environment.yml中安装CRAN包

    我正在使用 miniconda 来管理数据科学包的安装 这是我现在已经建立的工作流程 所以我希望它也能在这种情况下工作 我也认为它可以工作 因为它应该在这样的情况下有所帮助 比纯 python 需要更多的依赖项 我想安装pythonCDT工
  • 无法在cordova项目中安装插件

    我面临一个大问题 Unable to install the phonegap plugins在我的科尔多瓦项目中 实际上昨天它仍然工作正常 现在 每当我尝试在我的 cordova 项目中使用 CLI 添加任何 cordova 插件时 我收
  • Git 子模块:[电子邮件受保护]:权限被拒绝(公钥)。致命:无法从远程存储库读取

    我有一个问题git submodule update init remote 我收到错误 权限被拒绝和克隆失败 但我将 SSH 密钥添加到了我的 github 存储库中 我可以拉 推 git 克隆 我拥有所有需要的访问权限 我使用操作系统

随机推荐