i2cWriteReadNonstop VSCode-PlatformIO ESP32

Intel NUC11
Ubuntu 22.04.2 LTS - jammy
VS Code - PlatformIO

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit BNO055@^1.6.1
SPI
monitor_filters =
default
time
log2file
monitor_speed = 115200

Hello All,

I recently purchased the Adafruit BNO055 Absolute Orientation Sensor. I wrote my own little library to work with the BNO055 and it worked great. For a few weeks. The other day, out of the blue, I started getting this i2cWriteReadNonstop error messages. These messages occur after the bno.begin() call. After the error messages, the program continues to run just fine.

After several hours of trouble shooting and hunting around the different forums I decided to try one of the example programs (something I should have done first). I used the “read_all_data” sketch. I loaded and ran it from the Arduino IDE and it works just fine. When I use the VSCode with PlatformIO, I get the i2cWriteReadNonstop errors. I want to emphasize that this was not an issue for the first few weeks and I don’t know what might have changed on the VSCode PlatformIO side.

Below is the serial monitor output. Note the message “Orientation Sensor Test” which occurs before bno.begin(). I also wrapped the calls to getEvent() in some serial prints to identify the start and stop of all of those calls and you can see the error messages occur before that. So the problem occurs in or immediately after bno.begin().

Any trouble shooting ideas are greatly appreciated.

Here is the serial monitor output:

