Communicate between NodeMCU ESP8266 gateway and multiple sensor nodes

What is the best wired way to communicate between multiple NodeMCU ESP8266 boards for home automation.

Every room should get at least a light, temp, PIR and xx relay modules to switch things on and off.

To connect all these sensors the GPIOs from one NodeMCU are sometimes not enough.

To reach this goal I planned to install in every room one NodeMCU as gateway and multiple NodeMCU as nodes for my sensors. The gateway will receive and forward information from/to my openHAB center via MQTT messaging.

I thought to use an RS-485 2-Wire connection between my sensor nodes and the room gateway. The gateway from my room will be connected via wifi or wired cable to my network.

I2C seems more to be for communication directly on PCBs or only short wiring.

Do you have any suggestions for me, is my plan possible? Any better ideas?

I would experiment with i2c I/O extenders first. I2c will go further than you think, as long as you use the standard (slow) 100KHz speed and use some stronger pull-ups resistors (1K5, 1K, even 510R). That way you can avoid having multiple nodemcus each will their own sketch.

But if you are planning to use nodemcus as sensor nodes, why not just forget the room gateways and let the nodes connect directly with the mqtt server?

Alternatively, keep the light/temp/pir local to the nodemcus and local i2c/ SPI I/o extenders with low voltage wires going out to remote/dumb relay modules.

I would experiment with i2c I/O extenders first...

Do you have an example for the I2C I/O extender that I could use together with NodeMCU ESP8266?

That way you can avoid having multiple nodemcus each will their own sketch.

What exactly do you mean?

But if you are planning to use nodemcus as sensor nodes, why not just forget the room gateways and let the nodes connect directly with the mqtt server?

Then I would need to use the onboard wifi module right? And like I said I like to have an wired connection. Because I have bad experience here in my house with to many wifi connections.

ehome:
Do you have an example for the I2C I/O extender that I could use together with NodeMCU ESP8266?

No, I'll have to write a short one for you. It's very easy.

ehome:
What exactly do you mean?

The "slave" nodemcus will need a different sketch from the gateways, and both will be made more complex because of having to communicate with each other over a second comms standard. Using an esp and not using its WiFi capability sounds a little pointless. But they are cheap and you get loads more speed, ram etc compared to a atmega328 I suppose.

ehome:
Then I would need to use the onboard wifi module right? And like I said I like to have an wired connection. Because I have bad experience here in my house with to many wifi connections.

You did not say why before, only that you wanted to cable some of the nodemcus, which sounded strange. And still does: what kind of problems? Time for a new & better router?

oh yes sorry, forgot to say the reason.

  1. Bad experience with the reliability of wifi in my house. I already have multiple routers. And I already tried different kind of routers, frequencies, etc… I think we have bad materials in the walls and ceilings.

  2. I’d like to take the advantage of the better performance of the ESP’s. More space for sketch, etc… In the future I maybe like to try some crazy things with NeoPixel stripes :slight_smile:

  3. And because of security purposes. In my eyes an wired connection is more secure than wifi.
    O.k currently this is not so important if I just like to control lights, etc… but maybe this will change in the future…

  4. I was not able to find a similar sensor like the ESP. Best would be one with ethernet onboard :slight_smile:

I have similar problems. Thick sandstone walls, one of which is inside the house, so I need 3 wireless routers. Two in the house and one for the conservatory. But I have 6 or 7 ESPs running without any problems I am aware of, on top of various PCs, laptops, tablets, phones, media players.

ESP is not a sensor. It's an MCU with WiFi. I assume you meant to say MCU. It would be good to have some more 32-bit MCU dev boards with Ethernet or LoRa built in.

Yeah sorry you are correct, I meant for example the NodeMCU board.

And I totally agree that it would be good to have more such boards with little bit more GIO's (workaround i2c expander) and build in wired ethernet.