I finally wised up and pitched the Arduino IDE idea and started using the LuaLoader. The interface is a little cludgy and old looking but man this thing app works great.
Initial Setup
- Download and install the LuaLoader.
- Fire up LuaLoader.exe
- Plug in your ESP8266
- Click the settings menu in LuaLoader. You should see Open COMX on the setup menu. The LuaLoader automatically knows which COM port you are using.
- You should see a Connected Response and the COM section on the Top right should be green.
- In the Orange section you will see a spot for your wifi details...plug in your WIFI information
- Click the Get IP button
- BOOM, you have an IP.
Lua Script
You are now ready to start your quest to learn the .lua language. Below is a sample script. This script will start up a web server on the ESP8266 and will present some HTML. The web page will allow you to interact with an LED. Each 10s button will increase the intensity of the LED. If you click OFF it will turn the LED OFF, if you click ON it will turn the LED on 100%. If you click BLINK it will blink the LED on and off.
You will also notice that we read the GPIO Pin to determine if the LED is on or off. This will come in handy as we start to incorporate some other sensors. We can start adding Relays, Temperature sensors, Motion detectors, etc.
- Connect an LED to a Ground Pin and the D1 Pin on your ESP8266
- Open your favorite text editor
- Paste this code into your text editor
- Modify the code as needed. You will notice I am using port 85, you can use whatever port you want. Also I am loading an image from my web server. You can change that to whatever you want as well.
- Save your script with the name init.lua.
- Open up the LuaLoader interface again
- Click the Upload File Button on the right side
- Browse to your init.lua file and click open
- LuaLoader will upload your file.
- Once the upload is complete click Dofile.
- Hit the IP address with the Port you specified in a web browser.
- You should be able to control your LED using the web page.
So if you call the lua file init.lua, the ESP8266 will load this file on boot. This is cool because now you can find an external power source (I've been using a spare ChromeCast power brick, anything 3.3V to 5V should work) and the ESP8266 will load your program on boot. Meaning you can plug this thing in anywhere it can hit WiFi and you can start interacting with it via the web.
0 comments:
Post a Comment