Coder Social home page Coder Social logo

stickbreaker / arduino-esp32 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from espressif/arduino-esp32

38.0 11.0 24.0 170.74 MB

Arduino core for the ESP32

Makefile 0.01% C++ 10.30% C 87.87% Python 1.38% Ruby 0.01% Shell 0.02% Objective-C 0.41%
i2c esp32 wire

arduino-esp32's Introduction

Arduino core for ESP32 WiFi chip

Build Status

Need help or have a question? Join the chat at https://gitter.im/espressif/arduino-esp32

Contents

Development Status

  • Most of the framework is implemented.
  • Differences:
    • Wire() for deeper explanation README.md
      • 64k-1 data transfers
      • Special handling for sendStop=false
  • Missing:
    • analogWrite() While analogWrite is on it's way, there are a few other options that you can use:
      • 16 channels LEDC which is PWM
      • 8 channels SigmaDelta which uses SigmaDelta modulation
      • 2 channels DAC which gives real analog output
    • Wire.onReceive()
    • Wire.onRequest()

Installation Instructions

Decoding exceptions

You can use EspExceptionDecoder to get meaningful call trace.

Issue/Bug report template

Before reporting an issue, make sure you've searched for similar one that was already created. Also make sure to go through all the issues labelled as for reference.

Finally, if you're sure no one else had the issue, follow the ISSUE_TEMPLATE while reporting any issue.

ESP32Dev Board PINMAP

Pin Functions

Hint

Sometimes to program ESP32 via serial you must keep GPIO0 LOW during the programming process

arduino-esp32's People

Contributors

0xpit avatar alwint3r avatar apokorny avatar arcao avatar arvindr21 avatar bbx10 avatar consulitas avatar copercini avatar eroniki avatar esp32de avatar ionciubotaru avatar ivankravets avatar joeybab3 avatar lamloei avatar lonerzzz avatar m5stackjimmylai avatar markyad avatar mazgch avatar me-no-dev avatar minyk avatar per1234 avatar projectgus avatar radiumray avatar raienryu97 avatar schrod avatar stickbreaker avatar testato avatar tobozo avatar volca avatar wemos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-esp32's Issues

I2C Timeout with a PCA9685

Hardware:

Board: ESP32 Himalaya
Core Installation/update date: 14.2.2018
IDE name: Platform.io
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Hello, I use the ESP32 with an I2C PWM Expander PCA9685. With the ESP8266 I had no problem with this IC. But with the ESP32 I get an timeout, but only with this IC. On the same Board there is an LM75 Temp-Sensor, that delivers right values if the PCA is disassembled.
I use this Library:
https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/blob/master/Adafruit_PWMServoDriver.cpp library to controll the PCA9685

Sketch:

//Change the code below by your sketch
#include <Arduino.h>

void setup() {
Wire.begin(sda,scl);
ledDriver = Adafruit_PWMServoDriver();
ledDriver.setPWMFreq(200);  
ledDriver.reset();
}

void loop() {
for (uint8_t x = 0; x < 3; x++) {
     ledDriver.setPWM((i+x),0,4000);

    }
    i = 3;
    for (uint8_t x = 0; x < 3; x++) {
      ledDriver.setPWM((i+x),0,4000);

    }
    i = 6;
    for (uint8_t x = 0; x < 3; x++) {
   ledDriver.setPWM((i+x),0,4000);

    }
}

Debug Messages:

> Setting PWM 8: 0->4000
[E][esp32-hal-i2c.c:1151] i2cProcQueue():  Busy Timeout start=0xe430, end=0xe462, =50, max=50 error=4
[E][esp32-hal-i2c.c:609] i2cDumpI2c(): i2c=0x3ffc185c
[E][esp32-hal-i2c.c:610] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[E][esp32-hal-i2c.c:612] i2cDumpI2c(): lock=0x3ffd38b4
[E][esp32-hal-i2c.c:614] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:615] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:616] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:617] i2cDumpI2c(): error=4
[E][esp32-hal-i2c.c:618] i2cDumpI2c(): event=0x3ffce908 bits=200
[E][esp32-hal-i2c.c:619] i2cDumpI2c(): intr_handle=0x3ffce5b4
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): dq=0x3ffce590
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:622] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): byteCnt=0
[E][esp32-hal-i2c.c:582] i2cDumpDqData(): [0] 80 W STOP buf@=0x3ffc37b6, len=5, pos=5, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:598] i2cDumpDqData(): 0x0000: &....                            26 00 00 a0 0f
[E][esp32-hal-i2c.c:944] i2cDumpInts(): row  count   INTR    TX     RX
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [01] 0x0001 0x0002 0x0006 0x0000 0x0000e430
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [02] 0x0004 0x0100 0x0000 0x0000 0x0000e458

Question?

How to implement this i2c enhancement in my code? I'm using I2C LCD, DS1307 RTC, and PCA9555 IO Expander.

Many thanks in advance.

I2C with Adafruit Si7021 humidity/temp sensor

Hardware:

Board: Oddwires IoT ESP32 Dev Module
Core Installation/update date: 3/3/2018 (Not sure how to get the actual Core date
IDE name: Arduino IDE v1.8.5
Flash Frequency: 80MHz
Upload Speed: 921600

Description:

I have been having problems with using I2C on the OddWires IoT ESP32 board for an Adafruit Si7021 humidity/temperature board. It will work for a while (30 minutes to several hours, random), then fail by returning an out of range temperature. From then on, it will report the same temperature until reset.

I tried first installing (overwriting) esp32-hal-i2c.h, .cpp and esp32-hal-log.h in cores, and wire.h and .cpp in the Wire library. This compiled but returned a negative temperature value.

I also tried installing (overwrite) the entire package - same result.

Am I missing something simple? Seems to be communicating but getting some weird value.

Thanks, Ira

Sketch:

Debug Messages:

i2cDumpDqData() & i2cDumpInts() Enable Core Debug Level "Error"

Hardware:

Board: lolin32
Core Installation/update date: 10/12/2017
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

I've purchased an esp32 (loin32) module to replace an Arduino Mega but I'm having problems with i2c (a TI ADS1115, works fine on the Mega). I've just downloaded your library as I noticed the extra debugging you've added in the hopes of finding whats wrong.

After a few seconds of readings it stops working and produces the dump messages below. Any suggestions on how to debug this?

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:11392
entry 0x40078a9c

AIN0: 5240
 
AIN0: 4510
 
AIN0: 5302
 
AIN0: 5262

[E][esp32-hal-i2c.c:603] i2cDumpDqData(): Enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:947] i2cDumpInts(): enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:603] i2cDumpDqData(): Enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:947] i2cDumpInts(): enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:603] i2cDumpDqData(): Enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:947] i2cDumpInts(): enable Core Debug Level "Error"

...........
Library used:
https://github.com/adafruit/Adafruit_ADS1X15
i2c Device:
https://www.adafruit.com/product/1085

Sketch:

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads;

void setup(void)
{
  Serial.begin(115200);
  ads.setGain(GAIN_TWO);
  ads.begin();
}

void loop(void)
{
  int16_t adc0;
  adc0 = ads.readADC_SingleEnded(0);
  Serial.print("AIN0: "); Serial.println(adc0);
  Serial.println(" ");
  delay(1000);
}

Debug Messages:

[E][esp32-hal-i2c.c:603] i2cDumpDqData(): Enable Core Debug Level "Error"
[E][esp32-hal-i2c.c:947] i2cDumpInts(): enable Core Debug Level "Error"

i2c error causing panic

Hardware:

Board: Sparkfun ESP32 Thing
Core Installation/update date: 2/june/2018
IDE name: Platform.io
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Hey all! With the main arduino esp32 project right now, I'm getting the occasional insidious i2c timeout error, which led me to @stickbreaker's project.

I tried to replace the following files:

\libraries\Wire\scr\Wire.h
\libraries\Wire\scr\Wire.cpp
\cores\esp32\esp32-hal-i2c.h
\cores\esp32\esp32-hal-i2c.c
\cores\esp32\esp32-hal-log.h

