How to flash, install firmware on your ESP8266-03 with a Mac OSX (windows is similar)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to flash, install firmware on your ESP8266-03 with a Mac OSX (windows is similar)

    Required hardware:
    AMS1117
    USB to TTL Programmer
    Breadboard
    ESP8266 ESP-03

    Software installationOpen a Terminal on Mac and execute this command
    Code:
    sudo nvram boot-args="kext-dev-mode=1"
    and restart your Ðœac.

    Install an esp flasher Esptool software via Mac Terminal with this command:
    Code:
    pip install esptool
    more infos about esptool you can find here: https://github.com/themadinventor/esptool

    (Windows users can use this tool: https://github.com/nodemcu/nodemcu-flasher)

    Download Esplorer from: http://esp8266.ru/esplorer/ or directly http://esp8266.ru/esplorer-latest/?f=ESPlorer.zip
    it requires Java which you can install from https://www.java.com/en/download/ (in case you don't have it).


    Hardware preparation

    Now you need aн ESP8266-03 Module, which looks like this:

    ESP8266-03 with a pinout:


    Use a solderer with a tiny tip to solder wires to the pins of the module.

    Afterwards you esp should look like this:



    Now prepare the ESP826-03 for flashing. Important it requires 3,3 Volt power supply, so don't try to connect it directly to 5 Volts because it will destroy your chip. Many of USB to TTL programmers can provide 3,3 Volt power, so you can connect your ESP8266-02 to the 3,3 Volt pin of your programmer.
    I have used AMS1117 power converter, which converts 4,7 to 12 Volt into 3,3 Volts and connected it to the 5Volt output of my USB to TLL programmer, which looks like this:



    and the AMS1117 looks like this:


    at VIN+ you connect the 5 Volt of your USB to TTL programmer and at GND you connect the Ground pin of USB to TTL programmer,
    VOUT+ provides the required 3,3 Volt to power your ESP8266-03.

    Now lets connect everything on a breadboard and prepare the ESP8266-03 for flashing firmware,
    for flashing firmware you need to connect these pins:
    CONNECT GPIO15 TO GROUND
    CONNECT CH_PD TO HIGH (VOUT+)
    CONNECT GPIO 0 TO GROUND
    RX Programmer to TX ESP8266-03
    TX Programmer to RX ESP8266-03

    Like this:

    and this is how it looks like with breadboard


    Get the firmware

    Now get the latest firmware from here: http://nodemcu-build.com/ (select only the needed firmware modules because your chip has limited space and flashing firmware may fail due to lack of space on the chip, standard modules are selected by default and its recommended to include them in your build) I have selected the dev build with following additional modules: dht, file, gpio, http, mdns, net, node, rtcfifo, rtcmem, rtctime, tmr, uart, wifi.

    After the firmware is ready, download it and place it into your user folder on MAC.

    Flash the firmware

    Now you can connect USB to TTL programmer to usb port of your Mac, open CoolTerm click Options look in the ports for something that looks similar to /dev/cu.wchusbserialfa130, your port name will be same or different, write down the port name which you see in CoolTerm. If you don't see it, make sure that you installed all the drivers and executed
    Code:
    sudo nvram boot-args="kext-dev-mode=1"
    in terminal and restart your MAC.

    Now open the terminal, and execute this commands step by step:

    1. to go to the use folder
    Code:
    cd
    2. before you execute the next command replace the /dev/cu.wchusbserialfa130 with your port name and nodemcu-dev-13-modules-2016-06-26-20-11-56-float.bin with the firmware file name that you have built and downloaded previously.
    Code:
    esptool.py --port=/dev/cu.wchusbserialfa130  write_flash  -fm=dio -fs=32m 0x00000 nodemcu-dev-13-modules-2016-06-26-20-11-56-float.bin
    If you did everything correctly, the firmware will be written into the chip. If you get an error in the terminal output, make sure that your breadboard setup is correct and you are using the correct port.
    Advertise your mobile site for FREE with AdTwirl


    #2
    Start using your flashed chip

    Now when new firmware is flashed, you can start programming it with Esplorer tool (which you have previously downloaded).
    Before you start:
    disconnect USB to TTL programmer from your MAC
    disconnect the GPIO0 from the Ground, so it will look like this:


    connect the USB to TLL back to your Mac.

    Click the ESPlorer.jar file to start the tool, it will take several seconds until its ready to go, (if the tool doesn't open make sure that you have java installed).

    If you don't see your USB to Serial port that looks like /dev/cu.wchusbserialfa130 execute
    Code:
    sudo nvram boot-args="kext-dev-mode=1
    in terminal and restart your Mac.

    When the ESPlorer is ready, select your port and click Open button to connect to your ESP8266-03, you should see an output like this:

    what is good, but this is not what we need.
    Click the close button and open button again, you may have to click close and open button several times until you see the proper output result, sometimes you need to reconnect your USB to TTL programmer and start over connecting with ESPlorer again.
    The output result that we want to have should look like this:
    PORT OPEN 9600

    Communication with MCU...
    Got answer! AutoDetect firmware...
    Communication with MCU established.
    NodeMCU firmware detected.
    =node.heap()
    42624
    >


    Now you can start programming your ESP chip.

    here is an example of init.lua file which connects your ESP8266-03 to wifi network:
    Code:
    --init.lua
    wifi.setmode(wifi.STATION)
    wifi.sta.config("WIFI_Network-XXXX", "Password")
    wifi.sta.connect()
    
    -- Connect
    tmr.alarm(1, 1000, 1, function()
        if wifi.sta.getip()== nil then
            print("IP unavaiable, Waiting...")
        else
            tmr.stop(1)
            print("Connected to wifi")
        end
    end)
    Send GET Request with some data to a remote server
    i.e. you could use this code to send you data from dht11 or dht22 temperature humidity sensor to your server
    init.lua code:
    Code:
    --init.lua
    wifi.setmode(wifi.STATION)
    wifi.sta.config("WIFI_Network-XXXX", "Password")
    wifi.sta.connect()
    
    -- Connect
    tmr.alarm(1, 1000, 1, function()
        if wifi.sta.getip()== nil then
            print("IP unavaiable, Waiting...")
        else
            tmr.stop(1)
            dofile ("main.lua")
        end
    end)
    main.lua code:
    Code:
    -- main.lua --
    sensor = 1
    pin = 4
    
    tmr.alarm(2, 60000, tmr.ALARM_AUTO, function()
    
    status, temp, humi, temp_dec, humi_dec = dht.read11(pin)
    http.get("http://mysite.com/test.php?temp="..temp.."&humi="..humi.."&sensor="..sensor.."", nil, function(code, data)
        if (code < 0) then
          print("HTTP request failed")
        else
          print(code, data)
        end
      end)
    
    end )
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Nice man, I see you are getting your hand real dirty.
      wapZan Mobile site builder - Yours is here



      http://wapzan.com?ref=2wap

      Comment

      Working...
      X