ugo_arrigoni:
Thanks for the warning, i didn't mind about the safety but now after your advise i see there is more research to be done.
The other option is an "ice cube" relay with a socket base. Those too are usually rated and safe for use with 220V.
ugo_arrigoni:
Well, i already know how to control leds, relays and to read and print data from/to the serial monitor. I already have the libraries added to arduino ide. The problem is just putting all parts together and how to organize my code.
The key is to minimize the amount of programming in loop(). 80% of the programming in loop() should be a called to a sub-function. As an example, the read from the DHT22 should be done in a separate routine. If you really go all-out with that philosophy, then loop will have only three function calls. DHT22_read(), relay_control(), and ESP8266_write(). I'm not sure about the last it may take more, but for sure on the other two.
Here's step 4 loop routine.
loop()
{
DHT22_read();
}
For step 5:
loop()
{
DHT22_read();
relay_control();
}
There you go, one function already written
Seriously though, if you follow that methodology, then adding and testing of each new piece is much easier.