How to send feedback from the sensor via e-mail?
Go to files and click on Preferences in the Arduino IDE.
Copy the below code in the Additional Boards Manager: http://arduino.esp8266.com/stable/package_esp8266com_index.json
Click OK to close the Preference tab. Now we need to install the NodeMCU ESP8266 device in the Boards Manager.
When the installation is complete, we select NodeMCU v1.0 and the corresponding port.
The first thing you need to enter in the program is to provide basic information about your WiFi to which NodeMCU should connect, as well as information about your e-mail address and passwords, but converted from base64encode, and information about e-mail addresses.
The setup() function connects to your WiFi.
In the loop() function we read the data that we collect from the sensor. We check the brightness level of the projection, in the case of a light diminishing below 100, an e-mail message is sent automatically to illuminate the light.
In the sendEmail function, a connection is made to your e-mail and an e-mail message with information of light is sent.
And finally the eRcv() function checks whether the client to whom it is accessed is free.
The first time you try to connect to your e-mail with NodeMCU, you will receive a message that your Google account has just prevented the connection from an unknown device. While working, check to allow less secure devices to connect to e-mail.
We suggest that you create a new e-mail to use for sending information.
The code displays information about the port and e-mail for Google accounts or for Gmail if you use another mail. And if it is not Gmail, you must find this information for your mail.
(client.connect("smtp.gmail.com", 465) == 1)