ESP8266 I2C communication

As per subject... is it even possible?

Longer story: I'm trying to get two ESP8266 devices to communicate over I2C. One in master mode (no issues there), the other as slave.

So I set up the MasterWriter, and it didn't work. Then I started looking a bit further - and found some older info on ESP8266 not supporting slave mode, newer info claiming it is possible, but nothing that feels conclusive.

Really hope to get it to work, as short of a complete redesign it's all I have available... a possible solution would be Arduino + ESP01 module but that's layer upon layer, with the extra communication making it worse

Complete problem at hand: it's an ESP8266 based controller board that has to go inside a stainless steel fridge, and connect to the WiFi. That's not going to work when surrounded by metal. Bringing the box out is not an option (too many wires to different peripherals and sensors); so it's got to be a wire to a second ESP that's outside the fridge and that takes care of the internet communications and data logging (using the internal flash).

The logical solution: use a WiFi module with external aerial connector, like an ESP-07.
You can find WiFi aerials with ~20-30cm wire and connector in the screen of an old/broken laptop.
Leo..

Edit: Disable ceramic aerial.

Is the question about best way to send data between two devices using wires?

Look for other communication methods when I2C slave makes trouble. I don't know the ESP8266 regarding I/O but a centronics interface is one suggestion.

Railroader:
I don't know the ESP8266 regarding I/O but a centronics interface is one suggestion.

Centronics interface?

Yes. That was the communication between Pc and printers during the stoneage…
Use two wires, + GND. Place the data on the data wire, issue a pulse on the other wire as Clock. Eventually use some handshake wire…

The ESP-07 looks good, thanks for the suggestion. Pin compatible with the ESP12 so fits on the existing board. Just need to assemble a new one... I completely overlooked that possibility, just blinded by the solution I had in mind (as happens so often :-))

Extension wires seem to be no problem, I've found wires of over a meter long. Just have to find a way to keep that as short as reasonably possible to minimise losses.

Two ESP8266 may exchange data using Software UART Ports like ordinary Arduino UNOs.
nodeMCUNode.png

nodeMCUNode.png

I know - that's another option, but I would use the hardware UART for that, beyond programming it's just sitting idle and everything else has been taken already.
GPIO2 (Serial1) can of course be used for debugging.

Another alternative with the ability to connect an external antenna would be Wemos Mini Pro. With these also, you must move a small resistor to different pads to enable the external antenna.

But I'm not sure why you are using an esp inside the fridge anyway. I know they're cheap, but so are Arduino Pro Mini clones, Nano etc. And they have fewer problems acting as i2c slave.

Are you certain you even need a processor inside the fridge? Can't you just use 1-wire or i2c sensors inside the fridge and have the esp on the outside?

Yes, certain I need it there. It's got to control eight trays worth of hydroponic vegetables :slight_smile: Pumps, sensors, etc. If it were a run-of-the-mill fridge used as fridge, then indeed you wouldn't need a microcontroller inside.

I know the Arduino works great as I2C slave - if the ATtiny is anything to go by, that is. I've done that before, very easy and straightforward to get it working. Chosen the ESP for this project for the WiFi communication requirement. Squeezing the whole thing in the memory of an ATmega328 would've been another major challenge (and I'd still need at least one MCP23017 to get enough I/O).

wvmarle:
Yes, certain I need it there... I'd still need at least one MCP23017 to get enough I/O.

I still don't understand why you say your are "certain". Why can't the sensors and controls be entirely i2c? What do you have that can't be done like that?

Any project design where two or more microprocessors are used should be scrutinized very carefully. Sometimes they can be justified in terms of cost or complexity, but generally speaking, when you question the decision, you find the "justifications" simply evaporate. In the projects I have completed so far, I have used two processors once only (my Weather Station has a tiny85 to monitor wind sensors while the esp8266 is in deep sleep). I have plans to replace that design, LoRa instead of WiFi, and I'm pretty certain I can to get back to a single processor.

Wire length is one obstacle for I2C. The sensors themselves - giving a simple high/low output, flow sensors with a pulse output. Pump controls - the MOSFET based power switches. pH sensor and EC sensor are not I2C.
That's all done inside the fridge, hidden from view. That's why the controller is also in there. The only real issue is to get the WiFi signal out - and an external antenna would probably do this just fine, except for antenna cable length. Indeed a multi-controller design is to be avoided for a single project.

Anyway… I’m no expert on hydroponics, but I thought the idea was to grow stuff faster. But a fridge is designed to stop stuff growing at all (or at least stop stuff growing on your food). So what is this project?

Hydroponic fridge, where the fridge is mostly used as box to grow in. We probably don't need the cooling part at all (the aircon of the building it's in should be enough).

One place where you see refrigeration (typically referred to as "air conditioning" in that application) used for growing is to grow lettuces (which like temperatures of 20-25°C) indoors in hot climates.

It's not meant for commercial growing. It's more like a demo/showcase.

ESP8266(I2C Master) to ESP8266(I2C Slave) works from 2.5.0: See my comments here: ESP8266 to ESP8266 i2c · Issue #3046 · esp8266/Arduino · GitHub

Apparently still experimental.

What about the PSON library? Depends on how much data and how fast you need it but it's meant to be robust.