from @stickbreaker's fork into the current https://github.com/platformio/platform-espressif32.git#feature/stage build of platform.io

but this resulted in the below error:

[E][esp32-hal-i2c.c:1212] i2cProcQueue():  Gross Timeout Dead start=0x120e, end=0x120e, =0, max=51 error=1
[E][esp32-hal-i2c.c:630] i2cDumpI2c(): i2c=0x3ffc1554
[E][esp32-hal-i2c.c:641] i2cDumpI2c(): dev=0x60013000 date=0x16042000 level=ERROR
[E][esp32-hal-i2c.c:643] i2cDumpI2c(): lock=0x3ffcc0a4
[E][esp32-hal-i2c.c:645] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:646] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:647] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:648] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:649] i2cDumpI2c(): event=0x3ffcc128 bits=10
[E][esp32-hal-i2c.c:650] i2cDumpI2c(): intr_handle=0x3ffcd4a4
[E][esp32-hal-i2c.c:651] i2cDumpI2c(): dq=0x3ffcd294
[E][esp32-hal-i2c.c:652] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:653] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:654] i2cDumpI2c(): byteCnt=1
[E][esp32-hal-i2c.c:604] i2cDumpDqData(): [0] 78 W STOP buf@=0x3ffc51a2, len=17, pos=17, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:620] i2cDumpDqData(): 0x0000: @..ffaa``........                40 1f 1f 66 66 61 61 60 60 1f 1f 00 00 00 00 00 00
[E][esp32-hal-i2c.c:974] i2cDumpInts(): enable Core Debug Level "Error"
GGuru Meditation Error: Core  1 panic'ed (StoreProhibited)
. Exception was unhandled.
Core 1 register dump:
PC      : 0x4008431b  PS      : 0x00060031  A0      : 0x800843ba  A1      : 0x3ffc0ba0
A2      : 0x3ffc1554  A3      : 0x00000001  A4      : 0x00000010  A5      : 0x80000020
A6      : 0x00060021  A7      : 0x00000000  A8      : 0xbaad9677  A9      : 0x3ffe2bd0
A10     : 0x000000b7  A11     : 0xbaad5678  A12     : 0x00004000  A13     : 0x3ffd2470
A14     : 0x00000003  A15     : 0x00060c23  SAR     : 0x00000014  EXCCAUSE: 0x0000001d
EXCVADDR: 0xbaad9677  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000
Core 1 was running in ISR context:
EPC1    : 0x4008431b  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x400dd97a

Backtrace: 0x4008431b:0x3ffc0ba0 0x400843b7:0x3ffc0bc0 0x40084a36:0x3ffc0bf0 0x40081899:0x3ffc0c10 0x400dd977:0x00000000

Sketch:

#include <Wire.h>
#include <Adafruit_INA219.h> // You will need to download this library

Adafruit_INA219 sensor219; // Declare and instance of INA219

void setup(void) 
{
      
  Serial.begin(9600);    
  sensor219.begin();
  
}

void loop(void) 
{
  float busVoltage = 0;
  float current = 0; // Measure in milli amps
  float power = 0;

  busVoltage = sensor219.getBusVoltage_V();
  current = sensor219.getCurrent_mA();
  power = busVoltage * (current/1000); // Calculate the Power
  
  
  Serial.print("Bus Voltage:   "); 
  Serial.print(busVoltage); 
  Serial.println(" V");  
  
  Serial.print("Current:       "); 
  Serial.print(current); 
  Serial.println(" mA");
  
  Serial.print("Power:         "); 
  Serial.print(power); 
  Serial.println(" W");  
  
  Serial.println("");  

  delay(2000);
}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 

ETH and I2C

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: ?11/jul/2017?
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

I have been trying to communicate by I2C while connected through Ethernet cable.
Stand alone, both communication works. Although, when I begin ETH, Wire stops working. ETH seems to work properly.

Sketch:

#include <ETH.h>
#include <Wire.h>

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event)
{
	switch (event) {
		case SYSTEM_EVENT_ETH_START:
		Serial.println("ETH Started");
		//set eth hostname here
		ETH.setHostname("esp32-ethernet");
		break;
		case SYSTEM_EVENT_ETH_CONNECTED:
		Serial.println("ETH Connected");
		break;
		case SYSTEM_EVENT_ETH_GOT_IP:
		Serial.print("ETH MAC: ");
		Serial.print(ETH.macAddress());
		Serial.print(", IPv4: ");
		Serial.print(ETH.localIP());
		if (ETH.fullDuplex()) {
			Serial.print(", FULL_DUPLEX");
		}
		Serial.print(", ");
		Serial.print(ETH.linkSpeed());
		Serial.println("Mbps");
		eth_connected = true;
		break;
		case SYSTEM_EVENT_ETH_DISCONNECTED:
		Serial.println("ETH Disconnected");
		eth_connected = false;
		break;
		case SYSTEM_EVENT_ETH_STOP:
		Serial.println("ETH Stopped");
		eth_connected = false;
		break;
		default:
		break;
	}
}

void testClient(const char * host, uint16_t port)
{
	Serial.print("\nconnecting to ");
	Serial.println(host);

	WiFiClient client;
	if (!client.connect(host, port)) {
		Serial.println("connection failed");
		return;
	}
	client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
	while (client.connected() && !client.available());
	while (client.available()) {
		Serial.write(client.read());
	}
	Serial.println("closing connection\n");
	client.stop();
}

void setup()
{
	Serial.begin(115200);
 	WiFi.onEvent(WiFiEvent);
 	ETH.begin(1, 17, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_OUT);

	Wire.begin(33, 32,100000);
}

void loop()
{
	if (eth_connected) {
		testClient("google.com", 80);
	}
	
	delay(5000);
	Wire.beginTransmission(40);
	Wire.write("test");
	Wire.endTransmission();
}

Debug Messages:

Opening port
Port open
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:956
load:0x40078000,len:0
load:0x40078000,len:13076
entry 0x40078a58
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 19 - ETH_START
ETH Started
[W][esp32-hal-i2c.c:1094] i2cCheckLineState(): invalid state sda=0, scl=0

[E][esp32-hal-i2c.c:1110] i2cCheckLineState(): Bus Invalid State, TwoWire() Can't init
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 21 - ETH_CONNECTED
ETH Connected
[D][WiFiGeneric.cpp:293] _eventCallback(): Event: 23 - ETH_GOT_IP
ETH MAC: 30:AE:A4:19:5E:47, IPv4: 10.1.1.147, FULL_DUPLEX, 100Mbps

connecting to google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Fri, 01 Jun 2018 18:43:30 GMT
Expires: Sun, 01 Jul 2018 18:43:30 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
closing connection


connecting to google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Fri, 01 Jun 2018 18:43:35 GMT
Expires: Sun, 01 Jul 2018 18:43:35 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
closing connection


Port closed

Bus Invalid State sda=1, scl=0

Hardware:

Board: DOIT Esp32 DevKit v1
Core Installation/update date: last release
IDE name: Platform.io
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

I'm working on a project to upload on a Google Sheet accelerations read by the MPU6050, connected with wifi. There are 2 taks, one to read accelerations (readData) and one to upload them using HTTP (postRequest). The problem is: everything works, until when this error occurs! At that point the accelerometer doesn't show up anymore even running a simple i2c scanner sketch. Dead. If I change accelerometer (did it 3 times), everything works again... This for 10mins, or 1 day maybe, but sooner or later the error returns. I attach also the hardware layout I am using. Am I burning accelerometers? Is it just a code problem? pls save me
MVIMG_20190425_115932

Sketch:

#include <Arduino.h>
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
#include "WiFi.h"
#include "HTTPClient.h"
#include "freertos/FreeRTOS.h"
#include <string.h>

#define CORE_DEBUG_LEVEL (5) //FROM 1 TO 5
#define READ_DELAY 20 	//20 ms means 50hz
#define POST_DELAY 	10000 
#define SEND_POST 1

