Hi,
I have the following sketch for an Arduino ESP32 mounted on an Alvik:
#include <ArduinoBLE.h>
#include "Arduino_Alvik.h"
BLEService service("19B10000-E8F2-537E-4F6C-D104768A1214"); // Bluetooth® Low Energy LED Service
// Bluetooth® Low Energy LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
Arduino_Alvik alvik;
int brakeCt, rotateLeftCt, rotateRightCt;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BLE.begin()) {
Serial.println("starting Bluetooth® Low Energy module failed!");
while (1);
}
BLE.setLocalName("Alvik");
BLE.setAdvertisedService(service);
service.addCharacteristic(switchCharacteristic);
BLE.addService(service);
switchCharacteristic.writeValue(0);
BLE.advertise();
Serial.println("BLE Alvik Peripheral");
alvik.begin();
}
void loop() {
BLEDevice central = BLE.central();
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
while (central.connected()) {
if (switchCharacteristic.written()) {
Serial.println(switchCharacteristic.value());
if (switchCharacteristic.value() == 119) {
alvik.drive(10, 0.0);
brakeCt = 0;
switchCharacteristic.writeValue(0);
} else if (switchCharacteristic.value() == 97) {
rotateLeftCt++;
if (rotateLeftCt > 1)
switchCharacteristic.writeValue(0);
else alvik.rotate(45);
} else if (switchCharacteristic.value() == 100) {
rotateRightCt++;
if (rotateRightCt > 1)
switchCharacteristic.writeValue(0);
else alvik.rotate(-45);
} else if (switchCharacteristic.value() == 119) {
alvik.drive(-10, 0.0);
} else {
brake();
}
} else brake();
}
}
}
void brake() {
brakeCt++;
if (brakeCt > 5) {
alvik.brake();
brakeCt = 0;
rotateLeftCt = 0;
rotateRightCt = 0;
}
delay(100);
}
For some reason, it prints "BLE Alvik Peripheral" but then proceeds to print the battery percentage of the Alvik instead of running the rest of the sketch. When trying to burn the boot loader I get this error:
raceback (most recent call last):
File "esptool.py", line 34, in
File "esptool/init.py", line 1032, in _main
File "esptool/init.py", line 674, in main
File "esptool/init.py", line 921, in get_default_connected_device
File "esptool/loader.py", line 640, in connect
File "esptool/loader.py", line 541, in _connect_attempt
File "serial/serialutil.py", line 591, in flushOutput
File "serial/serialposix.py", line 692, in reset_output_buffer
termios.error: (6, 'Device not configured')
[4930] Failed to execute script 'esptool' due to unhandled exception!
Failed programming: uploading error: exit status 1