Connecting Arduino WiFi Shield on Mac for the first time

This gets data that is generated from an Arduino board, sent over WiFi to a receiving program – in this case a Python script.  Nothing fancy. 

Step 1: configure the shield as a serial port server

Plug the shield onto the Arduino, and power them up (with USB for example).

Press the “key” button on the ESP-13, for at least one second to make sure it goes back to default mode. It takes a few seconds to “come to life” in the default state.

Make sure the two DIP switches are OFF at this stage – this keeps the Arduino from talking to the shield – necessary for programming the Arduino.

On the computer or phone, turn on WiFi and select DoitWiFi_Config. Make sure DHCP is enabled, so the computer will be given an IP address by the ESP-13.  Once connected go to in a browser – this is the default address of the shield.

In the resulting configuration page:

  • change the AP name to DoitWiFi_Ser2Net
  • Leave encryption OPEN (for now)
  • Press Submit (green) button at the bottom of the page

Step 2: write a short Arduino program to send data over the serial link.

Here is a sample program that prints a sequence of numbers – one per second:

int ii;
void setup()

void loop()
  Serial.print("packet # ");
  Serial.println(" - hello ESP8266 WiFi");   //output the serial data

Step 3: upload the program to the Arduino.

The DIP switches must be off, otherwise the upload to the Arduino board will not succeed.

Step 4: make a program that can “receive” data.

The following Python program works on a Mac. Enter the text into a file called (created in Brackets for example).

import socket
import sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('', 9000)
print >>sys.stderr, 'connecting to %s port %s'% server_address
print >>sys.stderr, 'Connection made!'
 while 1:
  data = sock.recv(16)
  print >>sys.stderr, '%s' % data,
  print >>sys.stderr, 'closing socket'

Note that the server address ( and port (9000) are the default parameters that were set in step 1 (they are the default values).

Step 5: connect the computer’s WiFi to the shield

Find the DoitWiFi_Ser2Net wireless access point, and connect the computer to it. For this to work, DHCP must be enabled – this will ensure that the computer gets given a wireless address by the device that it will be able to talk to.

The IP address must be something like

Step 6: connect the Arduino serial port to the WiFi shield

Set the two DIP switches to “ON” so the Arduino will send serial data to the ESP-13 – at this point do not try to upload programs to the Arduino, but the USB can still be used for powering the board.

Step 7: start the Python program to capture the output from the shield

At the command line in the Terminal, run the above Python program by typing


The following output will show in Terminal (stop it by typing Ctrl-C):

connecting to port 9000
Connection made!
packet # 467 - hello ESP8266 WiFi
packet # 468 - hello ESP8266 WiFi
packet # 469 - hello ESP8266 WiFi
packet # 470 - hello ESP8266 WiFi

Packets are received by the computer every second, sent with the current value of the counter running on the Arduino board.

Excellent original content here:


Leave a Reply