MPU6050 accel(0x69);

// SSID and Password
static const char* ssid     = "G";
static const char* password = "f1";
static const char* url = "https://hooks.zapier.com/hooks"; 

//data
String x_buf, y_buf, z_buf;
bool read_en;

//rtos
static TaskHandle_t xTaskPost = NULL, xTaskData = NULL;
static SemaphoreHandle_t xMutex;

// Establish a Wi-Fi connection with your router
void initWifi() {
	Serial.print("Connecting to: "); 
	Serial.print(ssid);
	WiFi.begin(ssid, password);  

	int timeout = 10 * 4; // 10 seconds
	while(WiFi.status() != WL_CONNECTED  && (timeout-- > 0)) {
	delay(250);
	Serial.print(".");
	}
	Serial.println("");

	if(WiFi.status() != WL_CONNECTED) {
		Serial.println("Failed to connect to WIFI");
		while(1);
	}

	Serial.print("WiFi connected in: "); 
	Serial.print(millis());
	Serial.print(", IP address: "); 
	Serial.println(WiFi.localIP());
}

void initMPU(){
	Serial.print("Waiting MPU.....");
	while (!accel.testConnection()){
		Serial.print(accel.getDeviceID());
		Serial.print(".");
		delay(300);
	}
	Serial.println(".");
	Serial.println("MPU6050 connection successful");
	accel.initialize();

	delay(1000);
	// set offsets
	accel.calibrate(-5109, -5497, 9133, 38, -152, 29);

	//low pass filter
	Serial.println("Low-pass filter at 42Hz");
	accel.setDLPFMode(MPU6050_DLPF_BW_42);
}

// Make an HTTP request to the web service
void postRequest(void * pvParameters ) {
	String jsonObject;
	while(1){
		while(xSemaphoreTake(xMutex, (TickType_t) 1) != pdTRUE);
		if (read_en && xPortGetFreeHeapSize()>150000){ //if not reading, or not enough space, do not concatenate anymore
			Serial.println(String("Heap size free: ") + xPortGetFreeHeapSize());
			jsonObject.concat(String("{\"value1\":\"") + x_buf);
			x_buf = (char*) NULL; //invalidate
			jsonObject.concat(String("\",\"value2\":\"") + y_buf);
			y_buf = (char*) NULL; //invalidate
			jsonObject.concat(String("\",\"value3\":\"") + z_buf + "\"}\n");
			z_buf = (char*) NULL; //invalidate
		}
		else{
			Serial.println("Not enough space, waiting to POST successfully...");
			Serial.println(String("Heap size: ") + xPortGetFreeHeapSize());
			Serial.println(String("Reading accelerations: ") + (read_en?"enabled":"disabled"));
		}
		xSemaphoreGive(xMutex);
		Serial.println(String("Connecting to ") + url);   
		HTTPClient http;
		http.begin(url);
		//http.addHeader("authorization: Bearer ", auth_token);
		http.addHeader("content-type:", "application/json");
		#if SEND_POST
		int httpResponseCode = http.POST((uint8_t *)jsonObject.c_str(),jsonObject.length());
		#else
		int httpResponseCode = 0;
		Serial.println(jsonObject);
		#endif
		//Serial.println(jsonObject);
		if(httpResponseCode > 0){
			String response = http.getString(); 	//Get the response to the request
			Serial.println(httpResponseCode);   	//Print return code
			Serial.println(response);           	//Print request answer
			jsonObject = (char*) NULL;
			while(xSemaphoreTake(xMutex, (TickType_t) 1) != pdTRUE);
			if (!read_en){ 
				read_en = true;
				Serial.println("Read now enabled again");
			}
			xSemaphoreGive(xMutex);
			Serial.println("json empty!");
			Serial.println(String("Heap size: ") + xPortGetFreeHeapSize());
		}
		else{
			Serial.print("Error on sending POST: ");
			Serial.println(httpResponseCode);
		}
		
		http.end();  //Free resources
		vTaskDelay(POST_DELAY);
	}
}

void readData(void * pvParameters ) {
	for(;;){
		int16_t ax, ay, az;
		accel.getAcceleration(&ax, &ay, &az);
		while (xSemaphoreTake(xMutex, (TickType_t) 1) != pdTRUE);
		if (read_en){
			bool read_x = x_buf.concat(ax + String(" "));
			bool read_y = y_buf.concat(ay + String(" "));
			bool read_z = z_buf.concat(az + String(" "));
			read_en = read_x && read_y && read_z;
			if (!read_en){
				Serial.println("READ NOW DISABLED");
			}
		}
		xSemaphoreGive(xMutex);
		vTaskDelay(READ_DELAY);	
	}

}

void setup() {
	// join I2C bus (I2Cdev library doesn't do this automatically)
	Wire.begin();
	delay(1000);
	// initialize serial communication
	Serial.begin(115200);

	//mpu
	initMPU();
	
	//wifi
	delay(4000);
	initWifi();
	
	read_en = true;
	xMutex = xSemaphoreCreateMutex();
	xTaskCreate(
				postRequest,       /* Function that implements the task. */
				"PostReqTask",          /* Text name for the task. */
				4096,      /* Stack size in words, not bytes. */
				( void * ) 1,    /* Parameter passed into the task. */
				tskIDLE_PRIORITY,/* Priority at which the task is created. */
				&xTaskPost );      /* Used to pass out the created task's handle. */

	xTaskCreate(
				readData,       /* Function that implements the task. */
				"ReadDataTask",          /* Text name for the task. */
				4096,      /* Stack size in words, not bytes. */
				( void * ) 1,    /* Parameter passed into the task. */
				tskIDLE_PRIORITY,/* Priority at which the task is created. */
				&xTaskData );      /* Used to pass out the created task's handle. */

} 

void loop(){}

Debug Messages:

[E][esp32-hal-i2c.c:1426] i2cCheckLineState(): Bus Invalid State, TwoWire() Can't init sda=1, scl=0
Waiting MPU.....0.0.0.0.0.0.

Can't build: implicit declaration of function 'dumpCmdQueue' in esp-hal-i2c

Hardware:

Board: ESP32 Dev Module (DevKit-C)
Core Installation/update date: latest
IDE name: IDF component
Flash Frequency: 40MHz
Upload Speed: 115200

Description:

I get the following error when trying to build using your repo as my arduino-esp32 submodule in my arduino-as-idf-component configuration:

./components/arduino/cores/esp32/esp32-hal-i2c.c: In function 'fillCmdQueue':
./components/arduino/cores/esp32/esp32-hal-i2c.c:511:11: error: implicit declaration of function 'dumpCmdQueue' [-Werror=implicit-function-declaration]
           dumpCmdQueue(i2c);

Any idea where that might come from?

Working devices

I want to confirm that I have the following devices working properly with your code:

DS3231 (RTC)
AT24C32 (EEPROM)
BME680 (TEMP/PRES/HUMI/GAS SENSOR)

Noteworthy is, that I have all I2C communication coded so I never have to use endTransmission(false);

adding: #define STICKBREAKER

I have to regularly switch between the origin:master and your fork, but the I2C API is incompatible. would you mind sneaking in a #define STICKBREAKER in Wire.h so I can automagically switch between code branches? This is only required until your changes are merged upstream of course. or is there another way to detect the API version?

i2c communications on ESP32

I was reading your description of the issues of i2c communications on ESP32. You obviously have studied this issue in great detail, I am trying to better understand what is necessary when using i2c on an ESP32. I am fairly new to this lower level programming and thought that maybe you could answer a couple of questions.

You indicate that traditionally on Arduino, and for example your Adafruit_SI7021 code, that you

"set internal address pointer in I2C EEPROM from which to read",
then call
uint8_t err =Wire.endTransmission(false); // don't send a STOP, just Pause I2C operations

Is it really necessary to keep the connection active via the "false" argument before the call to Wire.requestFrom()?

I understand that if Wire.endTransmission(false) is called, then I2C_ERROR_CONTINUE must be an acceptable return value for the ESP32.

