For whatever reason the delay function is not working (it is not delaying at all) with my ESP32 development board. Has anyone come across a similar issue before? It's not working with other sketches, in either the loop or set up functions. A sample sketch:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <BleMouse.h>
// mouse object
BleMouse ble("test", "me");
/** I2C pins **/
#define I2C_SDA 33
#define I2C_SCL 32
// I2C object
TwoWire wire_custom = TwoWire(0);
// Sensor object
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &wire_custom);
/**************************************************************************/
function definitions
...
/**************************************************************************/
void setup(void)
{
wire_custom.begin(I2C_SDA, I2C_SCL, 400000);
Serial.begin(115200);
ble.begin();
if (!bno.begin())
{
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while (1);
}
delay(1000);
bno.setExtCrystalUse(true);
// updating range
bno.setMode(Adafruit_BNO055::OPERATION_MODE_CONFIG);
delay(1000);
write_register (0x28, 0x0A, 0b00111010);
bno.setMode(Adafruit_BNO055::OPERATION_MODE_NDOF);
delay(10000);
byte result = read_register (0x28, 0x0A, 1);
Serial.print(result);
Serial.print("\n");
Serial.print("\n");
}
/**************************************************************************/
void loop(void)
{
sensor_calibration ();
sensor_data (x_placeholder, y_placeholder);
transform_sensor_data (x_placeholder, y_placeholder, x, y);
if (ble.isConnected()) {
ble.move(x, y);
}
}
1 Answer 1
Placing a delay within any built-in function pertaining to the wireless radio will only halt operations on the Wi-Fi core
or core0
. Your main loop code wont be affected by a delay placed in core0
. It will only halt wireless operations.
I ran into a similar issue and it took a while for me to put it together. I use global variables when passing info between core0
and core1
.
- Wireless runs on
core0
and - Your main code runs on
core1
(unless otherwise specified in the setup).
-
How is this relevant to the question?StarCat– StarCat2024年05月07日 09:48:04 +00:00Commented May 7, 2024 at 9:48
delay()
is at fault?loop()
in the above code doesn't use a delay, and has no output either.