From charlesreid1

No edit summary
Line 5: Line 5:
[[Image:ArduinoWifi.jpg|300px]]
[[Image:ArduinoWifi.jpg|300px]]


==ESP8266 Chip==
=ESP8266 Chip=


This is an ESP8266 chip, which is a serial-over-wifi chip. More information about this product: http://www.vetco.net/catalog/product_info.php?products_id=16958
The ESP8266 chip is a serial-over-wifi chip. (Whatever that means.)
 
Documentation for this product: http://www.vetco.net/catalog/product_info.php?products_id=16958
 
More information on projects and interfacing with it: http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module
 
Manufacturer Expressif provides a nice set of pages with information/discussion/project ideas: http://bbs.espressif.com/


These are actually pretty nifty chips, much more nifty than I originally thought: you can hook up a GPIO to the chip, and have it act as a standalone chip running an application on its own.
These are actually pretty nifty chips, much more nifty than I originally thought: you can hook up a GPIO to the chip, and have it act as a standalone chip running an application on its own.
Line 19: Line 13:
From their page: "Our ESP8266 Wifi Module is a low-cost and easy-to-use alternative to expensive wifi shields. This module is built around a powerful onboard microprocessor that features a built-in TCP/IP stack which handles all of the heavy lifting - leaving your Arduino free to communicate using simple serial and AT commands."
From their page: "Our ESP8266 Wifi Module is a low-cost and easy-to-use alternative to expensive wifi shields. This module is built around a powerful onboard microprocessor that features a built-in TCP/IP stack which handles all of the heavy lifting - leaving your Arduino free to communicate using simple serial and AT commands."


==Serial Interface to Wifi Chip==
==Serial Interface==


To interface with the wifi chip via an Arduino, a Raspberry Pi, or a computer, you can use a serial connection.
This chip has 8 pins on the board. They are not labeled clearly. To interface with this chip (from an Arduino or a Raspberry Pi or a computer), you can use a serial connection.


The serial connection consists of four pins:
A serial connection typically consists of four pins:  
* Ground pin
* VIN: voltage in (3.3 V or 5 V)
* Voltage pin
* GND: ground pin
* RX pin
* RX: receive channel
* TX pin
* TX: transmit channel


The RX of device 1 is hooked up to the TX of device 2, and vice-versa.
Note that the receive and transmit pins are crossed when connecting two devices.


===Useful Hardware===
==Serial Hardware==


You will need some hardware to talk to the wifi chip to program it. Specifically, you need a converter to turn 5V logic signals into 3.3V logic signals. You also need a separate power source for the wireless chip to ensure it can draw the full 300 mA it requires.  
You will need some hardware to talk to the wifi chip to program it. A serial interface capable of generating 3.3 V logic signals is necessary. A separate power source for this wireless chip is also critical to ensure that the chip can draw the full 300 mA it requires.  


USB-to-Serial TTL converter:
One nice advantage of a USB-to-RS-232 serial interface is that the power source comes from another device. WHile you can only interface with this wifi chip via a computer, this is kind of the point of serial.
* good for debugging via serial, doing one-off tasks via a computer
* advantages: separate power supply
* disadvantages: you can only interface with the wifi chip via the computer (but, uh, that's kind of the point of serial)


<!--
<!--
Line 47: Line 38:
-->
-->


next up, we figure out how we control this thing directly from an Arduino - do you still try and send serial signals to the thing?
=Linkz=
 
==Documentation==
 
Documentation for this product from manufacturer: http://www.vetco.net/catalog/product_info.php?products_id=16958
 
Information about interfacing with the chip via serial: http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module


===Useful Links===
Manufacturer Expressif provides a nice set of pages with info and project ideas: http://bbs.espressif.com/


bi-directional logic converter: 3.3V to 5V (very cheap): https://www.sparkfun.com/products/12009
github library: https://github.com/willdurand/EspWiFi/blob/master/EspWiFi.h
 
esp8266 wiki: http://www.esp8266.com/wiki/doku.php?id=getting-started-with-the-esp8266
 
==Hardware==
 
Bi-directional logic converter: 3.3V to 5V (very cheap): https://www.sparkfun.com/products/12009


3.3V to 5V analog how-to, guide, tips and tricks: http://www.newark.com/pdfs/techarticles/microchip/3_3vto5vAnalogTipsnTricksBrchr.pdf
3.3V to 5V analog how-to, guide, tips and tricks: http://www.newark.com/pdfs/techarticles/microchip/3_3vto5vAnalogTipsnTricksBrchr.pdf
Line 62: Line 65:


another version with more pins: http://reflowster.com/blog/2015/05/11/esp8266.html
another version with more pins: http://reflowster.com/blog/2015/05/11/esp8266.html
github library: https://github.com/willdurand/EspWiFi/blob/master/EspWiFi.h


almost exactly the same hardware, using a serial-to-TTL converter: http://williamdurand.fr/2015/03/17/playing-with-a-esp8266-wifi-module/
almost exactly the same hardware, using a serial-to-TTL converter: http://williamdurand.fr/2015/03/17/playing-with-a-esp8266-wifi-module/


esp8266 wiki: http://www.esp8266.com/wiki/doku.php?id=getting-started-with-the-esp8266
==Useful Code==
 
===Useful Code===


This page [http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module] works by connecting an output signal from the Arduino to a USB-TTL serial converter chip. This signal is then sent back to the Arduino. The signal is (presumably) routed around to the Arudino's TX pin, and the Arduino's TX pin is hooked up to the Wifi chip's RX pin. Similarly, the Arduino's RX pin is hooked up to the Wifi chip's TX pin. This way, serial signals are routed through the USB-TTL converter.
This page [http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module] works by connecting an output signal from the Arduino to a USB-TTL serial converter chip. This signal is then sent back to the Arduino. The signal is (presumably) routed around to the Arudino's TX pin, and the Arduino's TX pin is hooked up to the Wifi chip's RX pin. Similarly, the Arduino's RX pin is hooked up to the Wifi chip's TX pin. This way, serial signals are routed through the USB-TTL converter.

Revision as of 07:43, 22 June 2016

Arduino Plus Wifi

I bought a couple of 8-pin wifi boards (ESP8266) to connect with an Arduino board to add wifi to some Arduino projects. Here's a photo of one of the chips:

ArduinoWifi.jpg

ESP8266 Chip

The ESP8266 chip is a serial-over-wifi chip. (Whatever that means.)

These are actually pretty nifty chips, much more nifty than I originally thought: you can hook up a GPIO to the chip, and have it act as a standalone chip running an application on its own.

From their page: "Our ESP8266 Wifi Module is a low-cost and easy-to-use alternative to expensive wifi shields. This module is built around a powerful onboard microprocessor that features a built-in TCP/IP stack which handles all of the heavy lifting - leaving your Arduino free to communicate using simple serial and AT commands."

Serial Interface

This chip has 8 pins on the board. They are not labeled clearly. To interface with this chip (from an Arduino or a Raspberry Pi or a computer), you can use a serial connection.

A serial connection typically consists of four pins:

  • VIN: voltage in (3.3 V or 5 V)
  • GND: ground pin
  • RX: receive channel
  • TX: transmit channel

Note that the receive and transmit pins are crossed when connecting two devices.

Serial Hardware

You will need some hardware to talk to the wifi chip to program it. A serial interface capable of generating 3.3 V logic signals is necessary. A separate power source for this wireless chip is also critical to ensure that the chip can draw the full 300 mA it requires.

One nice advantage of a USB-to-RS-232 serial interface is that the power source comes from another device. WHile you can only interface with this wifi chip via a computer, this is kind of the point of serial.


Linkz

Documentation

Documentation for this product from manufacturer: http://www.vetco.net/catalog/product_info.php?products_id=16958

Information about interfacing with the chip via serial: http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module

Manufacturer Expressif provides a nice set of pages with info and project ideas: http://bbs.espressif.com/

github library: https://github.com/willdurand/EspWiFi/blob/master/EspWiFi.h

esp8266 wiki: http://www.esp8266.com/wiki/doku.php?id=getting-started-with-the-esp8266

Hardware

Bi-directional logic converter: 3.3V to 5V (very cheap): https://www.sparkfun.com/products/12009

3.3V to 5V analog how-to, guide, tips and tricks: http://www.newark.com/pdfs/techarticles/microchip/3_3vto5vAnalogTipsnTricksBrchr.pdf

usb-to-serial TTL usb converter hardware: https://www.adafruit.com/products/954

usb-to-serial TTL usb converter guide: http://villagescience.org/running-raspberry-pi-usb-serial-ttl-adapter/

sparkfun version of the esp8266 (more pins?): https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/hardware-overview

another version with more pins: http://reflowster.com/blog/2015/05/11/esp8266.html

almost exactly the same hardware, using a serial-to-TTL converter: http://williamdurand.fr/2015/03/17/playing-with-a-esp8266-wifi-module/

Useful Code

This page [1] works by connecting an output signal from the Arduino to a USB-TTL serial converter chip. This signal is then sent back to the Arduino. The signal is (presumably) routed around to the Arudino's TX pin, and the Arduino's TX pin is hooked up to the Wifi chip's RX pin. Similarly, the Arduino's RX pin is hooked up to the Wifi chip's TX pin. This way, serial signals are routed through the USB-TTL converter.

   #include <SoftwareSerial.h>
   #define SSID "xxxxxxxx"
   #define PASS "xxxxxxxx"
   #define DST_IP "220.181.111.85" //baidu.com
   SoftwareSerial dbgSerial(10, 11); // RX, TX


   void setup()
   {
     // Open serial communications and wait for port to open:
     Serial.begin(57600);
     Serial.setTimeout(5000);
     dbgSerial.begin(9600); //can't be faster than 19200 for softserial
     dbgSerial.println("ESP8266 Demo");
     //test if the module is ready
     Serial.println("AT+RST");
     delay(1000);
     if(Serial.find("ready"))
     {
       dbgSerial.println("Module is ready");
     }
     else
     {
       dbgSerial.println("Module have no response.");
       while(1);
     }
     delay(1000);
     //connect to the wifi
     boolean connected=false;
     for(int i=0;i<5;i++)
     {
       if(connectWiFi())
       {
         connected = true;
         break;
       }
     }
     if (!connected){while(1);}
     delay(5000);
     //print the ip addr
     /*Serial.println("AT+CIFSR");
     dbgSerial.println("ip address:");
     while (Serial.available())
     dbgSerial.write(Serial.read());*/
     //set the single connection mode
     Serial.println("AT+CIPMUX=0");
   }


   void loop()
   {
     String cmd = "AT+CIPSTART=\"TCP\",\"";
     cmd += DST_IP;
     cmd += "\",80";
     Serial.println(cmd);
     dbgSerial.println(cmd);
     if(Serial.find("Error")) return;
     cmd = "GET / HTTP/1.0\r\n\r\n";
     Serial.print("AT+CIPSEND=");
     Serial.println(cmd.length());
     if(Serial.find(">"))
     {
       dbgSerial.print(">");
       }else
       {
         Serial.println("AT+CIPCLOSE");
         dbgSerial.println("connect timeout");
         delay(1000);
         return;
       }
       Serial.print(cmd);
       delay(2000);
       //Serial.find("+IPD");
       while (Serial.available())
       {
         char c = Serial.read();
         dbgSerial.write(c);
         if(c=='\r') dbgSerial.print('\n');
       }
       dbgSerial.println("====");
       delay(1000);
     }
     boolean connectWiFi()
     {
       Serial.println("AT+CWMODE=1");
       String cmd="AT+CWJAP=\"";
       cmd+=SSID;
       cmd+="\",\"";
       cmd+=PASS;
       cmd+="\"";
       dbgSerial.println(cmd);
       Serial.println(cmd);
       delay(2000);
       if(Serial.find("OK"))
       {
         dbgSerial.println("OK, Connected to WiFi.");
         return true;
         }else
         {
           dbgSerial.println("Can not connect to the WiFi.");
           return false;
         }
       }

Arduino Wifi Project

Project is to hook up a tiny LCD to the tiny wifi chip and make a tiny wifi monitor.

Add this to the Defcon badge, which should have a microchip that is programmable via serial as well, and could be wired up to control the LCD and tiny wifi chip.

Or, just hook it up to the battery or source of power, and have it standalone, running by itself.

Inspiration: http://www.seeedstudio.com/wiki/WiFi_Serial_Transceiver_Module

LCD Hardware:

USB-Serial Converter:

Once you have all those pieces, this page becomes much more useful, and tells you what serial commands to actually run:

What about the final - logic control from Arduino, USB adapter from 5 V to 3.3 V level, etc.?

Flags