I have a modified a version of Adafruit_SI7021 where I replaced Wire.endTransmission(false) with Wire.endTransmission(), which now returns I2C_ERROR_OK (0) instead of I2C_ERROR_CONTINUE (7) and the sensor appears to return valid data as desired assuming I accept I2C_ERROR_OK as an acceptable value for the ESP32.

I've tested this on ESP32, ESP8266, and ATmega328 devices without any detected problems. Maybe there are issues that are not obvious.

What am I missing that would require the connection to remain active between Wire.endTransmission
and Wire.requestFrom? I see other areas of code where that does not occur.

Thanks in advance for any enlightenment you can provide! :)

How to implement ?

Hi,
I am trying to connect an ESP32 Dev Board with I2c to an ADAFRUIT SX1509 GPIO extension board.
I do not know how to implement this library. Do I have to replace the original Wire.h library? Do I have to merge ?
What calls do I have to use in my code. (original wire.h calls or adapted ??)

Regards
Henk Wijtman
Rotterdam
Netherlands

Small compilation warning with I2C patched file

Please fill the info fields, it helps to get you faster support ;)

If you have a Guru Meditation Error, please decode it:
https://github.com/me-no-dev/EspExceptionDecoder

----------------------------- Remove above -----------------------------

Hardware:

Board: ESP32 WEMOS LOLIN32 WROOM
Core Installation/update date: 11/jan/2017 (last version from Github
IDE name: Arduino IDE
Flash Frequency: ?40Mhz?
Upload Speed: ?115200?

Hi stickbreaker,

I have a small issue while compiling your I2C patched version, and I could't find the exact reason.
May be this warning can be corrected but I don't know how:
The message is the following:
... /hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c: In function 'i2cDumpDqData':
.../hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c:603:1: warning: implicit declaration of function 'log_n' [-Wimplicit-function-declaration]
log_n("Enable Core Debug Level "Error"");

Can you explain this.
Thanks in avance
Robert

Weird i2c erors on ESP32-DEVKIT_V1 doit

I have a PCF-8523 .Initally all goes well but after a time i get this. error.

[E][esp32-hal-i2c.c:1115] i2cProcQueue(): TimeoutRecovery: expected=0ms, actual=2ms
[E][esp32-hal-i2c.c:609] i2cDumpI2c(): i2c=0x3ffc1894
[E][esp32-hal-i2c.c:610] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[E][esp32-hal-i2c.c:612] i2cDumpI2c(): lock=0x3ffdf6a0
[E][esp32-hal-i2c.c:614] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:615] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:616] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:617] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:618] i2cDumpI2c(): event=0x3ffdf724 bits=10
[E][esp32-hal-i2c.c:619] i2cDumpI2c(): intr_handle=0x3ffdf754
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): dq=0x3ffe12cc
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:622] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): byteCnt=2
[E][esp32-hal-i2c.c:582] i2cDumpDqData(): [0] d0 W STOP buf@=0x3ffc61da, len=1, pos=1, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:598] i2cDumpDqData(): 0x0000: . 03
[E][esp32-hal-i2c.c:944] i2cDumpInts(): row count INTR TX RX
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [01] 0x0001 0x0002 0x0002 0x0000 0x000346a6
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x000346a6
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [03] 0x0002 0x0040 0x0000 0x0000 0x000346a6
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0000 0x000346a6
[E][esp32-hal-i2c.c:1115] i2cProcQueue(): TimeoutRecovery: expected=0ms, actual=2ms
[E][esp32-hal-i2c.c:609] i2cDumpI2c(): i2c=0x3ffc1894
[E][esp32-hal-i2c.c:610] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[E][esp32-hal-i2c.c:612] i2cDumpI2c(): lock=0x3ffdf6a0
[E][esp32-hal-i2c.c:614] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:615] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:616] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:617] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:618] i2cDumpI2c(): event=0x3ffdf724 bits=10
[E][esp32-hal-i2c.c:619] i2cDumpI2c(): intr_handle=0x3ffdf754
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): dq=0x3ffe12cc
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:622] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): byteCnt=8
[E][esp32-hal-i2c.c:582] i2cDumpDqData(): [0] d1 R STOP buf@=0x3ffc6154, len=7, pos=7, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:598] i2cDumpDqData(): 0x0000: ....... 13 13 15 09 00 02 18
[E][esp32-hal-i2c.c:944] i2cDumpInts(): row count INTR TX RX
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [01] 0x0001 0x0002 0x0001 0x0000 0x00034b71
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x00034b71
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [03] 0x0008 0x0040 0x0000 0x0000 0x00034b72
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0007 0x00034b72
[E][esp32-hal-i2c.c:1115] i2cProcQueue(): TimeoutRecovery: expected=0ms, actual=2ms
[E][esp32-hal-i2c.c:609] i2cDumpI2c(): i2c=0x3ffc1894
[E][esp32-hal-i2c.c:610] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[E][esp32-hal-i2c.c:612] i2cDumpI2c(): lock=0x3ffdf6a0
[E][esp32-hal-i2c.c:614] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:615] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:616] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:617] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:618] i2cDumpI2c(): event=0x3ffdf724 bits=10
[E][esp32-hal-i2c.c:619] i2cDumpI2c(): intr_handle=0x3ffdf754
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): dq=0x3ffe12cc
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:622] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): byteCnt=8
[E][esp32-hal-i2c.c:582] i2cDumpDqData(): [0] d1 R STOP buf@=0x3ffc6154, len=7, pos=7, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:598] i2cDumpDqData(): 0x0000: ....... 15 13 15 09 00 02 18
[E][esp32-hal-i2c.c:944] i2cDumpInts(): row count INTR TX RX
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [01] 0x0001 0x0002 0x0001 0x0000 0x000352a3
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x000352a3
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [03] 0x0008 0x0040 0x0000 0x0000 0x000352a4
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0007 0x000352a4
[E][esp32-hal-i2c.c:1115] i2cProcQueue(): TimeoutRecovery: expected=0ms, actual=2ms
[E][esp32-hal-i2c.c:609] i2cDumpI2c(): i2c=0x3ffc1894
[E][esp32-hal-i2c.c:610] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[E][esp32-hal-i2c.c:612] i2cDumpI2c(): lock=0x3ffdf6a0
[E][esp32-hal-i2c.c:614] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:615] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:616] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:617] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:618] i2cDumpI2c(): event=0x3ffdf724 bits=10
[E][esp32-hal-i2c.c:619] i2cDumpI2c(): intr_handle=0x3ffdf754
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): dq=0x3ffe12cc
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:622] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): byteCnt=2
[E][esp32-hal-i2c.c:582] i2cDumpDqData(): [0] d0 W STOP buf@=0x3ffc61da, len=1, pos=1, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:598] i2cDumpDqData(): 0x0000: . 03
[E][esp32-hal-i2c.c:944] i2cDumpInts(): row count INTR TX RX
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [01] 0x0001 0x0002 0x0002 0x0000 0x00035b70
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x00035b70
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [03] 0x0002 0x0040 0x0000 0x0000 0x00035b70
[E][esp32-hal-i2c.c:947] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0000 0x00035b70

Gross Timeout occuring

@jlhavens is encountering Gross Timeouts, the debug out shows the ISR completing but i2cProcQueue() is timing out in the xEventGroupGetBits().

