Dear friends welcome to another video tutorial!
This is Nick from educ8s.tv and today we are going to learn how to send an email using
the Wemos D1 board which uses the ESP8266 chip. Without any further delay, let’s get
started! Having a WiFi enabled board, like the ESP8266
enable us to do many more things. I wanted to learn how to send emails from the Wemos
Board in order to get reports from my projects to my email account easily. As you are going
to find out, it is very easy! I have built a simple project in order to
demonstrate what I mean. I have connected a DHT22 temperature and humidity sensor, and
when the project boots up, it measures the temperature and the humidity and sends the
data to my email address! This functionality can be very useful in some projects. As you
are going to find out is very easy add such functionality in your Arduino projects. But
let’s see how to build this project. The parts needed in order to build this project
are these: • A Wemos D1 board, or a Wemos D1 mini
• A DHT22 sensor • A small breadboard
• Some wires The parts that we need for this project cost
around 15$ if you use the Wemos D1 board, or around 10$ if you use the Wemos D1 mini
board. You can find links for all the parts in the description of the video.
The connection of the parts is extremely easy. All you have to do is to connect the Ground
pin of the DHT22 sensor to the Ground pin of the Wemos D1 board. Next you have to connect
the Vcc pin of the sensor to the 5V or 3.3V pin of the board. The last thing we have to
do is to connect the output pin of the sensor to digital pin 8 of the board. Now we are
ready to power up the project! After a few seconds, a new email arrives with the readings
that the sensor measured. Let’s now see the software side of the project. The code of the project consists of two parts,
the Arduino code, and the server code. We are not sending the email directly from the
board to the email address but I used another solution which in my opinion is much easier
to implement. The board all it does is to gather the data and send them to a remote
web server. There, a simple php script will send that data to any email address we want.
This way the Arduino code is extremely easy as you are going to see and we have already
build a project like this. The php code is also extremely easy, it is 7 lines of code.
Of course, you must have a web server available if you are going to use this solution. Since
2006 I use bluehost.com as my hosting provider and I host all my websites there. So, since
I had a webserver available this solution was the easiest for me to implement. It took
me less than hour to make this project work. If you don’t have a webserver available
with around 4$ per month you can have your own bluehost account. You can find a link
for it in the description of the video. Of course, you can use any other host you like,
I use bluehost for over 10 years that’s why I recommend it.
All we have to do, is to create a new php script with this code which I name it send_email.php
and upload it to the webserver. I create it under my educ8s.tv website folder so in order
to run it all we have to do is to enter this address followed by some variables: www.educ8s.tv/send_email.php?temperature=23.2&humidity=56.
What we are doing here, is we provide 2 variables to the php script manually. We provide temperature
and humidity. The php script will take the variables and it will send them with an email.
It is very easy. Can you now understand what the Arduino has to do? It only has to create
this web address with the readings from the sensor and then make a GET request to that
web page. The PHP script will automatically get the data and send them with an email. That’s exactly what we are doing in the
Arduino code. We first connect to the WiFi network and then we read the sensor. We save
the values, we convert them to Strings and send a GET request to the educ8s.tv/send_email.php
file with the values from the sensor. That’s it. The PHP script will take the data and
it will send the email. It’s that easy! As always you can find the code of the project,
both the PHP and the Arduino code in the description of the video. For obvious reasons I have removed
the send_email.php file from my webserver, so the project won’t send you an email if
you run it as it is. You have to enter your server address in the Arduino code and have
the send_email.php file uploaded to your webserver. As you can see we can now easily send email
from our Internet enabled Arduino projects. With this project we have also moved one step
forward. We now know how to send data to a remote webserver. The next step is to develop
a php script that will save that data. This way we are going to build an online datalogger
with almost unlimited storage! We can achieve all that with a 5$ board! This is impressive
in my opinion! I would love to hear your opinion on that, so please post your comments in the
comments section below! Thanks! If this is your first time here, I would love
to have you subscribed. In this channel I post videos about DIY projects every Saturday.
I love making things and I believe that anyone can make things, anyone can become a maker.
That’s why I created this channel, in order to share my knowledge with the community and
learn from the community. I hope you will join us. Until next Saturday, Watch, Learn,
Build! [ Translating these subtitles? Add your name