This is working IoT project that allows me manage 8 relays and each relay can switch my outside lights in the garden.
First of all I started to use NodeMCU framework and Lua as programming language but after some period of time I’m stuck with some restrictions of the framework and I decided to switch to native C code using Arduino Studio. Native C code allows you do more magic things instead of NodeMCU, also you can control memory consumption more efficiently.
So, current implementation has initial mode when ESP8266 chip works as Wi-Fi access point and you able to configure module to connect to your home Wi-Fi network and MQTT server. After configuration will be set this module will be rebooted and it starts listening messages from your MQTT server. This solution uses all possible GPIO outputs in ESP8266.
Please remember that ESP8266 works at 3.3V but relays have to use 5V. I put there also transistors and LEDs to see when relay is switched ON or OFF.
Here is a full code of solution.