Initial support for ESP8266 // Issue #119

This commit is contained in:
Valeriy Koval
2015-04-02 20:24:22 +03:00
parent f072a10e9a
commit 6594601932
16 changed files with 893 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
How to build PlatformIO based project
=====================================
1. `Install PlatformIO <http://docs.platformio.org/en/latest/installation.html>`_
2. Download `source code with examples <https://github.com/platformio/platformio/archive/develop.zip>`_
3. Extract ZIP archive
4. Run these commands:
.. code-block:: bash
# Change directory to example
> cd platformio-develop/examples/espressif/esp8266-webserver
# Process example project
> platformio run
# Upload firmware
> platformio run --target upload
# Clean build files
> platformio run --target clean

View File

@@ -0,0 +1,23 @@
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload
[env:esp01_8266]
platform = espressif
framework = arduino
board = esp01

View File

@@ -0,0 +1,54 @@
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
const char* ssid = "*****";
const char* password = "*****";
ESP8266WebServer server(80);
const int led = 13;
void handle_root() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from esp8266!");
delay(100);
digitalWrite(led, 0);
}
void setup(void)
{
Serial.begin(115200);
pinMode(led, OUTPUT);
digitalWrite(led, 0);
// Connect to WiFi network
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handle_root);
server.on("/inline", [](){
server.send(200, "text/plain", "this works as well");
});
server.begin();
Serial.println("HTTP server started");
}
void loop(void)
{
server.handleClient();
}