esp32
使用ESP32內建的藍芽與裝在Arduino系列板子的模組HC-05配對。
#include "esp_bt_device.h"
#include "esp_bt_main.h"
bool initBluetooth() {
if (!btStart()) {
Serial.println("Failed to initialize controller");
return false;
}
if (esp_bluedroid_init() != ESP_OK) {
Serial.println("Failed to initialize bluedroid");
return false;
}
if (esp_bluedroid_enable() != ESP_OK) {
Serial.println("Failed to enable bluedroid");
return false;
}
}
void printDeviceAddress() {
const uint8_t* point = esp_bt_dev_get_address();
// This function takes no arguments and
// returns the six bytes of the Bluetooth device address.
// Note that the six bytes will be returned as a pointer to an array of uint8_t,
// which we will store on a variable.
for (int i = 0; i < 6; i++) {
char str[3];
sprintf(str, "%02X", (int)point[i]);
Serial.print(str);
if (i < 5) {
Serial.print(":");
}
}
}
void setup() {
Serial.begin(115200);
initBluetooth();
printDeviceAddress();
}
void loop() {}
#include "BluetoothSerial.h"
#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;
char *pin = "1234"; //建立連接時的密碼,不設置與hc05連接不上
void setup() {
Serial.begin(115200);
SerialBT.setPin(pin);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
#include <SoftwareSerial.h>
// Pin10為RX,接HC05的TXD
// Pin11為TX,接HC05的RXD
SoftwareSerial BT(10, 11);
char val;
void setup() {
Serial.begin(38400);
Serial.println("BT is ready!");
// HC-05默認,38400
BT.begin(38400);
}
void loop() {
if (Serial.available()) {
val = Serial.read();
BT.print(val);
}
if (BT.available()) {
val = BT.read();
Serial.print(val);
}
}
AT+ORGL
AT+ROLE=1
AT+PSWD=1234
AT+INIT
AT+CMODE=0
:
改為冒號,
AT+BIND = 7C87,CE,4AB68E
原因 : ESP32的默認程式存儲區域大小為1M,超過這個大小就會報錯。
解決方法:
修改分區表,教學文。
打開Arduino IDE,給APP分區較大的空間。
報告截止日期 : 2022/01/18 成果發表 demo影片連結 程式原碼 研究動機 新冠疫情肆虐全球,大減餐廳的內用生意,而外送訂餐儼然已成為生活常態,而各外送平台為了避免外送時造成的接觸感染,提出了無接觸外送 - Foodpanda在領取商品時,外送員與消費者保持1公尺以上的距離。而Uber eat採用線上支付或是放在門口。 但同時無接觸外送也引發了某些問題 - 放在門把上、放在地上、被偷走、使用非實體支付遭重複扣款,因此以此問題為出發點,我們想實現全自動的防疫送餐車,讓消費者不需要直接與外送員面對面取餐,減少染疫風險。
Jan 24, 2022最後更新日期 : 2022/01/20 時間 內容 2021/11/05(五) 第1波模組採購 2021/11/11(四) 團體討論、永勝需焊接秤重、RFID、GPS模組
Jan 19, 2022報告截止日期 : 2021/12/23 示意圖 產品概念圖 模組之間通訊架構圖 系統架構 (紅色代表修改或新增) 車上模組功能
Jan 19, 2022報告截止日期 : 2021/11/04 簡述 自動領取餐點自走車,減少染疫的風險。 功能與用到的模組 車體開發板 Arduino Mega 2560 功能 模組 通訊
Jan 17, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up