NodeMCU and I2C issue

hey folks,

I'm having an issue trying to make a NodeMCU to communicate with an Arduino-based custom board.

First, I have a Nano that send 1 byte to a custom board, that has an ATTiny2313 that upon receiving that byte, will display something.

I have a "sniffer" that capture the packets, and the result is as expected.

When I connect my NodeMCU, the display board doesn't do anything: but the sniffer capture some activity: request to write something to address 01 with "NoAck"

I know the pinout is good on my NodeMCU, otherwise I wouldn't sniff anything. I have reversed the signals (SCL vs SDA) and when I do it, my sniffer doesn't catch anything.

Anyone has an idea of what my be wrong ?
I suspected that the NodeMCU might be on a weird speed. I've added the following line: Wire.setClock(400000L) with no luck.

Are the Gnds connected between units?

How did you program the Attiny2313? Did you add this to the IDE for it?

yes,

GND are connected together. Vcc is not. Pull-up are in place (4.7k across 3.3v) Maybe I should try a lower value ??

Yes, the SpenceKonde library is what I've used. I do not suspect that board to be the problem, as it works fine with 2-3 other boards that I did.

The final board that I plan to use is actually not that one (I use it as a test board), but if I can't make it work with that one, if will definitely not work with the other !

just had a ""flash"

NodeMCU is 3.3v. Pull ups are tied to the 3.3v

My ATTiny2313 is 5v.

could it be that the pull-ups only bring the signal to 3.3v which is unsufficient for the ATTiny2313 to "see" a high level ?

any risk if I connect to 5v despite the fact that the NodeMCU is 3.3v based ? it would not be a direct 5v but rather thru the pull-ups ?

Do you really have to use the I2C bus between the ATtiny and the NodeMCU ?
Do you know if the ATtiny does work in Slave mode ?
Do you really have to use the ATtiny, can you try with an Arduino Uno.

I wrote a page to scare new users for these situations: How to make a reliable I2C bus · Koepel/How-to-use-the-Arduino-Wire-library Wiki · GitHub.

You made me curious, what is your sniffer ?
I am very fond of the LHT00SU1 logic analyzer in combination with sigrok/PulseView.

Can you show your sketches ?
Keep the default speed of the I2C bus (100kHz).
The ESP8266 is more or less 5V tolerant. You could try 10k pullup resistors to 5V to raise the level. Never do that with a ESP32. You can also power your ATtiny with 4V or 4.5V.
Do you use a breadboard ? They have often bad contacts.
Is your ATtiny on a breadboard ? How many decoupling capacitors are there ? Does it have a good crystal ?

You might not have just one problem, there could be more than ten problems in these situations. Or maybe the ATtiny is broken, then it is just one problem.

Yes, I2C is a must in my case

Yes, the ATTiny works fine in slave mode: I have done a few scoreboard using the same board for every digits

Sniffer is : http://www.zeroplus.com.tw/logic-analyzer_en/products.php?pdn=1&product_id=253

Just loves it. Has helped me many times to troubleshoot I2C issues

Not using a breadboard: PCB on both (master & slave) side

No crystal. Using internal clock (by memory, I think it's 2 or 8 MHz

Decoupling cap (1x) almost sitting on the CPU

As I mentioned, I don't think the slave is the problem, as it works fime with other boards, all Arduinos

This is the first time I use a NodeMCU with I2C. I will make more test tonight, but I getting convinced, it has to do with 3.3v vs 5.0v and the pull-ups connected to 3.3v instead of 5.0v

Update:

turned out that it was due to the fact that my Pull-ups were connected across the 3.3v of the NodeMCU instead of across the 5V from the ATTiny2313

Connected them to the 5v and it worked fine. I guess the High voltage on the bus wasn't high enough for the ATTiny !

Keopel: here was the trace look like when it's all good ! I am writing "02" to node "01" and received an my ACK from the slave

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.