logo elektroda
logo elektroda
X
logo elektroda

How to start i2c communication between NodeMcu and Wemos D1?

omnixcrs 1392 15
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18474243
    omnixcrs
    Level 11  
    Welcome,

    colleagues I am running out of ideas for the above problem. I have been trying for a few hours to get i2c communication working between the NodeMcu and the Wemos D1 mini.
    I have connected both boards with ground and d1 to d1 and d2 to d2. Of course the lines pulled up to the power supply via 4k7. Node as master and Wemos as slave. Unfortunately after uploading the programs in the ports monitor nothing !
    I paste the codes, they are almost finished examples, maybe I have rewritten something wrong.

    Master to node code:
    Code: C / C++
    Log in, to see the code
    .

    code to slave Wemos:
    Code: C / C++
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #2 18474289
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #3 18474311
    omnixcrs
    Level 11  
    function returns value 2

    Added after 11 [minutes]:

    I've connected an arduino nano instead of wemos for testing, removing the line "Wire.begin(D2, D1);" and it works without a problem, I suspect that this is where the problem will be with this addressing or pin setting, maybe it writes wrong ???
    I have also tried writing in this form: " Wire.begin(D2,D1,8); " and also nothing.
  • Helpful post
    #4 18474382
    Anonymous
    Level 1  
  • #5 18474388
    omnixcrs
    Level 11  
    As I wrote above I also used: "Wire.begin(D2, D1, 8);" and it did not do anything.
    I read somewhere that esp 12 does not have the option to work in SLAVE mode is it possible ???
    I connected another esp instead of WEMOSA, namely another NodeMcu and also nothing.
  • Helpful post
    #6 18475388
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #7 18476318
    omnixcrs
    Level 11  
    Hmm.... I understand in that case I will give up esp as sleve and replace it with some Adriano uno or mega, I think they support slave MODE.
  • ADVERTISEMENT
  • Helpful post
    #8 18476437
    Anonymous
    Level 1  
  • #9 18477006
    omnixcrs
    Level 11  
    Yes, I know. Thanks for your help khoam!
  • #10 18504131
    omnixcrs
    Level 11  
    Hello, I have another question, will the esp32 support slave mode?
  • #11 18504298
    Anonymous
    Level 1  
  • #12 18504875
    omnixcrs
    Level 11  
    Aha, so in short I can't use the ESP32 as a slave by programming it from the Arduino IDE, yes ??
  • #14 18505362
    omnixcrs
    Level 11  
    Ok, I'll figure it out somehow. Tell me just a little bit off the top of my head: Because I have to build a network of temp sensors on a site where distances are known. These will be DS18b20 onewire. I have read from various sources that the safest way is to build a bus with a maximum length of up to 100m. I need to deploy about 30 sensors so I will certainly exceed 100m so I thought I would create for example 3-4 buses on different pins on one esp, is this possible and will it work?
  • #15 18505375
    Anonymous
    Level 1  
  • #16 18505406
    omnixcrs
    Level 11  
    Ok I am already creating.

Topic summary

The discussion revolves around establishing I2C communication between a NodeMCU and a Wemos D1 mini, with the NodeMCU configured as the master and the Wemos as the slave. The user encountered issues with the communication, specifically receiving a NACK (Negative Acknowledgement) when attempting to transmit data. Various troubleshooting steps were suggested, including verifying the return value of the Wire.endTransmission() function, which indicated errors. The user tested with an Arduino Nano, which worked successfully, leading to suspicions about the Wemos D1's configuration. It was noted that the ESP8266 (NodeMCU and Wemos D1) lacks a hardware I2C controller, complicating slave mode functionality. The conversation also touched on the ESP32's limitations regarding slave mode in the Arduino HAL. Ultimately, the user considered switching to an Arduino Uno or Mega for reliable slave mode support and inquired about deploying multiple temperature sensors using DS18B20 on a long bus.
Summary generated by the language model.
ADVERTISEMENT