-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ESP8266 I2C Master issue #4396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Adding #include <Arduino.h> made no changes. Meanwhile,the I2C Master and Slave examples work fine. That is, I can put I2C_Slave on Uno and I2C_Master on NodeMCU and get hello hello hello hello. The examples use different functions but I used them to prove my level shifter works from 3.3 to 5v and wiring was ok. It works without the shifter too. Why doesn't "send_ack_signal" ever come true on ESP8266? Help! |
@Eddiiie please edit your post and put a complete minimal code example (MCVE sketch). Without that, it's unlikely this will be looked at. |
There is no more code that does anything with send_ack_signal it is all in the background.
I will post code but you will not see anything with send_ack_signal.
…________________________________
From: WereCatf <[email protected]>
Sent: Tuesday, February 20, 2018 4:35 AM
To: esp8266/Arduino
Cc: Eddiiie; Author
Subject: Re: [esp8266/Arduino] ESP8266 I2C Master issue (#4396)
How should anyone know what's going on with this "send_ack_signal" when you're not showing any of the relevant code?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#4396 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AKItQOKzo4kAGVmL8XU7w7pZNBiDBVsqks5tWrv1gaJpZM4SLYsq>.
|
@Eddiiie Where does this send_ack_signal come from, then? There is no such thing anywhere in the ESP8266 Arduino-env source-code. |
It is clearly magic that the Arduino has that the ESP doesn't. :) |
code moved to top
|
I think you are leaving something out or you have a modified codebase, because there is no reference, whatsoever, to send_ack_signal anywhere in either the Atmel- or the ESP8266-codebase. If nothing uses the variable, then obviously nothing is going to change it from false to true, either. |
I agree with previous comment: a quick search reveals no such variable anywhere in the AVR Wire code base. Or anywhere else, for that matter. |
Sorry my bad. It has been a really hard day. The sample code is missing "Wire.onReceive(i2c_receive_isr);" just after the "Wire.begin(12, 14);" line. Wire.onReceive "Registers a function to be called when a slave device receives a transmission from a master." My code Wire.Receive defines a function "i2c_receive_isr" that sets a global boolean variable "send_ack_signal" to TRUE (or FALSE). SO, it appears the issue in my case is that the function defined in Wire.onReceive() is not being executed on the ESP8266, whereas it is working on the Mega and Uno. I will now add some serial.print lines in the i2c_receive_isr function to confirm or deny this. |
The isr should be in RAM, and the global should be declared volatile. |
Code updated.. Note, I added volatile, tested, no change. Also added print lines to the ISR code, it does not show up. |
I just looked at the actual Wire-library and... well, it doesn't look like I2C-slave is supported at all on the ESP8266 at the moment. The relevant functions don't actually do anything and all the slave-mode code has been commented out. No reason is mentioned in the comments, so I do not know why. |
This issue describes an i2c master issue. The previous comment addresses an i2c slave shortcoming, which is a different issue. If you need the latter, try pr #3287 , and report back how it works. If you confirm that pr, it would help to move that feature forward. |
Let's leave it closed. I'll stick with the Uno. I think the issue can be summed up to be that the function (isr) defined by calling wire.onReceive() never executes. Like you say, this is most likely a known issue. #3287 is pretty close. Thanks for the time. |
I am sorry, does 3287 have code that I can test somehow? I've never done that before. Is it a pull request? I will google how to do it. All the notes and links is overwhelming at first. From what I understand, in proper I2C protocol every time a Master talks to a slave, the slave needs to acknowledge that the conversation has been heard. (or something like that :P) To me, in order for this to happen, the Master needs to change to slave mode for a moment to get that ACK. Maybe my explanation is not exactly accurate but I believe wire.onReceive() is a slave state type thing... The reason the I2C_Master example code works is because it just puts the bits on the wire, it does not look for an ACK or proper handshake. Off to see what to do with a pull request? |
Not quite: the I2C-master sends 8 bits on the line (ie. the I2C-address of the slave it wants to communicate with and one bit to indicate whether it wants data from the slave or to send data to it), then the master waits passively for a bit and the slave is supposed to send an ACK by pulling SCL LOW for a bit. No need to change from master to slave. As for Wire.onReceive() -- yes, it's a slave-thing and, like I mentioned, the function doesn't do anything at the moment. |
@WereCatf thanks once again. It is not a master thing at all.. It is that the code does not exist yet. Are bounties / bribes accepted? |
would it be ok to change the title of this to "Please complete Wire.onRequest()" ? |
I happy to test but will need my hand held through getting the PR code and making sure it is used rather than the master. I am trying to finger that out now. |
I'll just rename the existing files in program files (x86)\Arduino\hardware\esp8266com\libraries\Wire |
Hmm it does not appear to be using it from that folder. |
Basic Infos
I am working with a multimaster setup. Have PoC code that works just fine on Uno and Mega, but when I try to run it on ESP8266 Arduino Lib it hangs on waiting for a variable to change from 0 to 1. - a Callback I guess you'd say.
It is awesome that I can specify pin numbers to use, wish that would work on Mega and Uno...
Code:
The 'while' loop never exits on ESP8266.
"send_ack_signal" is the function I defined that gets registered when you call Wire.onReceive().
Hardware
Hardware: ?ESP-12?
Core Version: ?2.1.0-rc2?
I've confirmed this on Heltec Wifi 8 kit, NodeMCU, and WeMOS D1.
Settings in IDE
Module: Heltec Wiki 8 kit, NodeMCU, WeMOS D1
Flash Size: 4MB I believe
CPU Frequency: Tested 80 and 160
Flash Mode: huh?
Flash Frequency: once a day? :)
Upload Using: Arduino ISP ?
Reset Method: Power cycle
The text was updated successfully, but these errors were encountered: