The following arduino code is used for automation of sensors using ESP8266 and android app built using MIT App Inventor. ESP8266 can be directly connected to the home or any network by using a mobile phone or PC. When ESP8266 is powered on its name can be seen on PC or mobile phone for avoiding hard coading of wifi credentials. By clicking on it, a web page will be displayed to enter the wifi credentials of the router or device used to connect to the internet. Google's firebase is used to store the status of the bits and it can be toggled using an android device to switch on/off the relay to control the appliances.
The following firebase authentication key and url of esp8266 has to match with the authentication key and url of the android app.