| 総重量31.18g |
フレーム・プロペラ・0615 モーター (JJRC H36 Eachine E010適用)一式に「ESP-FLY」 ベースのXIAO ESP32S3制御ドローン組立・動作確認。
参考サイト
回路図
XIAO ESP32S3
| 技適製品 |
・デュアルコア、最大 240 MHz で動作する 32 ビットプロセッサ
・完全な 2.4GHz Wi-Fi サブシステム BLE: Bluetooth 5.0、Bluetooth mesh
・オンチップ 8M PSRAM & 8MB Flash
・1x UART、1x IIC、1x IIS、1x SPI、11x GPIOs (PWM)、9x ADC、1x ユーザー LED、1x 充電 LED
1x リセットボタン、1x ブートボタン
ドライブ基板
●角型ランド両面スルーホールガラスコンポジット・ユニバーサル基板 Cタイプ(72×47mm)
XIAO ESP32S3取付ピンヘッダー
(PU・バンドで固定)
●ドライバーSI2302A・チップ抵抗・チップコンデンサ
SI2302A
●MOSFETドライバー
バッテリー
充電式リチウムポリマーバッテリー
アマゾン購入:HS210 3.7V 250mAhフレーム・モータ・MPU6050
アマゾン購入:フレーム・プロペラ・0615 モーター (JJRC H36 Eachine E010適用)一式
【JJRC H36 フレーム】検索
MPU6050をフレームに両面テープで固定。
モーター回転方向
0615モーター
●CWモーター(時計回転)
赤⊕ 青⊖
M2 M4
●CCWモーター(反時計回転)
白⊕ 黒⊖
M1 M3
ボードマネージャ
追加のボードマネージャーURL
【https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json】
【esp 32】
【バージョン3.2.0】インストール
ボード:"XIAO_ESP32S3"選択
MPU6050動作確認
プログラム Arduino IDE【ボード:XIAO_ESP32S3】
#include "MPU6050.h"
MPU6050 accelgyro;
int16_t ax, ay, az;//加速度 int16_tは2バイトの符号付き整数
int16_t gx, gy, gz;//角速度 同上
void setup() {
Wire.begin();
Serial.begin(115200);
accelgyro.initialize();//初期化
}
void loop() {
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print(ax); Serial.print(", ");
Serial.print(ay); Serial.print(", ");
Serial.print(az); Serial.print(" : ");
Serial.print(gx); Serial.print(", ");
Serial.print(gy); Serial.print(", ");
Serial.print(gz); Serial.println("");
delay(100);
}
RemoteXYアプリでM1~M2動作確認
.png)
●同ブログ関連記事:【RemoteXY使い方】
【Properties】【Configuration】設定変更
【Connection】Bluetooth
【Board】ESP32 based board
【Module】Integrated Bluetooth
【IDE】Arduino IDE
【Apply】実行
【Slider】をスマホ画面に貼付け、大きさ・色等を変更
(コントロール配置は5変数以内)
【Get source code】実行
コードをArduino IDEに貼付てスケッチを行う。
プログラム Arduino IDE【ボード:XIAO_ESP32S3】
//ESP32ボードマネージャ バージョン3.2.0
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_BLE
#include <BLEDevice.h>
// RemoteXY connection settings
#define REMOTEXY_BLUETOOTH_NAME "RemoteXY"
#include <RemoteXY.h>
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t const PROGMEM RemoteXY_CONF_PROGMEM[] = // 61 bytes V19
{ 255,5,0,0,0,54,0,19,0,0,0,0,110,1,106,200,1,1,5,0,
4,13,18,80,13,128,2,26,4,13,45,80,13,128,2,26,4,13,73,80,
13,128,2,26,4,13,99,80,13,128,2,26,1,40,131,24,24,0,2,31,
0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
int8_t slider_01; // from 0 to 100
int8_t slider_02; // from 0 to 100
int8_t slider_03; // from 0 to 100
int8_t slider_04; // from 0 to 100
uint8_t button_01; // =1 if button pressed, else =0, from 0 to 1
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define M1 D8
#define M2 D3
#define M3 D2
#define M4 D0
#define LED D10 //STSTUS_LED BAT_LED D6
void setup()
{
RemoteXY_Init ();
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
pinMode(M3, OUTPUT);
pinMode(M4, OUTPUT);
pinMode(LED, OUTPUT);
//ledcSetup(1, 1000, 8); // モータ 0CH 490Hz 8bit=0-255(PWM)
//ledcSetup(2, 1000, 8);
//ledcSetup(3, 1000, 8);
//ledcSetup(4, 1000, 8);
//ledcAttachPin(M1, 1); // モータ CH
//ledcAttachPin(M2, 2);
//ledcAttachPin(M3, 3);
//ledcAttachPin(M4, 4);
//ESP32バージョン3以降
ledcAttach(M1,1000,8);
ledcAttach(M2,1000,8);
ledcAttach(M3,1000,8);
ledcAttach(M4,1000,8);
delay(300);
}
void loop()
{
RemoteXY_Handler ();
int S1 = RemoteXY.slider_01; //M1スライダー
int S2 = RemoteXY.slider_02; //M2スライダー
int S3 = RemoteXY.slider_03; //M3スライダー
int S4 = RemoteXY.slider_04; //M4スライダー
digitalWrite(LED, RemoteXY.button_01);
S1 = map(S1, 0, 100, 0, 255);
S2 = map(S2, 0, 100, 0, 255);
S3 = map(S3, 0, 100, 0, 255);
S4 = map(S4, 0, 100, 0, 255);
//ledcWrite(1, S1); //M1
//ledcWrite(2, S2); //M2
//ledcWrite(3, S3); //M3
//ledcWrite(4, S4); //M4
//ESP32バージョン3以降
ledcWrite(M1, S1); //M1
ledcWrite(M2, S2); //M2
ledcWrite(M3, S3); //M3
ledcWrite(M4, S4); //M4
}

.png)
.drawio.png)

.png)
.png)
.png)
0 件のコメント:
コメントを投稿