I need Esp8266 code for automation

I need to automate my home using RASPBERRYPI + ESP8266 + RELAY + OPENHAB2.
I have dump Openhab 2 in my raspberry pi and I need code for ESP8266 (Arduino sketch).Please help me out. Thanks in advance


There are hundreds of them in the www. You should find one with MQTT support, that is the easiest way to connect ESP8266 to openHAB.
Also you could use an alternative firmware like ESPEasy, MQTT openHAB support already built in.

Sonoff is very easy, when you have some knowlage with arduino.

Homie is also a good framework to do tis.