标号 名称 功能描述
1 串口烧录区 VCC:3.3V输入
GND:供电地
IO0:RX(3.3V)
IO1:TX (3.3V)
2 I2C/其他传感器(纽扣电池供电) VBAT:纽扣电池正极
IO3/IO7:可设置为SDA/SCL或者数字/模拟输入输出
3 I2C/其他传感器(动态电源控制) SW0:可配置动态电源,仅在广播时输出高电平为传感器供电
IO4/IO5:可设置为SDA/SCL或者数字/模拟输入输出
4 数字/模拟传感器 SW1:可配置动态电源,仅在广播时拉低
IO2:可设置为SDA/SCL
IO6:可设置为数字/模拟输入,此引脚内置分压电阻,推荐接入模拟量传感器
5 上拉电阻选择焊盘 IO3/IO7/IO4/IO5/IO2上拉电阻焊点,连接后对应IO接到上拉电阻,默认不接上拉。
Fermion 和Gravity系列传感器的上拉电阻均在传感器端
6 电池座 CR2032纽扣电池。
正极连接VBAT,负极连接GND
7 NOTE 信标信息标记处,可以标记所烧录的信标的关键信息

数字/模拟传感器使用教程

以自定义数据格式为例,通过手机app和ESP32获取传感器数据。

一、软硬件准备

二、配置传感器信标

*注:模块仅能烧录一次,在未确定配置信息前不要直接点击"Burn/Program"进行烧录。可通过"Run inRAM"进行测试,在烧录前"Run in RAM"可无限次使用,断电后系统复位。

模块的ADC接口输入电压不可超过1.6V,若接入的传感器电压可能会超过1.6V,则需将传感器接至GPIO6,GPIO6添加了2.06倍的分压电阻,支持输入电压最大3.3V。

三、手机app获取数据

四、ESP32获取数据

/*
   Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
   Ported to Arduino ESP32 by Evandro Copercini
   Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo
*/

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <BLEEddystoneURL.h>
#include <BLEEddystoneTLM.h>
#include <BLEBeacon.h>
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))

float Sensor_Data;
int scanTime = 5; //In seconds
BLEScan *pBLEScan;

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
{
    void onResult(BLEAdvertisedDevice advertisedDevice)
    {
      if (advertisedDevice.haveName())
      {
        if(String(advertisedDevice.getName().c_str()) == "Fermion:Sensor Beacon"){
          Serial.print("Device name: ");
          Serial.println(advertisedDevice.getName().c_str());
          std::string strManufacturerData = advertisedDevice.getManufacturerData();
          uint8_t cManufacturerData[100];
          strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0);
          Serial.printf("strManufacturerData: %d ", strManufacturerData.length());
            for (int i = 0; i < strManufacturerData.length(); i++)
            {
              Serial.printf("[%X]", cManufacturerData[i]);
            }
            Sensor_Data = int(cManufacturerData[2]<<8 | cManufacturerData[3]);
            Serial.println();
            Serial.print("Voltage:");Serial.print(int(Sensor_Data));Serial.println("mV");   
            Serial.print("Temp_LM35:");Serial.print(Sensor_Data/10);Serial.println("℃");      
            Serial.println("------------------");       
        }        
      }
    }
};
void setup()
{
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop()
{
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
  delay(2000);
}

五、确认数据并烧录

I2C传感器使用教程

以自定义数据格式为例,通过手机app和ESP32获取I2C传感器数据。

一、软硬件准备

*注:因配置文件错误导致烧录后模块变砖,由用户自行承担责任。模块仅能烧录一次,在未确定配置信息前请不要点击"Burn/Program"进行烧录。

I2C传感器不支持"Run in RAM"测试只能直接烧录,推荐直接使用DFRobot提供的传感器样例配置文件,我们会不断丰富官方示例,若要使用未提供配置文件的I2C传感器,请仔细阅读Wiki中的教程使用。

二、配置传感器信标

/*
   Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
   Ported to Arduino ESP32 by Evandro Copercini
   Changed to a beacon scanner to report iBeacon, EddystoneURL and EddystoneTLM beacons by beegee-tokyo
*/

#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <BLEEddystoneURL.h>
#include <BLEEddystoneTLM.h>
#include <BLEBeacon.h>
#define ENDIAN_CHANGE_U16(x) ((((x)&0xFF00) >> 8) + (((x)&0xFF) << 8))

float TemperatureData,HumidityData;
float Temperature,Humidity;

//设置ESP32 5秒扫描一次蓝牙设备
int scanTime = 5; //In seconds
BLEScan *pBLEScan;

class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks
{
    void onResult(BLEAdvertisedDevice advertisedDevice)
    {
      if (advertisedDevice.haveName())
      {
        if(String(advertisedDevice.getName().c_str()) == "SHT40")//扫描是否有名为SHT40的蓝牙设备
        {
          Serial.print("Device name: ");
          Serial.println(advertisedDevice.getName().c_str());
          std::string strManufacturerData = advertisedDevice.getManufacturerData();
          uint8_t cManufacturerData[100];
          strManufacturerData.copy((char *)cManufacturerData, strManufacturerData.length(), 0);
          Serial.printf("strManufacturerData: %d ", strManufacturerData.length());

          for (int i = 0; i < strManufacturerData.length(); i++)
          {
            Serial.printf("[%X]", cManufacturerData[i]);
          }

          //从SHT40获取原始数据
          TemperatureData = int(cManufacturerData[2]<<8 | cManufacturerData[3]);
          HumidityData = int(cManufacturerData[5]<<8 | cManufacturerData[6]);

          //将原始数据转化为温湿度数据
          Temperature = (175 * TemperatureData/65535) - 45;
          Humidity = (125 * HumidityData/65535) - 6;

          Serial.println();
          Serial.print("TemperatureData:");Serial.print(Temperature);Serial.println("℃");   
          Serial.print("HumidityData:");Serial.print(Humidity);Serial.println("%");      
          Serial.println("------------------");       
        }        
      }
    }
};
void setup()
{
  Serial.begin(115200);
  Serial.println("Scanning...");

  BLEDevice::init("");
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(100);
  pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop()
{
  // put your main code here, to run repeatedly:
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
  delay(2000);
}

动态电源控制

APP弹窗提示

Fermion:传感器信标支持APP弹窗提示,您可以设置阈值触发手机提示,详情请见IN100官方教程

NanoBeacon Config Tool使用说明

关于NanoBeacon Config Tool更多用法,可查看软件的用户指南:NanoBeacon Config Tool User Guide EN.pdf

用户指南中使用的是“Beacon development kit”,在使用Fermion: BLE 传感器信标时,直接使用3.3V USB-TTL工具即可:

常见问题

文末的Gitee仓库链接中存放着我们测试过的传感器示例代码和配置文件。

我们会不断丰富官方例程清单,如您有新的传感器兼容性需要也可以联系您采购渠道的技术支持或者直接向techsupport@dfrobot.com发送需求邮件。 我们会在评估后尽快予以您答复。

更多