15:38:25.803 > rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:38:25.808 > configsip: 0, SPIWP:0xee
15:38:25.810 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:38:25.816 > mode:DIO, clock div:2
15:38:25.818 > load:0x3fff0030,len:1184
15:38:25.820 > load:0x40078000,len:13192
15:38:25.823 > load:0x40080400,len:3028
15:38:25.825 > entry 0x400805e4
15:38:25.972 > Orientation Sensor Test
15:38:25.975 >
15:38:26.035 > [ 81][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.046 > [ 92][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.056 > [ 102][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.066 > [ 112][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.076 > [ 122][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.086 > [ 132][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.096 > [ 142][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.106 > [ 152][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.116 > [ 162][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.126 > [ 172][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.136 > [ 182][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.146 > [ 192][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.156 > [ 202][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.166 > [ 212][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.176 > [ 222][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.186 > [ 232][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.196 > [ 242][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.206 > [ 252][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.216 > [ 262][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.226 > [ 272][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.236 > [ 282][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.246 > [ 292][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.256 > [ 302][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.266 > [ 312][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.276 > [ 322][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.286 > [ 332][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.296 > [ 342][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.306 > [ 352][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.316 > [ 362][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.326 > [ 372][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.336 > [ 382][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.346 > [ 392][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.356 > [ 402][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.366 > [ 412][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.376 > [ 422][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.386 > [ 432][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.396 > [ 442][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.406 > [ 452][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.416 > [ 462][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.426 > [ 472][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.436 > [ 482][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.446 > [ 492][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.456 > [ 502][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.466 > [ 512][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.476 > [ 522][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.486 > [ 532][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.496 > [ 542][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:26.506 > [ 552][E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1
15:38:27.639 > Calling getEvent() for all sensor data
15:38:27.647 > Finished getEvent() for all sensor data
15:38:27.652 > Orient: x= 0.00 | y= 0.06 | z= 2.62
15:38:27.656 > Gyro: x= 0.00 | y= 0.00 | z= 0.00
15:38:27.658 > Linear: x= 0.00 | y= 0.00 | z= -0.28
15:38:27.661 > Mag: x= 32.50 | y= -1.50 | z= -5.06
15:38:27.665 > Accl: x= 0.00 | y= -0.46 | z= 9.50
15:38:27.668 > Gravity: x= 0.01 | y= -0.45 | z= 9.79
15:38:27.671 >
15:38:27.671 > temperature: 29
15:38:27.673 >
15:38:27.673 > Calibration: Sys=0 Gyro=3 Accel=0 Mag=0
15:38:27.676 > –
15:38:27.772 > Calling getEvent() for all sensor data
15:38:27.780 > Finished getEvent() for all sensor data
15:38:27.784 > Orient: x= 0.00 | y= 0.06 | z= 2.62
15:38:27.788 > Gyro: x= 0.00 | y= 0.00 | z= 0.00
15:38:27.791 > Linear: x= 0.00 | y= -0.01 | z= -0.24
15:38:27.794 > Mag: x= 32.06 | y= -1.50 | z= -5.06
15:38:27.797 > Accl: x= 0.02 | y= -0.46 | z= 9.54
15:38:27.800 > Gravity: x= 0.01 | y= -0.45 | z= 9.79
15:38:27.804 >
15:38:27.804 > temperature: 29
15:38:27.805 >
15:38:27.806 > Calibration: Sys=0 Gyro=3 Accel=0 Mag=0
15:38:27.809 > –
15:38:27.905 > Calling getEvent() for all sensor data
15:38:27.911 > Finished getEvent() for all sensor data
15:38:27.916 > Orient: x= 0.00 | y= 0.06 | z= 2.62
15:38:27.919 > Gyro: x= 0.00 | y= -0.00 | z= -0.00
15:38:27.922 > Linear: x= 0.00 | y= -0.02 | z= -0.21
15:38:27.925 > Mag: x= 33.56 | y= -2.56 | z= -4.75
15:38:27.929 > Accl: x= 0.02 | y= -0.47 | z= 9.57
15:38:27.932 > Gravity: x= 0.01 | y= -0.45 | z= 9.79
15:38:27.935 >
15:38:27.935 > temperature: 29
15:38:27.937 >
15:38:27.937 > Calibration: Sys=0 Gyro=3 Accel=0 Mag=0

Then let’s compare the two. Please post

  • The esp32 version as shown in Arduino IDE → Tools → Board → Board Manager → esp32
  • A screenshot of the used Arduino IDE → Tools settings
  • the exact used version of the Adafruit BNO0555, as found in <Documents folder>/Arduino/library/Adafruit ..../library.properties
  • your full platformio.ini

Thank you for your attention to this matter. Below is the information you requested.

ESP32 Dev Module

image

name=Adafruit BNO055
version=1.6.1
author=Adafruit info@adafruit.com
maintainer=Adafruit info@adafruit.com
sentence=Library for the Adafruit BNO055 Absolute Orientation Sensor.
paragraph=Designed specifically to work with the Adafruit BNO055 Breakout, and is based on Adafruit’s Unified Sensor Library.
category=Sensors
url=GitHub - adafruit/Adafruit_BNO055: Unified sensor driver for the Adafruit BNO055 orientation sensor breakout
architectures=*
depends=Adafruit Unified Sensor, Adafruit BusIO

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
adafruit/Adafruit Unified Sensor@^1.1.9
adafruit/Adafruit BNO055@^1.6.1
SPI
monitor_filters =
default
time
log2file
monitor_speed = 115200

I may be wrong about this. I first noticed the error messages when I pressed the reset button in order to see some serial output I had added to the start of setup(). So it may have been happening all along and I just never noticed it until I pressed the reset button.

Did you give up on me?

Hi @rtalan and @maxgerhardt,

Apologies if this is the wrong place to discuss. If so let me know and I will start a new post.

I have what appear to be the same symptoms. ie continuous repeated serial output of

[E][Wire.cpp:499] requestFrom(): i2cWriteReadNonStop returned Error -1

for context:

  1. my project has been in platformio for more than 3 years. I last did a build that worked without issue on 26 April 2023.
  2. Last week on 2 Jun 2023 I made changes and the application now fails as noted above. I reverted the code to the previous known working commit, as well as a few earlier commits, and have the failure above each time.
  3. I am using an espressif devboard (esp32 devkitc ve). I have binaries of the previous known good firmware (built prior to 26 April 2023) which work without issue if I manually load with esptool.py

My project’s plaformio.ini (which has not changed for >12 months) is:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
extra_scripts =
    pre:build_scripts/auto_firmware_version.py

lib_deps = 
	bblanchon/ArduinoJson@^6.17.2
	FS
	SPIFFS
	davetcc/IoAbstraction@^1.6.7
    paulstoffregen/Time @ ^1.6.1
test_port = COM13
test_ignore = test_desktop
build_flags = 
    -Wno-packed-bitfield-compat
    -Wno-parentheses

[env:native]
platform = native
test_ignore = test_embedded, test_common
lib_compat_mode = off
lib_deps = 
   https://github.com/maxgerhardt/ArduinoFake.git
    davetcc/IoAbstraction@^1.6.7
    bblanchon/ArduinoJson@^6.17.2
    paulstoffregen/Time @ ^1.6.1
; map conversion arrays to 0. 
; will crash if anyone tries to use it, but shouldn't be used.
build_flags = 
    -D port_to_output_PGM=(uint8_t*)0
    -D digital_pin_to_port_PGM=(uint8_t*)0
    -D port_to_input_PGM=(uint8_t*)0
    -Wno-packed-bitfield-compat
    -Wno-parentheses

I have the same issue building on:

  1. a recent (last week) install of Ubuntu 22.04 server that I was using to setup a CI pipeline with platformio core
  2. my development laptop (windows 11) when using the platformio extension.

Given the application previously worked, my instinct is that the issue relates to something that has recently changed in the underlying build processes or dependencies (perhaps the arduino framework?). I am not familiar with these aspects, but will try to dig in and see what I can find to rule in or out a possible cause.

I have also tried pinning older versions of dependencies per below, but still have the problem

[env:esp32dev]
platform = espressif32@~5.3.0
board = esp32dev
framework = arduino
extra_scripts =
    pre:build_scripts/auto_firmware_version.py

lib_deps = 
	bblanchon/ArduinoJson@^6.17.2
	FS
	SPIFFS
	davetcc/IoAbstraction@2.4.3
    paulstoffregen/Time @ ^1.6.1

Same with 3.5.0 as the version?

If I set the platform to <= espressif32@~5.0.0
The issue appears to be present when platform >= espressif32@~5.1.0

Verified platform versions working okay:

  • 3.5.0
  • 4.4.0
  • 5.0.0

I have tested and found the issue is present when platform versions set to:

  • 5.1.0
  • 5.1.1
  • 5.2.0
  • 5.3.0
  • 6.0.0
  • 6.1.0
  • 6.3.1

5.1.0 was when the Arduino core was upgraded to 2.0.4. So if everything below that works fine, then the problem was introduced in 2.0.4.

Can you verify the same error occrus in the Arduino IDE with an Arduino-ESP32 core installation of 2.0.4 and latest? If yes → Issues · espressif/arduino-esp32 · GitHub

That makes sense that the problem appeared with 2.0.4
I don’t use the Arduino environment (I haven’t looked back since I started with Platformio a few years ago - thanks for your great work/product/project!) and my project is too large to quickly port across.

I tried to create a minimal example in both Arduino and Platformio, but the issue doesn’t occur. I’ll try a bit more and post back here if I can get a minimal code sample to demonstrate the issue and test in the Arduino environment.

@dobrien32

I’m glad to see you got some attention on this issue. After supplying all information that was asked of me I never heard back from @maxgerhardt so I just gave up on it. But it looks like the two of you have managed to narrow down the version this was introduced in so maybe it will get fixed.

I’m curious though, do you see this issue in the middle of your code or only when the ESP32 starts up or when you reset it? I was seeing it only at these points and my code worked just fine afterwards.

I observe the issue during the startup of my application code and the issue is continuous thereafter. I haven’t yet confirmed but I assume this coincides with where Wire.begin() is called.

Have you tried pinning your platform version 5.0.0 or earlier in the platformio.ini file ie.

platform = espressif32@~5.0.0

If so does that resolve your issue?

I also had the same problem and changed to version in platformio.ini
platform = espressif32@~5.0.0
and it was fixed and worked properly