[E][esp32-hal-i2c.c:1643] i2cProcQueue():  Gross Timeout Dead st=2492, ed=2542, =50, max=50 error=1
[E][esp32-hal-i2c.c:1103] dumpI2c(): i2c=0x3ffc1040
[E][esp32-hal-i2c.c:1104] dumpI2c(): dev=0x60013000
[E][esp32-hal-i2c.c:1105] dumpI2c(): lock=0x3ffd343c
[E][esp32-hal-i2c.c:1106] dumpI2c(): num=0
[E][esp32-hal-i2c.c:1107] dumpI2c(): mode=1
[E][esp32-hal-i2c.c:1108] dumpI2c(): stage=3
[E][esp32-hal-i2c.c:1109] dumpI2c(): error=1
[E][esp32-hal-i2c.c:1110] dumpI2c(): event=0x3ffd34c0 bits=0
[E][esp32-hal-i2c.c:1111] dumpI2c(): intr_handle=0x3ffd08d4
[E][esp32-hal-i2c.c:1112] dumpI2c(): dq=0x3ffe1734
[E][esp32-hal-i2c.c:1113] dumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:1114] dumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:1115] dumpI2c(): byteCnt=4
[E][esp32-hal-i2c.c:1120] dumpI2c(): [0] 90 W STOP buf@=0x3ffc3542, len=3, pos=3, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:1468] i2cDumpInts(): row  count   INTR    TX     RX
[E][esp32-hal-i2c.c:1471] i2cDumpInts(): [01] 0x0001 0x0002 0x0004 0x0000
[E][esp32-hal-i2c.c:1471] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000
[E][esp32-hal-i2c.c:1471] i2cDumpInts(): [03] 0x0004 0x0040 0x0000 0x0000
[E][esp32-hal-i2c.c:1471] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0000

I recommended he increase the default Gross Timeout from +50ms to +500ms.
in esp32-hal-i2c.c:1596

chuck.

Problem in i2C between ESP32 and Adafruit_ADS1015

Hardware:

Board: ESP32 ?ESP32
Core Installation/update date: ?27/Mar/2018?
IDE name: ?Arduino IDE
Flash Frequency: ?80Mhz?
Upload Speed: ?115200?

scope_2

yellow PIN 18 SDA, RED PIN 19 SCL

Description:

I have ESP32 connected to ADS1015 through i2C (PIN 18, 19), everything was cool when I first had the ESP8266 but when I changed to ESP32 first I got zeros from the function readADC_SingleEnded()
However when I changed to your arduino-esp32 I am getting a constant value of 4096 all the time.
any suggestions.
`#include "Arduino.h"
#include "Adafruit_ADS1015.h"
Adafruit_ADS1015 adc;

void getSolarCurrent() {
adc.setGain(adsGain_t::GAIN_TWO); //set upper limit vmax to 2.048V
uint16_t adc_res = adc.readADC_SingleEnded(1);
Serial.println("ADC res: "+String(adc_res));
Serial.flush();
//return (double) adc_res / 8.326; //Result is in mA (adc_val 2048mV/2047 / 8.33 / 1 Ohm)

}
void getCapVoltage() {
adc.setGain(adsGain_t::GAIN_ONE); //set vmax to 4.096V
uint16_t adc_res = adc.readADC_SingleEnded(0);
Serial.println("ADC res: "+String(adc_res));
Serial.flush();
//return (double)adc_res / 0.4998;//Result in mV (adc_res * 4096mV/2047)

}

void setup() {
//rtc_clk_cpu_freq_set(RTC_CPU_FREQ_80M);
Serial.begin(115200);
Serial.println();
Serial.println("Booted");
Serial.flush();

adc.begin(); /* own begin-method which sets sda=2 and scl=14 pins to the ones used on solar board (and data sheet) */

yield();  

getSolarCurrent();
getCapVoltage();
esp_sleep_enable_timer_wakeup(10*1000000);

esp_deep_sleep_start();   

}

void loop() {

}`

Debug Messages:

Booted
ADC res: 4095
ADC res: 4095



Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 

Question: set and read SDA/SCL

Hello,

I've a question. I'm adding I2C slave implementation based on your code (porting from ESP8266 to ESP32), however I'm not sure, how to replace access to GPIO control registers (as in https://github.com/esp8266/Arduino/blob/master/cores/esp8266/esp8266_peri.h).

What I need to implement is:

#define GPES   ESP8266_REG(0x310) //GPIO_ENABLE_SET WO
#define GPEC   ESP8266_REG(0x314) //GPIO_ENABLE_CLR WO
#define GPI    ESP8266_REG(0x318) //GPIO_IN RO (Read Input Level)

#define SDA_LOW()   (GPES = (1 << twi_sda)) //Enable SDA (becomes output and since GPO is 0 for the pin, it will pull the line low)
#define SDA_HIGH()  (GPEC = (1 << twi_sda)) //Disable SDA (becomes input and since it has pullup it will go high)
#define SDA_READ()  ((GPI & (1 << twi_sda)) != 0)
#define SCL_LOW()   (GPES = (1 << twi_scl))
#define SCL_HIGH()  (GPEC = (1 << twi_scl))
#define SCL_READ()  ((GPI & (1 << twi_scl)) != 0)

Question??

Hi. Has this been made part of the main core project yet ? If I use 1.0.1 ?

Bus busy error when using 2nd TwoWire instance

Hardware:

Board: LOLIN32
Core Installation/update date: Main + latest stickbreaker patched i2c files
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Just testing the second i2c on the ESP32 with the i2c changes, seems there's an issue having both active?
I've modified the scanner example to scan both, getting a busy bus error. No issues when scanning only one bus in the loop, even when beginning both.

[I][esp32-hal-i2c.c:971] i2cProcQueue(): Bus busy, reinit

Sketch:

#include <Wire.h>

TwoWire Wire1(1);

void scan() {
  Serial.println("\n Scanning I2C Addresses");
  uint8_t cnt = 0;
  for (uint8_t i = 0; i < 0x7F; i++) {
    Wire.beginTransmission(i);
    uint8_t ec = Wire.endTransmission(true); // if device exists on bus, it will aCK
    if (ec == 0) { // Device ACK'd
      if (i < 16)Serial.print('0');
      Serial.print(i, HEX);
      cnt++;
    }
    else Serial.print(".."); // no one answered
    Serial.print(' ');
    if ((i & 0x0f) == 0x0f)Serial.println();
  }
  Serial.print("Scan Completed, ");
  Serial.print(cnt);
  Serial.println(" I2C Devices found.");
}

void scan2() {
  Serial.println("\n Scanning I2C Addresses");
  uint8_t cnt = 0;
  for (uint8_t i = 0; i < 0x7F; i++) {
    Wire1.beginTransmission(i);
    uint8_t ec = Wire1.endTransmission(true); // if device exists on bus, it will aCK
    if (ec == 0) { // Device ACK'd
      if (i < 16)Serial.print('0');
      Serial.print(i, HEX);
      cnt++;
    }
    else Serial.print(".."); // no one answered
    Serial.print(' ');
    if ((i & 0x0f) == 0x0f)Serial.println();
  }
  Serial.print("Scan Completed, ");
  Serial.print(cnt);
  Serial.println(" I2C Devices found.");
}

void setup() {
  Serial.begin(115200);
  Wire.begin();
  Wire1.begin(19, 23);

}

void loop() {
  scan();
  scan2();
  delay(500);
}

Debug Messages:

 Scanning I2C Addresses
00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. 48 .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. 57 .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. 68 .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Scan Completed, 4 I2C Devices found.

 Scanning I2C Addresses
[I][esp32-hal-i2c.c:971] i2cProcQueue(): Bus busy, reinit
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
20 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Scan Completed, 1 I2C Devices found.

Random Timeouts

Board: LOLIN32
Core Installation/update date: Main + latest stickbreaker patched i2c files
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Several times an hour I get the below error on debug - even with timeouts set to 2000ms.
I'm using a pair of i2c extenders (P82B715 + 6 metres of double shielded cat 6a) which may be introducing some latency.

to

Is there anything that can be done software side? rise time is below 1 μs (0.400 μs) and the cable is earthed ESP32 end, signal looks clean and stable over time.

Sketch:

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads;

void setup(void) 
{
  Serial.begin(115200);

  ads.begin();
}

void loop(void) 
{
  int16_t adc0, adc1, adc2, adc3;

  adc0 = ads.readADC_SingleEnded(0);
  adc1 = ads.readADC_SingleEnded(1);
  adc2 = ads.readADC_SingleEnded(2);
  adc3 = ads.readADC_SingleEnded(3);
  Serial.print("AIN0: "); Serial.println(adc0);
  Serial.print("AIN1: "); Serial.println(adc1);
  Serial.print("AIN2: "); Serial.println(adc2);
  Serial.print("AIN3: "); Serial.println(adc3);
  Serial.println(" ");
  
  delay(1000);
}

