2020-10-14 10:53:07 [显示全部楼层]
查看: 160|回复: 1

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

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

202010144080..png

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

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

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

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




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


202010142756..png

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


202010147890..png

【转发后记】

张怀华老师是我在河南省中小学信息能力提升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
202010145444..png
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.
[C] 纯文本查看 复制代码
//#############################################################################
//In this sketch a BLE server with one service and one characeristic is created.
//The analog input (pin 36) is readout periodically. 
//#############################################################################

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <esp_system.h>
#include <BLE2902.h>


//uuid's can be generated on [url=https://www.uuidgenerator.net/]https://www.uuidgenerator.net/[/url]
#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "59f51a40-8852-4abe-a50f-2d45e6bd51ac"
BLECharacteristic *aCharacteristic;

void setup() {
 Serial.begin(9600);

 //BLE server is being initialized
 //create one BLEService and one Characteristic
 BLEDevice::init("Arduino");
 BLEServer *aServer = BLEDevice::createServer();
 
 //uuid for the BLE service is set
 BLEService *aService = aServer->createService(SERVICE_UUID);
 //uuid for the BLE characteristic is set
 //the characteristics properties are defined
 aCharacteristic = aService->createCharacteristic(
                     CHARACTERISTIC_UUID,
                     BLECharacteristic::PROPERTY_READ   |
                     BLECharacteristic::PROPERTY_WRITE  |
                     BLECharacteristic::PROPERTY_NOTIFY  
                   );
 aCharacteristic->addDescriptor(new BLE2902());

 //BLE server is being started
 aService->start();
 BLEAdvertising *aAdvertising = aServer->getAdvertising();
 aAdvertising->start();

}

void loop() {

 //analog Input 36 is read out and the measured voltage is calculated
 
 float voltage = 3.3*analogRead(36)/4095;

 aCharacteristic->setValue(voltage);
 aCharacteristic->notify();
 delay(100);

}


rzyzzxw  版主
 楼主|

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

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

使用道具 举报

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

本版积分规则

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

硬件清单

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

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

mail