Esp8266 Team Hack Wifi

by querry43 in Circuits > Microcontrollers

2394 Views, 2 Favorites, 0 Comments

Esp8266 Team Hack Wifi

wifi.png

This project is part of a series for an instructables team hack. See the series for more information.

The MicroPython firmware comes with a web-based interface which may be a lot more convenient than any of these serial console programs. There are two ways to get into this.

  1. Connect your esp8266 to your wireless network
  2. Connect to your esp8266's wireless network

I will assume you are already talking to your esp8266 over serial, and you have a home wireless network. Let's go with option 1 and get your microcontroller on the internet.

Connecting to Wifi

ifconfig.png

Type the following into the serial console to connect to your wifi network. It will remember these settings and automatically connect when it starts later. Substitute your wireless network name and password in `wifi.connect`.

import network

wifi = network.WLAN(network.STA_IF)
wifi.active(True)

wifi.connect("network-name", "network-password")

Give it a moment to connect, they run the following. If it worked, it should print `True`. Otherwise, check your network name and password.

wifi.isconnected()

You can also fetch your ip.

wifi.ifconfig()

When I ran this, it printed the following. The first set of numbers is the ip of my esp8266 (10.0.0.15).

('10.0.0.15', '255.255.255.0', '10.0.0.1', '75.75.75.75')

This is great! Now your dev board has internet access.

Talking to Your Esp8266 in a Browser

webrepl.png

For our team hack, the esp8266s are pre-configured to run the webrepl with the password 'letmein'. If you are setting up your own esp8266, follow these instructions

We can now talk to our esp8266 development boards from a browser. Go to the http://micropython.org/webrepl, and connect using your ip. For me, the connect string is `ws://10.0.0.15/8266`. If you are on any sort of VPN, you will need to disconnect before this works.

Once you connect, it may ask for a password (`letmein` if your board was pre-configured). You should then get the same `>>>` python prompt. Go ahead, try hello world again.

You will only need the serial console software if you want to change network settings serial console software anymore.