Debug Messages:

[D][esp32-hal-i2c.c:1166] i2cProcQueue(): used TimeoutRecovery: expected=0ms, actual=3ms, configured=50ms 
[E][esp32-hal-i2c.c:630] i2cDumpI2c(): i2c=0x3ffc1030
[E][esp32-hal-i2c.c:641] i2cDumpI2c(): dev=0x60013000 date=0x16042000 level=DEBUG
[E][esp32-hal-i2c.c:643] i2cDumpI2c(): lock=0x3ffc5cc8
[E][esp32-hal-i2c.c:645] i2cDumpI2c(): num=0
[E][esp32-hal-i2c.c:646] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:647] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:648] i2cDumpI2c(): error=1
[E][esp32-hal-i2c.c:649] i2cDumpI2c(): event=0x3ffc5e10 bits=10
[E][esp32-hal-i2c.c:650] i2cDumpI2c(): intr_handle=0x3ffc5e40
[E][esp32-hal-i2c.c:651] i2cDumpI2c(): dq=0x3ffc5dec
[E][esp32-hal-i2c.c:652] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:653] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:654] i2cDumpI2c(): byteCnt=3
[E][esp32-hal-i2c.c:604] i2cDumpDqData(): [0] 93 R STOP buf@=0x3ffc2304, len=2, pos=2, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:620] i2cDumpDqData(): 0x0000: a.                               61 c1 
[E][esp32-hal-i2c.c:968] i2cDumpInts(): 0 row  count   INTR    TX     RX
[E][esp32-hal-i2c.c:971] i2cDumpInts(): [01] 0x0001 0x0002 0x0001 0x0000 0x00057c73
[E][esp32-hal-i2c.c:971] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x00057c73
[E][esp32-hal-i2c.c:971] i2cDumpInts(): [03] 0x0003 0x0040 0x0000 0x0000 0x00057c73
[E][esp32-hal-i2c.c:971] i2cDumpInts(): [04] 0x0001 0x0080 0x0000 0x0002 0x00057c76


pinging @telliottosceola

travis,
I received those Sample NCD products, but, I cann't seem to upload programs to them.

What is the correct definite (board) for Arduino 1.8.8? BaudRate... all that stuff?
PR54-6. I searched on the NCD website but could not find anything. I can see the board in serial monitor, at 115200 and got it to accept a program once at 115200, but when I try again, it fails. the one successful load is still running.
The little blue/read led blinks?
at 234000

C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/esptool/esptool.exe --chip esp32 --port COM22 --baud 230400 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 C:\Users\user\AppData\Local\Temp\arduino_build_110441/I2C_Scan.ino.bin 0x8000 C:\Users\user\AppData\Local\Temp\arduino_build_110441/I2C_Scan.ino.partitions.bin 
esptool.py v2.6-beta1
Serial port COM22
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x5F)
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x5F)

at 256000:

C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/esptool/esptool.exe --chip esp32 --port COM22 --baud 256000 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users\user\Documents\Arduino\hardware\mwire\esp32/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 C:\Users\user\AppData\Local\Temp\arduino_build_110441/I2C_Scan.ino.bin 0x8000 C:\Users\user\AppData\Local\Temp\arduino_build_110441/I2C_Scan.ino.partitions.bin 
esptool.py v2.6-beta1
Serial port COM22
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x6E)
A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x6E)


Chuck.

TimeOut recovery

TimeOut, Arbitration, and Bus Busy errors cause by hardware faults are difficult to recover from.

The current Wire.reset() cannot successfully reset the hardware.

This can be tested by initing the Wire library with Wire.begin() then grounding SDA. This is simulate a START -> STOP, it is considered a void statement by the I2C standard and not recommended. But, reality cannot be ignored, it happens.

The bus will be clear(SCL and SDA high with no activity), but the SM will fall into an irrecoverable state of BUS_BUSY, TIMEOUT perhaps ARBITRATION.

The only successful recovery is a HARDWARE reset operation. Or, if a second set of GPIO pins are dedicated, a manual bit banged START 9 clocks STOP can recover the SM.

Does anyone have a successful Software Recovery Method?

Chuck.

I2C compile error when CONFIG_DISABLE_HAL_LOCKS defined

Hi!
The method "\esp32-hal-i2c.c -> void i2cDumpI2c(i2c_t * i2c)" has the line:
log_e("lock=%p",i2c->lock);
but declaration of field "lock" is under CONFIG_DISABLE_HAL_LOCKS defines.
And in case of using a CONFIG_DISABLE_HAL_LOCKS, compilation causes an error.

Wire.lastError() throwing back error 5

Hi Stickbreaker !!!

How are you ? Hope you remember me, I had serious problems with ESP32 and official arduino branch regarding i2c.

Your work saved me!

And then, today, I decided to update into the latest espressif/arduino-esp32 code from github.

Then I downloaded your branched - i2c enhanced code from git, and copied over the relevant files, into the master esp32 arduino:

\libraries\Wire\scr\Wire.h
\libraries\Wire\scr\Wire.cpp
\cores\esp32\esp32 - hal - i2c.h
\cores\esp32\esp32 - hal - i2c.c
\cores\esp32\esp32 - hal - log.h

I recompiled, and to my dismay, my code is not being able to read 256 bytes from my sensor's EEPROM (which in the older commit was OK until now (I was using ge5b2c1cf).

This is my code (which was working fine):

//Levanto toda la info de la EEPROM del sensor para manejarla en ram (más rápido)
void readEEPROM() { // Read in blocks of 32 bytes to accomodate Wire library
	int err = 0;
	do {
		Wire.beginTransmission(MLX90621_EEPROM);
		Wire.write(0);
		err = Wire.transact(eepromData, 256); //grab 256 byte directly into eepromData
		if (err != 256) { //Error: NO recibí los 256 bytes de la eeprom
			Serial.println("EEPROM ERROR " + (String)Wire.lastError() + ", " + (String)err + " bytes");
			Wire.endTransmission(true); //Cierro la transmision correctamente.
			Wire.reset(); //Y reseteo el interface
		}
	} while (err != 256);
	reseteo = 0; //No da error el i2c
}

Which now keeps in loop throwing at me:

EEPROM ERROR 5, 0 bytes

I was hoping you may have an idea on what may be going on ? I could try to revert into earlier commits, until I get a working one again, I suppose. But maybe it is an easy thing to fix from my side ?

Regards,

Enrique.

How to include this in Platformio ?

Please fill the info fields, it helps to get you faster support ;)

If you have a Guru Meditation Error, please decode it:
https://github.com/me-no-dev/EspExceptionDecoder

----------------------------- Remove above -----------------------------

Hardware:

Board: ESP32 Dev Module?
Core Installation/update date: 11/Dec/2017
IDE name: Platform.io
Flash Frequency: 40Mhz
Upload Speed: 9600

Description:

How to easily include this one in the platformio ?

Understanding merge with Main, not an issue.

Hi stickbreaker.
First i want to say thanks for your contribution on I2c issues.
I am beginner so not able to understand one thing properly. Your changes are merged in main repo. but i see two methods named "TwoWire::transact()" in your Wire.cpp but they are not present in latest Repo of ESP32 arduino. So does it means that i still need to replace all 5 files from your release to esp32 arduino core?

i2c from second core fails (MCP23017)

Hardware:

Board: LOLIN32
Core Installation/update date: Main + latest stickbreaker patched i2c files
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

The below code works great when calling checkRpmPins(); from within the main loop, however, when calling mcp.digitalRead(0); from a second core task I get the below error. When using digitalRead(0);

I'm guessing a timing issue when using the second core? I'm not sure if anyone's tried calling from the second core for i2c? I'm counting the RPM value from 16 fans (hall effect sensors) so timing is critical which is why I'm complicating things. :)

