The purpose of this project is to demonstrate a simple way to scan networks, select and connect to any of them.
We will use the ESP8266 to perform the scan, buttons to select and apply the connection and a display to show the wifi networks found.
The CodeLet's assume that we already know how to connect ESP to a display and focus only on the implementation.
The code is purposefully simple and should/can be improved by anyone who wants to go deeper into the implementation.
The libraries used were LiquidCrystal_I2C and Wire, for the integration of ESP with Display and ESP8266WiFi, responsible for the wifi connection.
The code has three main methods:
- initializescreen
It will scan and display all nearby networks found. An important note, our display has only three lines, so we have to work with logic to display only 3 networks at a time. Because of this, we use an auxiliary array that will receive 3 networks to be displayed.
- clickButtonDown
This method will go through the array with the found networks. Note that there is a variable called currentIndex, it will tell you which is the current network where the course is pointing.
As our display only works with 3 networks, we have to go through the array and break it into 3 parts at a time, for that when the cursor is a value multiple of 3 the display is updated with the next 3 networks and so on.
When the cursor has the same value as the total number of nets found, the reading returns to the first position.
- clickButtonOk
This method will connect the ESP to the desired network. On the first click, the network where the course points will be selected and the display will show the name and request the password to access the network. For this project I didn't have an external keyboard to enter the password, so I had to enter the hard code password.
Feel free to add this improvement to the project.
After entering the password, click the button again and wait for the connection. If all goes well, the connection will take place and the IP will be informed.
Result
Comments
Please log in or sign up to comment.