The first thing you need to do (unless you are installing into an existing environment) is to download ind and install the latest raspbian OS on the SD card. If it is a new installation, you need to extend the file system and use raspi config to set the locale / time zone / keyboard. For more information on how to do this, see here.
When finished, open the terminal and enter the following command-
sudo apt-get update
sudo apt-get dist-upgrade
Sudo apt get install build essential srecord Unrar free Autoconf automake libtool bin GCC G GPERF flex bison texinfo gawk ncurses dev libexpat dev python python serial sed Git
After that, you have successfully set up the operating system and the necessary prerequisites.
Step 2: Step 2: get and build the ESP open SDK
The next step is to download and install the SDK source. To do this, enter the following terminal command-
sudo git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
Here we can edit the makefile and select the SDK version of our supplier. (at the time of writing this article, the current version is 1.5.2). If you have any questions, please leave. After completion, return to the terminal and enter-
The build takes about 2 hours, so this is a good time to get the build
Step 3: set path
ESP open SDK is now installed. In order to use it, the file must be in your path. To do this, you can edit the file / home / pi /. Profile in the editor (photo), or open the terminal and enter the following command-
You can now log off (or restart) and cross compile
Step 4: test the compiler
Now that we have installed the tool chain, his next step is to test it. (note that this is optional, but highly recommended. First, let's download the code example. Open a terminal and enter the command-
Now, in your favorite text editor, open makefile for the 'blinky' project at / sourcecode examples / blinky / Makefile, and-
Change the xtensa_tools_root variable to / opt / ESP open SDK / xtensa-lx106 - elf / bin
Change the sdk_base variable to / opt / ESP open SDK / SDK
Now save the makefile, then return to the terminal and execute-
CD source code example / flashing
If everything goes well, make should work normally. If there is a problem-
Check your path (echo $path) to make sure it can be compiled by the compiler
Check the makefile of blink to verify that the path of the tool and SDK is correct
Now you can refresh the sample to the ESP module. This varies from module to module, but usually you will-
When connecting the ESP module to the serial adapter, be careful to supply only 3.3vdc to the esp8266 V pin (some serial adapters have a separate 3.3V pin and others have jumpers, see the photo for these two examples)
Start ESP with gpio0 pin grounded
Now plug the UART adapter into your raspi USB port from the 'blinky' project terminal
Enter the command sudo make flash
If successful, you should see the firmware pushed at the command prompt. You can test the program by connecting a red LED and 1K resistor in series between gpio2 and the ground, as shown below. When booting esp8266, the LED should flash.
Step 5: additional tools: Eclipse IDE and espexplorer
Now that you have a tool chain to develop your own esp8266 firmware, the next thing you need is the IDE. I recommend eclipse. Installation is easy. Just open a command prompt and type-
sudo apt-get install eclipse-cdt
This will take some time to download and install. But in the end, you will get one of the most useful and powerful ides available anywhere!
For Lua development on esp8266, another tool you need is espexplorer. The only requirement is Java (Java will be installed by default anyway). To install esplorer-
Download the espexplorer.zip package (Blue Download button) from the home page and place the files in the home directory on the terminal
In the terminal, execute the following commands
sudo mv ESPlorer/opt/
sudo chown -R pipi/opt/ESPlorer
That's it! To run espexplorer, just open a terminal and run it-
To connect to the esp8266 using nodemcu, simply insert it, select your serial speed (selected at compile time), and then click the connect button. You should see the Lua prompt and possibly file system or heap data, depending on your firmware. (see Figure)
You can use espexplorer to upload Lua scripts and run commands interactively on esp8266. Here is a very good article on using espexplorer, Lua and esp8266.
Step 6: reward: launch your own nodemcu firmware!
Note - this is a more advanced example, assuming you know something about esp8266, nodemcu, Lua and espexplorer. In short, if you don't know what this is, you may not need it.; -)
One neat thing about esp8266 is the existence of the nodemcu firmware project. This is the open source firmware of esp8266, which allows people to write explanatory code in Lua language and then upload it to esp8266 using the espexplorer application we set up in the previous step. You may already be familiar with it. Most people download and flash their precompiled version into their ESP module. (reasons for this include getting the latest updates and bug fixes and / or increasing stability and reducing memory usage by including only the modules we actually want to use.)
First, we get the source code. Open the terminal and enter the following command-
sudo git clone https://github.com/nodemcu/nodemcu -firmware.git
Clown-r PI: pi / opt / nodemcu firmware
Before building the firmware, you need to configure the settings.
Edit the file / opt / nodemcu firmware / APP / include / user_config. H to set the default serial baud rate by setting bit_rate_default (the default is bit_rate_115200). (if the flash size of the module is not automatically detected during the refresh process, you can also set the flash size of the module here.)
Edit the file / opt / nodemcu firmware / APP / include / user_modules. H to select the modules to include. Enable only the features you need. Selecting too much may destabilize your system.
Once you have edited the configuration, you can enter the command from the / opt / nodemcu firmware directory-
The blinking is exactly the same as the blinking example, except hook the UART adapter and start the esp8266 with gpio0 ground, and then execute-
Making flash memory
The successful flash memory is shown in the figure above. Once you refresh the module, you need to test it. The easiest way is to connect to it through espexplorer and throw some test commands to the Lua interpreter. Here are some good Lua examples.
If you have completed all these steps, now configure raspberry Pi as a budget development environment to create an application for esp8266.
Bao’an District Shenzhen City, China
+86 189 3806 5764