Sketch:

#include <Wire.h>
#include "Adafruit_MCP23017.h"

#define NUM_RPM (sizeof(rpmPins)/sizeof(rpmPins[0]))

int rpmPin = 0;
static volatile uint16_t rpmcounter;

Adafruit_MCP23017 mcp;
TaskHandle_t Task1;

void checkRpmPins() {

  static bool lastPinState;

  if (mcp.digitalRead(rpmPin) != lastPinState) {
    lastPinState = !lastPinState;
    if (lastPinState) {
      rpmcounter++;
    }
  }
}

void coreTask( void * parameter)
{
  while (true) {
    vTaskDelay(1);
  }
}

void setup() {
  Serial.begin(115200);
  mcp.begin();      // use default address 0

  mcp.pinMode(0, INPUT);
  mcp.pullUp(0, HIGH);

  xTaskCreatePinnedToCore(
    coreTask,   /* Function to implement the task */
    "coreTask", /* Name of the task */
    10000,      /* Stack size in words */
    NULL,       /* Task input parameter */
    0,          /* Priority of the task */
    &Task1,       /* Task handle. */
    0);  /* Core where the task should run */

  delay(100);

}

void loop() {
  checkRpmPins();
  static unsigned long lastmillis = 0;
  int rpm;

  if (millis() - lastmillis >= 1000) {

    lastmillis = millis();

    rpm = rpmcounter * 30;
    rpmcounter = 0;

    Serial.print("fan ");
    Serial.print(": ");
    Serial.print(rpm);
    Serial.print("\t");

    Serial.println();
  }

}

Debug Messages:

[E][esp32-hal-i2c.c:593] i2cDumpDqData(): [0] 40 W STOP buf@=0x3ffc24ce, len=1, pos=1, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:609] i2cDumpDqData(): 0x0000: .                                12 
[E][esp32-hal-i2c.c:948] i2cDumpInts(): 1 row  count   INTR    TX     RX
[E][esp32-hal-i2c.c:951] i2cDumpInts(): [01] 0x0001 0x0202 0x0002 0x0000 0x00002340
[E][esp32-hal-i2c.c:951] i2cDumpInts(): [02] 0x0001 0x0040 0x0000 0x0000 0x00002340
[E][esp32-hal-i2c.c:951] i2cDumpInts(): [03] 0x0001 0x0020 0x0000 0x0000 0x00002340
[I][esp32-hal-i2c.c:971] i2cProcQueue(): Bus busy, reinit
[E][esp32-hal-i2c.c:620] i2cDumpI2c(): i2c=0x3ffc1060
[E][esp32-hal-i2c.c:621] i2cDumpI2c(): dev=0x60027000 date=0x16042000
[E][esp32-hal-i2c.c:623] i2cDumpI2c(): lock=0x3ffc5d78
[E][esp32-hal-i2c.c:625] i2cDumpI2c(): num=1
[E][esp32-hal-i2c.c:626] i2cDumpI2c(): mode=1
[E][esp32-hal-i2c.c:627] i2cDumpI2c(): stage=3
[E][esp32-hal-i2c.c:628] i2cDumpI2c(): error=5
[E][esp32-hal-i2c.c:629] i2cDumpI2c(): event=0x3ffc5dfc bits=112
[E][esp32-hal-i2c.c:630] i2cDumpI2c(): intr_handle=0x3ffc5e2c
[E][esp32-hal-i2c.c:631] i2cDumpI2c(): dq=0x3ffc5dd8
[E][esp32-hal-i2c.c:632] i2cDumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:633] i2cDumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:634] i2cDumpI2c(): byteCnt=1

Libraries used:

https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library

Digital read function:

uint8_t Adafruit_MCP23017::digitalRead(uint8_t pin) {
	uint8_t bit=bitForPin(pin);
	uint8_t regAddr=regForPin(pin,MCP23017_GPIOA,MCP23017_GPIOB);
	return (readRegister(regAddr) >> bit) & 0x1;
}

I2C Progress?

I know that you were working on I2C for ESP32, which I much appreciate. Where are you in that process? Do you think we will have master, slave and multimaster working soon? I think the problem was one of managing multiple users of I2C and preventing conflict, but I lost track of your progress.

Thanks again.

David

Compilation error with recent changes

I've just refreshed the i2c files from your fork and can no longer compile.

D:\OneDrive\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-i2c.c: In function 'i2cInit':

D:\OneDrive\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-i2c.c:329:5: warning: implicit declaration of function 'i2cReleaseISR' [-Wimplicit-function-declaration]

     i2cReleaseISR(i2c); // ISR exists, release it before disabling hardware

Core dump when doing I2C Address scan

Hardware:

Board: Custom
Core Installation/update date: 2017/11/29
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

I managed to find another issue today. When I do a scan of the I2C bus for addresses, I get a core dump and it points to this line (around 852) of the i2c hal file. I checked and byteCnt =1 and queuePos = 0 in this situation.

if(p_i2c->byteCnt > p_i2c->dq[p_i2c->queuePos].queueLength){// simulate Trans_start

Does the code rely on the receipt of a byte that it won't get when scanning?

I2C error messages at startup

Please fill the info fields, it helps to get you faster support ;)

If you have a Guru Meditation Error, please decode it:
https://github.com/me-no-dev/EspExceptionDecoder

----------------------------- Remove above -----------------------------

Hardware:

Board: Custom
Core Installation/update date: 2017/11/27
IDE name: Arduino IDE
Flash Frequency: 40Mhz
Upload Speed: 115200

Description:

Hey Chuck,

I just pulled down your latest today, an update from 8-10 days ago and now I am getting a bunch of the following messages right at startup:

[E][esp32-hal-i2c.c:550] dumpI2c(): i2c=0x3ffc10c4
[E][esp32-hal-i2c.c:551] dumpI2c(): dev=0x60013000
[E][esp32-hal-i2c.c:552] dumpI2c(): lock=0x3ffd16c4
[E][esp32-hal-i2c.c:553] dumpI2c(): num=0
[E][esp32-hal-i2c.c:554] dumpI2c(): mode=1
[E][esp32-hal-i2c.c:555] dumpI2c(): stage=3
[E][esp32-hal-i2c.c:556] dumpI2c(): error=6
[E][esp32-hal-i2c.c:557] dumpI2c(): event=0x3ffe3590 bits=92
[E][esp32-hal-i2c.c:558] dumpI2c(): intr_handle=0x3ffe2ec4
[E][esp32-hal-i2c.c:559] dumpI2c(): dq=0x3ffe30e0
[E][esp32-hal-i2c.c:560] dumpI2c(): queueCount=1
[E][esp32-hal-i2c.c:561] dumpI2c(): queuePos=0
[E][esp32-hal-i2c.c:562] dumpI2c(): byteCnt=1
[E][esp32-hal-i2c.c:567] dumpI2c(): [0] 61 R STOP buf@=0x3ffd5c98, len=1, pos=0, eventH=0x0 bits=0
[E][esp32-hal-i2c.c:895] i2cDumpInts(): row count INTR TX RX
[E][esp32-hal-i2c.c:898] i2cDumpInts(): [01] 0x0001 0x0002 0x0001 0x0000 0x000015c6
[E][esp32-hal-i2c.c:898] i2cDumpInts(): [02] 0x0001 0x0200 0x0000 0x0000 0x000015c6
[E][esp32-hal-i2c.c:898] i2cDumpInts(): [03] 0x0001 0x0040 0x0000 0x0000 0x000015c6
[E][esp32-hal-i2c.c:898] i2cDumpInts(): [04] 0x0001 0x0100 0x0000 0x0000 0x000015d3
[E][esp32-hal-i2c.c:550] dumpI2c(): i2c=0x3ffc10c4
[E][esp32-hal-i2c.c:551] dumpI2c(): dev=0x60013000

After this, everything stabilizes. I suspect it is just connected hardware coming online but it is new and your code is updated so was wondering if you had changed anything that affects startup.

