liqinliqin's repos on GitHub
Lua · 12 人关注
COULD-coding-with-NodeMCU
COULD-coding-with-NodeMCU
8 人关注
Android-Source-Code-DoitCar
Android-Source-Code-DoitCar
3 人关注
beaconSpam_esp8266_WiFi-SSID_WiFi_Hotspots
Our WiFi hotspots advertisement machine can hold 32 wifi hotspots at a time, free DIY for things you want to promote. Comes with free OTG conversion head, you can edit the advertisement through the OTG head anywhere and anytime. Powered by USB, you can power it by power bank, laptop, socket and any device that can afford charging. No electricity inside, work with power bank plug in. Mini size like a U disk but big function, easy to store and carry around. No APP required. Just plug this to your phone and edit on the page freely, no APP required, easy and convenient to use. https://www.amazon.com/Hotspots-Advertisement-Billboard-Marketing-Promotion/dp/B09292P3T1
2 人关注
Arduino-Third-party-Libraries
Store the Arduino library functions
1 人关注
Arduino-Code
Upload an Arduino source
Java · 1 人关注
blockly-android-master
blockly
1 人关注
CAR
app
C · 1 人关注
channel3
ESP8266 Analog Broadcast Television Interface
1 人关注
cJSON
cJson源码和源码分析
C++ · 0 人关注
anwi
ANWI - All New Wireless IDS
Arduino · 0 人关注
arduino
firmata firmware for arduino
HTML · 0 人关注
Arduino-1
Arduino IDE for ESP8266
C++ · 0 人关注
arduino-sht
Unofficial repository for Sensirion Humidity and temperature sensor support on Arduino
C++ · 0 人关注
ArduinoMD5
The first easily-embeddable MD5 library for Arduino
CSS · 0 人关注
beiyuu.github.com
BeiYuu's Blog
JavaScript · 0 人关注
billryan.github.io
Blog at Github
0 人关注
blog
test
0 人关注
blog.github.io
本仓库以基于 docsify 构建的所见即所得博客,程序员👨🏻‍💻伙伴可以通过克隆仓库,配置基础的信息就可以拥有一个这样的博客了!
0 人关注
blog.github.io-1
fuzhengwei.github.io
0 人关注
book
Jupyter Notebook · 0 人关注
BookData
Python 和数据科学学习笔记
0 人关注
build-web-application-with-golang
A golang ebook intro how to build a web with golang
C · 0 人关注
chibios-stm32f407-discovery-mqtt
MQTT on STM32F407 Discovery with Ethernet
Python · 0 人关注
django-blog-zinnia
Simple yet powerful and really extendable application for managing a blog within your Django Web site.
Python · 0 人关注
docdev
Documentation for glpi developpers
0 人关注
docsify
🃏 A magical documentation site generator.
0 人关注
docsImage
0 人关注
docstest
Docs of W600
0 人关注
docte
a very lightweight markdown docs site reader
Jupyter Notebook · 0 人关注
doctest
liqinliqin
ONLINE

liqinliqin

www.doit.am
🏢  深圳四博智联科技有限公司 / 研发负责人
V2EX 第 23618 号会员,加入于 2012-07-18 09:41:55 +08:00
今日活跃度排名 822
机器人、物联网
liqinliqin 最近回复了
我开发的 全套,需要资料加 V andy433928
APP+硬件原型周期一上午可以完成
这段代码实现了以下功能:

控制马达的转速,可以通过 motorSpeed 变量设置马达的转速。
检测温度传感器的数据,通过 tempSensorPin 引脚读取温度传感器的值。
通过 BLE 服务将温度数据发送给 BLE 中心设备。
检测运动传感器的状态,通过 motionSensorPin 引脚读取运动传感器的状态。
监测开关机按键状态,通过 powerButtonPin 引脚检测开关机按键的状态,并通过 BLE 服务将开关机状态发送给 BLE 中心设备。
#include <Arduino.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>

// 定义 BLE 服务、特征和 UUID
BLEServer* pServer;
BLEService* pService;
BLECharacteristic* pCharacteristic;

// 定义马达控制参数
const int motorPin = 12; // 马达控制引脚
int motorSpeed = 0; // 马达转速

// 定义温度传感器引脚
const int tempSensorPin = 34; // 温度传感器引脚

// 定义运动检测参数
const int motionSensorPin = 35; // 运动传感器引脚
int motionDetected = 0; // 运动检测结果

// 定义开关机按键参数
const int powerButtonPin = 27; // 开关机按键引脚
bool powerState = false; // 开关机状态

// 定义 BLE 特征的 UUID
#define CHARACTERISTIC_UUID "1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p"

// 回调函数,当有 BLE 中心设备连接或断开连接时调用
class MyServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
Serial.println("BLE 设备已连接");
};

void onDisconnect(BLEServer* pServer) {
Serial.println("BLE 设备已断开连接");
}
};

// 初始化 BLE 服务
void initBLE() {
BLEDevice::init("ESP32_BLE_Server");
pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());

pService = pServer->createService(BLEUUID((uint16_t)0x180F));
pCharacteristic = pService->createCharacteristic(
BLEUUID((uint16_t)0x2A19),
BLECharacteristic::PROPERTY_READ
);

pCharacteristic->setValue(0); // 初始化特征值为 0
pService->start();
BLEAdvertising* pAdvertising = pServer->getAdvertising();
pAdvertising->start();
}

// 初始化硬件
void setup() {
Serial.begin(115200);
initBLE();
pinMode(motorPin, OUTPUT);
pinMode(tempSensorPin, INPUT);
pinMode(motionSensorPin, INPUT);
pinMode(powerButtonPin, INPUT_PULLUP);
}

// 主循环
void loop() {
// 读取温度传感器数据
float temperature = analogRead(tempSensorPin) * 3.3 / 4095 * 100; // 假设温度传感器为模拟传感器,实际情况请根据传感器类型调整

// 检测运动传感器
motionDetected = digitalRead(motionSensorPin);

// 检测开关机按键状态
if (digitalRead(powerButtonPin) == LOW) {
powerState = !powerState; // 切换开关机状态
}

// 发送数据到 BLE 中心设备
pCharacteristic->setValue(temperature); // 将温度值写入 BLE 特征
pCharacteristic->notify();

delay(1000); // 等待 1 秒钟
}
37 天前
回复了 SssaltedFish 创建的主题 iPhone 苹果定位漂移怎么办
推测可能把几公里外的路由拿到办公室用了,根据路由 mac 地址定位了
51 天前
回复了 LiuJiang 创建的主题 香港 香港开户
不买保险,就要找中介,是开美元的账号吗
@Ericality #19 我们主要出模组,有的工厂买过去,自己生产销售的
@Ericality #9 从什么渠道购买的
@hh4646908 #5 可以加 V andy433928 我安排一个技术一对一看下
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5401 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms · UTC 03:41 · PVG 11:41 · LAX 20:41 · JFK 23:41
Developed with CodeLauncher
♥ Do have faith in what you're doing.