Monday 20 April 2015

ESP8266 Setup

ESP8266.

i'm using ESP-01 Version


Hardware pinout



Normal mode operation

Normal boot from flash, normal working mode
  • VCC- 3.3 ONLY! draws 20mA-250mA
  • GND-..
  • RX- connects to TX of arduino or similar controller
  • TX- connects to RX, ditto above
  • GPIO0/2- general purpose in out
  • RST- reset (LOW = reset active)
  • CH_PD- chip power down i.e. (LOW = power down active)
  • Red LED- power
  • Blue LED- status
Note it has been said that the last 4 pins must be attached to VCC, however Great Scott the youtuber has had success with only the CH_PD attached to VCC.


Firmware

Needed a ttl to usb adaptor very cheap 1-2 pounds- i prefer the cable as its easier to work with. 

Following this tutorial (and for updating the firmware this great Video from Kevin Darrah- check his channel out!) i will update the firmware using a USB - TTL cable, i'm powering the ESP with the arduinos 3.3v and ground although the arduino wont give the max current the ESP will take it will be enough for updating the firmware (just a bit slower). the green TX of the TTL cable goes to the RX of the ESP and the white RX of the TTL to the TX of the ESP.

Flash mode pin config

The other side of the cable im holding is USB and goes to ...the computer.
Im only using the power form the arduino here.
Note the shared ground. 




  • VCC- 3.3 from arduino
  • GND- from arduino also shared with the TTL cable
  • RX- connects to TX of TTL (green)
  • TX- connects to RX of TTL (white)
  • GPIO 0- set LOW
  • GPIO 2- set HIGH
  • GPIO 15- set LOW OR HIGH?! (SDM model)
  • RST- reset HIGH 
  • CH_PD-  HIGH


  • When the ESP is connected up- with power then connect to the computer. Before flashing with the software on the tutorial, make sure that you have updated the driver for the usb cable, goto devices and printers and auto update the driver. Now you should be able to flash the device.

    Follow the video and blog!

    And Then?

    if you have followed the tutorial, and have flashed the chip with new firm ware, we can now test it. Open the arduino IDE and select the com port that your ttl cable is connected to, open the serial monitor and try some commands.

    Some chips are already set to work at 9600 baud rate mine was, if not you might have to try 
    115200 and possibly others. Set auto scroll and "Both NL & CR"

    • AT
      • a simple test it should return "OK"
    • AT+RST
      • resets the board returns "[System Ready, Vendor:www.ai-thinker.com]" could fscanf or read for this line to ensure it has been restarted. (changed from firmware version to version)
    • AT+GMR
      • tells you the firmware its running
    • AT+CWMODE=?
      • tells you what modes it will accept: can be..
      • a device on the network
      • an access point- can log into it setup a password and ssid (completely stand alone device)
      • both
    • AT+CWMODE=1
      • changes mode 1-3
    • AT+CWMODE?
      • current mode
    • AT+CWLAP
      • displays wifi points
    • AT+CWJAP="SSID wifi name","password"  
      • connects to WIFI
    • AT+CWJAP?
      • check to see if connected to WIFI
    • AT+CIPMUX=1
      • setting it to accept multiple connections, required for the tcp connection to the internet.
      • Must always set the every time device is powered down!!!
    • AT+CIPMUX?
      • current mode
    • AT+CIPMODE=0
      • not data mode (= 1 is possible to set data streaming mode)



    And Then?

    So now we can connect to a wifi network and set the ESP to different modes.

    In my next post i'm going to have examples of getting data from the internet using the last two links under useful Reference Material. Here for a video

    Useful Reference Material

    Youtube

    Kevin Darrah- Just go there!
    Great Scott!- Lots of links in the info box (under the video)
    Julian Llett- Alot of interesting videos, lots of iot stuff
    AllAboutEE- Same as above

    Yahoo Query Language-
    Yahoo Query Language tutorial-

    Friday 17 April 2015

    8x8 Led Matrix using Max7219 IC


    The Board

    The Maxim 7219 IC

    Info here

    The Library (LedControl)

    info here

    The Code





    Notes

    Can be daisy chained..

    setup functions

    void setup()
    {
      lc.shutdown(0,false);  // Wake up displays

      lc.setIntensity(0,1);  // Set intensity levels 1-15

      lc.clearDisplay(0);  // Clear Displays
    }

    lighting individual leds

    /* 
     * Set the status of a single Led.
     * Params :
     * addr  address of the display 
     * row   the row of the Led (0..7)
     * col   the column of the Led (0..7)
     * state If true the led is switched on, 
     * if false it is switched off
     */
    void setLed(int addr, int row, int col, boolean state);

    example
    //switch on the led in the 3'rd row 8'th column
    //and remember that indices start at 0! 
    lc.setLed(0,2,7,true);   
    //Led at row 0 second from left too
    lc.setLed(0,0,1,true);   
    delay(500);
    //switch the first Led off (second one stays on)
    lc.setLed(0,2,7,false);



    Control all leds in a row

    The setRow(addr,row,value)-function takes 3 arguments. The first one is the already familiar address of our device. The second one is the row that is going to be updated and the third one the value for this row.

    Here is the signature of the method :

    /* 
     * Set all 8 Led's in a row to a new state
     * Params:
     * addr  address of the display
     * row   row which is to be set (0..7)
     * value each bit set to 1 will light up the corresponding Led.
     */
    void setRow(int addr, int row, byte value);

    example
    //include this file so we can write down a byte in binary encoding
    #include <binary.h>

    //now setting the leds from the third row on the first device is easy
    lc.setRow(0,2,B10110000);

    Ref websites 

    http://playground.arduino.cc/Main/LedControl
    https://brainy-bits.com/tutorials/how-to-control-max7219-led-matrix/