Software apps and online services
In this tutorial I show you how to add WiFi control to your project in an easy way.
I will use the NodeMCU ESP8266 but the process for other devices is the same.
- ESP8266 library
First of all you need the ESP library, you can install it on your Arduino IDE in this way.
Copy this link in File/Preferences/Additional Board URL:
Now you can install the necessary board library:
After that you can choose NodeMCU or other board with ESP8266.
If you did everything right you should see these new boards:
- Blynk library
For the WiFi connection I will use Blynk.
This amazing application provides the necessary tools to create your own app which can communicate with NodeMCU, Arduino...
This is the official web site with other tutorials and a lot of examples:
After this short introduction on the app you need the Blynk library for Arduino IDE:
Download the zip file which contains the library from:
After that you can copy the zip file into you sketchbook folder and you should see this new library:
If there are some problems try to use "add.ZIP library".
- Blynk app
After the installation of Blynk app on your smartphone you can create a new project.
The app send you a code called "Auth Token" which is used to identify your custom application from Blynk server and you will use it into the sketch.
Now we have got all instruments to create the first simple project.Now I will create a simple LED control to try the app.
First one click on new project and select the board and the connection type:
In the app we use a button connected to D0 of NodeMCU like this:
Now we need the code for NodeMCU.
On Arduino IDE file/Examples/Blynk/Boards_WiFi/NodeMCU
This is the base sketch for all applications, here we can see three important rows:
// You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth = "YourAuthToken"; //1 // Your WiFi credentials. // Set password to "" for open networks. char ssid = "YourNetworkName"; //2 char pass = "YourPassword"; //3
The first is the auth Token: the code received on email.
The second and the third are your WiFi credentials which allows NodeMCU to connect to your WiFi.
Now you can choose the correct board in my case NodeMCU 1.0 and upload the code.
After that you can run the application and you should see the LED on NodeMCU which turns on and off following the state of the button.