ESP32主站通过蓝牙设置ESP32从站红绿灯时间,其中,两个参数由主站串口输入,蓝牙发送,从站蓝牙接收。主从站单向通信。

硬件电路连接:

ESP32主站:数据线连PC

ESP32从站:

设备:

oled:
VCC-3.3V

GND-GND

SDA-D15

SCL-D4

红绿灯:

G-13

Y-12

R-14

软件:

ESP32主站:

//主机模式
#include 
#include 
//#include
#include 
#include 
#include 
#include 
#include 
#include 
#include
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;

#define Master 1    //主从机模式选择 1主机 0从机
String SlaveName="ESP32_SLAVE";


int RT;
int GT;
String input_string;
void Bluetooth_Event(esp_spp_cb_event_t event, esp_spp_cb_param_t *param);  //蓝牙事件回调函

你可能感兴趣的:(ESP32,RGY灯,BT)