1

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);
 }
}
asked May 10, 2021 at 18:50
7
  • 1
    What does "not working" mean? Not delaying at all? Delaying forever? Too short a delay? Too long a delay? And what makes you believe that delay() is at fault? Commented May 10, 2021 at 19:01
  • 1
    how do you know that the delay function does not work? ... you do not have any debugging code that would verify that Commented May 10, 2021 at 19:01
  • Sorry I didn't clarify it is not delaying at all regardless of what amount I set it to. Commented May 10, 2021 at 19:03
  • How would you know? The loop() in the above code doesn't use a delay, and has no output either. Commented May 10, 2021 at 19:32
  • 1
    Gotta be something to do with that register you set, or the setcrystal thing or one of those libraries. To prove it, just upload a dead simple delay sketch and see if it works then. Commented May 10, 2021 at 23:29

1 Answer 1

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).
Rohit Gupta
6122 gold badges5 silver badges18 bronze badges
answered May 5, 2024 at 21:20
1
  • How is this relevant to the question? Commented May 7, 2024 at 9:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.