2020-10-14 10:53:07 [显示全部楼层]
4609浏览
查看: 4609|回复: 2

[ESP8266/ESP32] 利用Phyphox和ESP32蓝牙做分压电路实验

[复制链接]
【本文经焦作创客张怀华老师授权转发】
原文链接:

利用Phyphox和ESP32蓝牙做分压电路实验图1

近日,微主刚刚学会了利用蓝牙技术将开发板采集的数据传输给Phyphox的方法,就趁热打铁,复习巩固,做了一个电位计的分压实验。

实验中用到的面包板、杜邦线和电位计都是焦作市创客教育名师工作室指导专家、顺时针魔方俱乐部技术总监李璐老师赠送的。

用杜邦线将电位计的两侧固定引脚与开发板ESP32的V5脚和GND脚相连,将可动引脚与IO33脚相连。

套用上次“电容器充放电实验”的Phyphox实验程序和ESP32源码,将它们修改成适合“分压电路实验”的需要。然后将实验的ESP32源码编译烧录到开发板上,将Phyphox实验程序加载到Phyphox系统内。




然后,将智能手机中的Phyphox实验与开发板ESP32建立蓝牙连接,Phyphox就可以接受和处理ESP32传来的电压数据了。


利用Phyphox和ESP32蓝牙做分压电路实验图2

有了蓝牙技术的支持,Phyphox可以将智能手机转化为一台可以随身携带的数据分析器和图形显示器。


利用Phyphox和ESP32蓝牙做分压电路实验图3

【转发后记】

张怀华老师是我在河南省中小学信息能力提升2.0工程专家培训中认识的,张老师任教于焦作十一中学,在教学中不断进行创新技术与课堂教学整合探索与实践。开源电子与学科融合的创新学科教学是创客教育的一个发展方向,张老师的探索为我们指明了方向。
张老师的探索是为了解决Phyphox内置传感器不足而采取的一种补救措施,其实除了电学实验以外,Phyphox的应用范围已经非常广了,基本上把手机的科学探究能力发挥到了极限。
张老师说:phyphox是目前智能手机做科学实验最好的app。高中传感器部分是专门的一章,教材上有,但是从来不讲,直接跳过。以后传感器这部分,就不要跳过去了,可以好好地讲一讲。



【相关资源】
phyphoxWIKI:

以下复制自WIKI,仅供参考,请以原文为准。

Using a ESP32:
In this example we use the HIMALAYA ESP32 Dev Board. Since the ESP32 isn't an official Arduino Board, a library to support this micro-controller in the Arduino-IDE has to be used. To do so start the Arduino-IDE and open: File > Preferences Then past the following link into the Field “Additional Board Manager URLs:”
Afterwards open the Board Manager:
Tools > Board > Boardmanager
利用Phyphox和ESP32蓝牙做分压电路实验图4
Search for ESP32 platform and install the library. Choose the Board DOIT ESP32 DEVKIT V1
Tools > Board: ”DOIT ESP32 DEVKIT V1”
To check if the library is installed correctly, flash one of the basic examples on the micro-controller:
File > Examples > Basic > Blink
After the sketch is flashed on the ESP32 the LED should start flashing. Afterwards a library has to be installed in order to use BLE on the ESP32. For Example the BLE library by Neil Kolban which can be found on github:
Download the library as a zip file. These zip file can be included directly via
(In the Arduino IDE) Sketch > Include Library > Add .ZIP Library... > select the downloaded file > Open
After both libraries are installed the following sketch can be used to initialize a Bluetooth Low Energy server with one service and one characteristic. In this sketch the analog input on Pin 36 is readout and the value is written into the characteristic. The additional phyphox file subscribes to notifications from this characteristic and plots the received values.

  1. //#############################################################################
  2. //In this sketch a BLE server with one service and one characeristic is created.
  3. //The analog input (pin 36) is readout periodically.
  4. //#############################################################################
  5. #include <BLEDevice.h>
  6. #include <BLEUtils.h>
  7. #include <BLEServer.h>
  8. #include <esp_system.h>
  9. #include <BLE2902.h>
  10. //uuid's can be generated on <a href="https://www.uuidgenerator.net/" target="_blank">https://www.uuidgenerator.net/</a>
  11. #define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
  12. #define CHARACTERISTIC_UUID "59f51a40-8852-4abe-a50f-2d45e6bd51ac"
  13. BLECharacteristic *aCharacteristic;
  14. void setup() {
  15. Serial.begin(9600);
  16. //BLE server is being initialized
  17. //create one BLEService and one Characteristic
  18. BLEDevice::init("Arduino");
  19. BLEServer *aServer = BLEDevice::createServer();
  20. //uuid for the BLE service is set
  21. BLEService *aService = aServer->createService(SERVICE_UUID);
  22. //uuid for the BLE characteristic is set
  23. //the characteristics properties are defined
  24. aCharacteristic = aService->createCharacteristic(
  25.                      CHARACTERISTIC_UUID,
  26.                      BLECharacteristic::PROPERTY_READ   |
  27.                      BLECharacteristic::PROPERTY_WRITE  |
  28.                      BLECharacteristic::PROPERTY_NOTIFY  
  29.                    );
  30. aCharacteristic->addDescriptor(new BLE2902());
  31. //BLE server is being started
  32. aService->start();
  33. BLEAdvertising *aAdvertising = aServer->getAdvertising();
  34. aAdvertising->start();
  35. }
  36. void loop() {
  37. //analog Input 36 is read out and the measured voltage is calculated
  38. float voltage = 3.3*analogRead(36)/4095;
  39. aCharacteristic->setValue(voltage);
  40. aCharacteristic->notify();
  41. delay(100);
  42. }
复制代码

rzyzzxw  版主
 楼主|

发表于 2020-10-18 08:32:31

这个APP很棒,我还在学习中。让它和掌控板结合,是我的目标。
回复

使用道具 举报

hmilycheng  高级技师

发表于 2021-7-2 18:35:00

这个APP太赞了!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail