From charlesreid1

Arduino/Morse Code Libraries

Arduino Plus Wifi

I bought a couple of 8-pin Wifi cards to connect with an Arduino board to add wifi to some Arduino projects. We'll see how that goes. Here's a photo of one of the chips:

ArduinoWifi.jpg

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

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.

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

To interface with the wifi chip via an Arduino, a Raspberry Pi, or a computer, you can use a serial connection.

The serial connection consists of four pins:

  • Ground pin
  • Voltage pin
  • RX pin
  • TX pin

The RX of device 1 is hooked up to the TX of device 2, and vice-versa.

Useful 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.

USB-to-Serial TTL converter:

  • 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)


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?

Useful Links

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

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/

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

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.?

Morse Code Generator

This project involves using the building blocks covered above - an LCD scren, the Arduinomorse library, and a piezoelectric speaker - to create a morse code generator with an Arduino Micro.

Arduino Morse Code Generator

More Projects

List from Adafruit

https://learn.adafruit.com/series/learn-arduino

RFDuino

https://www.sparkfun.com/products/13209

http://www.rfduino.com/shop/index.html

Flags