I2C not working with RTClib using DS3231

Hardware:

Board: ESP32 Dev Module and ESP32 Nodemcu CP2102 Module and
HiLetgo ESP-WROOM-32 ESP32 ESP-32S
Core Installation/update date: ?11/jul/2017?
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

Doesn't appear to communicate with DS3231

Sketch:

// Init and get the time
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
getLocalTime(&timeinfo);
Serial.print("In Setup - Time from Internet ");
Serial.print(timeinfo.tm_hour);
Serial.print(" : ");
Serial.print(timeinfo.tm_min);
Serial.print(" : ");
Serial.println(timeinfo.tm_sec);
iyear = timeinfo.tm_year;
bmonth = timeinfo.tm_mon;
bdayOfMonth = timeinfo.tm_mday;
bhour = timeinfo.tm_hour;
bminute = timeinfo.tm_min;
bsecond = timeinfo.tm_sec;
rtc.adjust(DateTime(iyear, bmonth, bdayOfMonth, bhour, bminute, bsecond));
// rtc.adjust(DateTime(F(DATE), F(TIME)));
// rtc.adjust(DateTime(2019, 1, 25, 20, 33, 30));
delay(10);
now_time = rtc.now();
bhour = now_time.hour();
bminute = now_time.minute();
last_sec = now_time.second();
Serial.print("In Setup - Time from RTC ");
Serial.print(bhour);
Serial.print(" : ");
Serial.print(bminute);
Serial.print(" : ");
Serial.println(last_sec);

Code above returns correct time from Internet and all 0's from DS3231. Added the 5 files from the patch - no different.

Thanks, Theron Wierenga

//Change the code below by your sketch
#include <Arduino.h>

void setup() {
}

void loop() {
}


### Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here

Compilation Warning with 2 of July version

Hardware:

Board: ESP32 WEMOS LOLIN32 WROOM
Core Installation/update date: 11/jan/2017 (last version from Github
IDE name: Arduino IDE
Flash Frequency: ?40Mhz?
Upload Speed: ?115200?

Description:

Describe your problem here
@stickbreaker
I still have random issue with the wire library (currently using your patched version of the 13 of March)
So I did reinstall your complete save set of the 2nd of July, that looks OK for the time being.
However I have some compilation errors (something I had in the past but was solved by reinstalling the software) and I am wondering if this is due to my set-up or if this a general one.

Arduino/Sketch/hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c: In function 'i2cInit':
Arduino/Sketch/hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c:329:5: warning: implicit declaration of function 'i2cReleaseISR' [-Wimplicit-function-declaration]
i2cReleaseISR(i2c); // ISR exists, release it before disabling hardware
^
Arduino/Sketch/hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c: At top level:
Arduino/Sketch/hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c:1242:6: warning: conflicting types for 'i2cReleaseISR'
void i2cReleaseISR(i2c_t * i2c){
^
Arduino/Sketch/hardware/espressif/esp32/cores/esp32/esp32-hal-i2c.c:329:5: note: previous implicit declaration of 'i2cReleaseISR' was here
i2cReleaseISR(i2c); // ISR exists, release it before disabling hardware

Thanks in advance Robert

ESP32-S2 Support

Hardware:

Board: ESP32-S2 Dev Module

Simply a support request for the ESP32-S2 board
Cheers

Grosstimeout dead?

Any ideas on this one, appears every minute or so ?

It still works pretty well, just be nice to fix this error :)

Thanks.

[1B][0;31m[E][esp32-hal-i2c.c:1220] i2cProcQueue(): Gross Timeout Dead start=0x1e6b2b, end=0x1e6b8f, =100, max=100 error=1[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:638] i2cDumpI2c(): i2c=0x3ffb13e8[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:649] i2cDumpI2c(): dev=0x60013000 date=0x16042000 level=ERROR[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:651] i2cDumpI2c(): lock=0x3ffce1fc[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:653] i2cDumpI2c(): num=0[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:654] i2cDumpI2c(): mode=1[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:655] i2cDumpI2c(): stage=3[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:656] i2cDumpI2c(): error=1[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:657] i2cDumpI2c(): event=0x3ffd2658 bits=0[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:658] i2cDumpI2c(): intr_handle=0x3ffce260[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:659] i2cDumpI2c(): dq=0x3ffd4ce4[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:660] i2cDumpI2c(): queueCount=2[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:661] i2cDumpI2c(): queuePos=1[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:662] i2cDumpI2c(): byteCnt=1[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:612] i2cDumpDqData(): [0] ee W buf@=0x3ffb87ce, len=1, pos=1, eventH=0x0 bits=0[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:628] i2cDumpDqData(): 0x0000: . 00 [1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:612] i2cDumpDqData(): [1] ef R STOP buf@=0x3ffb8748, len=3, pos=0, eventH=0x0 bits=0[1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:628] i2cDumpDqData(): 0x0000: .8. 09 38 ff [1B][0m
[1B][0;31m[E][esp32-hal-i2c.c:982] i2cDumpInts(): enable Core Debug Level "Error"[1B][0m
V (1993971) intr_alloc: esp_intr_free: Disabling int, killing handler[1B][0m
V (1993977) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args[1B][0m
V (1993984) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0xE[1B][0m

different behavior of DS3231 on rev0 and rev1 chips.

I just made an interesting observation: My DS3231 (RTC) module works on ESP32 rev0, but does NOT on rev1 chips. This observation holds even when I switch from your I2C fork to the origin/master repository.
An at24c32 EEPROM on the very same I2C bus works on both chip revisions.

FYI: I do not use any Wire.endTransmission(false); calls.

Question about using RTOS and I2C

Hello , I have just a question not an issue .

So i started to work on one esp32 project i must use RTOS as i need to run more tasks independently , so i actually read some sensors and send to server .

My question is as i have about 4-5 I2C devices, and suspect that in RTOS I2C get unstable and crash sometime causing module to restart. So what i do is every communication with devices over I2C i put like semaphores so only one communication at a time is available , i think that it crash when i have more tasks reading sensors maybe two tasks reading different sensor go immediately one after another.

What is solution or is it okay to do like this , or to remove so I2C can be used in RTOS as in normal running code.

Compiling on Arduino IDE 1.8.5 with maximum compiler warnings causes compilation to fail

Compiling on Arduino IDE 1.8.5 with maximum compiler warnings causes compilation to fail. (warnings treated as errors).

example console output:

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'int8_t EEPROMClass::readChar(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:188:46: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

   return EEPROMClass::readAll (address, value);

                                              ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'uint8_t EEPROMClass::readUChar(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:194:46: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

   return EEPROMClass::readAll (address, value);

                                              ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'int16_t EEPROMClass::readShort(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:199:11: note: 'value' was declared here

   int16_t value;

           ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'uint16_t EEPROMClass::readUShort(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:205:12: note: 'value' was declared here

   uint16_t value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'int32_t EEPROMClass::readLong(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:223:11: note: 'value' was declared here

   int32_t value;

           ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'uint32_t EEPROMClass::readULong(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:229:12: note: 'value' was declared here

   uint32_t value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'int64_t EEPROMClass::readLong64(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:235:11: note: 'value' was declared here

   int64_t value;

           ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'uint64_t EEPROMClass::readULong64(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:241:12: note: 'value' was declared here

   uint64_t value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'float_t EEPROMClass::readFloat(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:247:11: note: 'value' was declared here

   float_t value;

           ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'double_t EEPROMClass::readDouble(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:317:12: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

     return value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:253:12: note: 'value' was declared here

   double_t value;

            ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: In member function 'bool EEPROMClass::readBool(int)':

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:260:54: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]

   return EEPROMClass::readAll (address, value) ? 1 : 0;

                                                      ^

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp: At global scope:

C:\Users\e\Documents\Arduino\hardware\espressif\esp32\libraries\EEPROM\EEPROM.cpp:32:20: warning: 'TAG' defined but not used [-Wunused-variable]

 static const char* TAG = "eeprom";

                    ^

cc1plus.exe: some warnings being treated as errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.