enjoyneering / esp8266-i2c-driver Goto Github PK
View Code? Open in Web Editor NEWFixed built-in I2C driver for Arduino ESP8266 core
Fixed built-in I2C driver for Arduino ESP8266 core
Hello,
I'd like to try your implementation, but I don't want to replace the existing library files. Is that possible? Can I use it like a regular library?
Thanks,
Adam
У меня проблемы с подкючением DS3231 на ESP-01 , в начале не хочет читать время,только позже и то надо вручную это делать через веб интерфейс,что не подходит,ведь надо после включения автоматом считать время.Попробовал ваш фикс I2C ,и сразу выскочило несколько ошибок,исправить недолго,не было difine TWI_BUFFER_LENGTH и методах twi_writeTo twi_readFrom аргументы менял на unsigned char .Но RTC DS3231 вообще не работал,даже вручную.Думаю может ошибка в загруженности ESP-01 в начале инициализации.Как думаете они уже пофиксили в официальном ядре I2C?
What exactly does this fix? What is/was problem with the stock library? What changes were made to overcome it. Why should I use THIS version?
I would have expected these questions to be addressed in the README....
hi!
I Try compile sketch with you library.
(with standart libraries sketch was normal compile)
I'm replaced four files. but on compiling i have som error:
In file included from C:\Users\mr.Director\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/Arduino.h:39:0,
from C:\Users\mr.Director\Documents\Arduino\libraries\Adafruit_NeoPixel\esp8266.c:7:
C:\Users\mr.Director\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\cores\esp8266/twi.h:61:49: error: expected ';', ',' or ')' before '=' token
void twi_setClockStretchLimit(uint32_t limit = TWI_I2C_SCL_STRCH_LIMIT);
^
I have:
Arduino IDE 1.8.10
ESP8266 core ver 2.6.3
compiling for NodeMCU 1.0 (ESP12E module)
maybe you can tell in which direction to dig?
Как я смогу использовать твой фикс на platformio. Спасибо заранее.
Please use UTF-8 BOM encoding for compatibility with PlatformIO.
https://youtu.be/SDD6ZwwvWLE?t=437
Thanks for your work!
Выполнил замену.
Copy and relpace "twi.h", "core_esp8266_si2c.c" in folder %USERPROFILE%\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266
Copy and replace "Wire.h", "Wire.cpp" in folder %USERPROFILE%\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Wire
Пытаюсь подключить SI7021 к ESP01 на пины 0,2. Беру Ваш пример из библиотеки HTU21D-master SI7021_DEMO при компиляции выдает ошибку.
C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266_core_esp8266_si2c.c:157:15: error: conflicting types for 'twi_writeTo'
unsigned char twi_writeTo(unsigned char address, unsigned char * buf, unsigned int len, unsigned char sendStop){
^
In file included from C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266_core_esp8266_si2c.c:21:0:
C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\twi.h:66:9: note: previous declaration of 'twi_writeTo' was here
uint8_t twi_writeTo(uint8_t address, uint8_t *buffer, uint8_t length, bool sendStop);
^
C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266_core_esp8266_si2c.c:181:15: error: conflicting types for 'twi_readFrom'
unsigned char twi_readFrom(unsigned char address, unsigned char* buf, unsigned int len, unsigned char sendStop){
^
In file included from C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266_core_esp8266_si2c.c:21:0:
C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\twi.h:67:9: note: previous declaration of 'twi_readFrom' was here
uint8_t twi_readFrom(uint8_t address, uint8_t *buffer, uint8_t length, bool sendStop);
^
Используем библиотеку Wire версии 1.0 из папки: C:\Users\HOME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Wire
Используем библиотеку HTU21D-master версии 1.1.0 из папки: D:\Arduino\libraries\libraries\HTU21D-master
exit status 1
Ошибка компиляции для платы Generic ESP8266 Module.
I realize it's been part of the code since early on, but it's a Bad Idea. There is NO requirement in any version of the I2C spec I've seen that describes a limit on clock stretch timing. In fact, the spec clearly says that the bus theoretically goes to DC (0Hz), depending on the requirements of the slave. SMBus has a minimum speed of 10KHz, but I2C has no lower limit. I've used I2C parts before that added MUCH more stretch than is listed in this driver (230uS). By introducing an artificial and arbitrary limit on slave devices, you guarantee that a few people will have issues, and they won't know why without a DSO and some understanding of the I2C protocol.
core_esp8266_si2c.cpp line 215,
twi_setClockStretchLimit(230); //stretch SCL limit, in μsec
Here's the current ver. 6 of the I2C spec:
https://www.nxp.com/docs/en/user-guide/UM10204.pdf
If you're 'fixing' or 'improving' the original code, you should fix this as well. I did a quick Google and got 88 hits for "clock stretch limit site:arduino.cc", and at least a few of them are "it works on an Arduino but not on an ESP8266". That's because the Arduino Wire library has no artificial limit. I can't imagine a slave that's slow enough to trip the WDT on the ESP with an unusually long stretch, but I suppose it's possible with a bit-bang chunk of code and unknown parts.
your library works ok, but why you don`t use open drain on GPIO ?
#define SDA_LOW() (GPES = (1 << twi_sda)) //enable SDA (becomes OUTPUT & since GPO is 0 for the pin, it will pull the line low)
#define SDA_HIGH() (GPEC = (1 << twi_sda)) //disable SDA (becomes INPUT_PULLUP & since it has 30kOhm..100kOhm 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)
you can use it as described in "ESP8266 Technical Reference". All useful defines in esp8266/esp8266_peri.h
//GPIO (0-15) PIN Control Registers
#define GPC(p) ESP8266_REG(0x328 + ((p & 0xF) * 4))
#define GPC0 ESP8266_REG(0x328) //GPIO_PIN0
#define GPC1 ESP8266_REG(0x32C) //GPIO_PIN1
#define GPC2 ESP8266_REG(0x330) //GPIO_PIN2
#define GPC3 ESP8266_REG(0x334) //GPIO_PIN3
...//GPIO (0-15) PIN Control Bits
#define GPCWE 10 //WAKEUP_ENABLE (can be 1 only when INT_TYPE is high or low)
#define GPCI 7 //INT_TYPE (3bits) 0:disable,1:rising,2:falling,3:change,4:low,5:high
#define GPCD 2 //DRIVER 0:normal,1:open drain
#define GPCS 0 //SOURCE 0:GPIO_DATA,1:SigmaDelta
Столкнулся с неправильным формированием "REPEATED START" состояния при взаимодействии с часами MAX31343.
esp8266 - 1 master
MAX31343 - slave
pull-up`s 1K
core 3.0.2
Полная посылка на чтения времени:
Более подробно интересующий нас фрагмент:
тут видно что из-за опережения фронта SCK ошибочно формируется еще и STOP состояние, что рушит обмен с часами
можно оценить несоответствие, а ведь SDA должен быть high задооооолго до SCK:
используемый мной фрагмент кода в котором формируется "REPEATED START"
i2c_handler->beginTransmission(MAX3134X_I2C_W); i2c_handler->write(reg); i2c_handler->endTransmission(false); i2c_handler->requestFrom(MAX3134X_I2C_R, len);
т.е. при endTransmission(false) становится заметна проблема.
На мой поверхностный взгляд ошибка в функции twi_write_start (файл core_esp8266_si2c.cpp) там в первых строках по любому будет сформирован STOP.
Hello,
I can't manage to get SCL signal on Wemos D1 mini with caf5172 Dec 6, 2018.
May be something wrong in file core_esp8266.c line 60
uint16_t preferred_si2c_clock = 100000; //default I2C speed 100kHz
but does not solve my problem.
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.