Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
This branch contains all "tasty" features that are not merged into the official Sming develop branch. For the moment these include:
- Faster interrupts so that there is less flickering. ( PR 774 )
- Fix for loosing final bytes when using rBoot Over-The-Air. ( PR 769 )
- Allow setting the wifi station configuration without persisting it in flash. ( PR 734 )
- Better Heap Allocation. ( PR 696 )
- SSL with the help of AXTLS-8266 ( PR 596)
- MQTT callback on delivering a message with QoS 1 or 2. ( PR 617 )
MQTT: Better memory usage and no limits for username, password and clientid.MergedFix for slow booting.MergedrBoot Makefile switch to enable the switch temp functions.MergedDebug support with the help of ESPGDBStubMergedrBoot with support for temporary switching to a ROM.Merged
- Fast & user friendly development
- Work with GPIO in Arduino style
- High effective in perfomance and memory usage (this is native firmware!)
- Compatible with standard Arduino libraries - use any popular hardware in few lines of code
- rBoot OTA firmware updating
- Built-in file system: spiffs
- Built-in powerfull network and wireless modules
- Built-in JSON library: ArduinoJson
- HTTP, AJAX, WebSockets support
- MQTT protocol based on [libemqtt] (https://github.com/menudoproblema/libemqtt)
- Networking based on LWIP stack
- Simple and powerfull hardware API wrappers
- Based on Espressif NONOS SDK 1.4.0 & 1.5.0
- Spiffy : Source included in Sming repository
- [ESPtool2] (https://github.com/raburton/esptool2) esptool2
You can find more information about compilation and flashing process by reading esp8266.com forum discussion thread.
More information at Wiki Examples page.
#define LED_PIN 2 // GPIO2
...
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
Serial.begin(9600);
Serial.println("Hello Sming! Let's do smart things.");
WifiStation.enable(true);
WifiStation.config("LOCAL-NETWORK", "123456789087"); // Put you SSID and Password here
#include <Libraries/DHT/DHT.h> // This is just popular Arduino library!
#define WORK_PIN 0 // GPIO0
DHT dht(WORK_PIN, DHT22);
void init()
{
dht.begin();
float h = dht.readHumidity();
float t = dht.readTemperature();
}
HttpClient thingSpeak;
...
thingSpeak.downloadString("https://api.thingspeak.com/update?key=XXXXXXX&field1=" + String(sensorValue), onDataSent);
void onDataSent(HttpClient& client, bool successful)
{
if (successful)
Serial.println("Successful!");
else
Serial.println("Failed");
}
void OtaUpdate() {
uint8 slot;
rboot_config bootconf;
Serial.println("Updating...");
// need a clean object, otherwise if run before and failed will not run again
if (otaUpdater) delete otaUpdater;
otaUpdater = new rBootHttpUpdate();
// select rom slot to flash
bootconf = rboot_get_config();
slot = bootconf.current_rom;
if (slot == 0) slot = 1; else slot = 0;
// flash rom to position indicated in the rBoot config rom table
otaUpdater->addItem(bootconf.roms[slot], ROM_0_URL);
// and/or set a callback (called on failure or success without switching requested)
otaUpdater->setCallback(OtaUpdate_CallBack);
// start update
otaUpdater->start();
}
server.listen(80);
server.addPath("/", onIndex);
server.addPath("/hello", onHello);
server.setDefaultHandler(onFile);
Serial.println("=== WEB SERVER STARTED ===");
Serial.println(WifiStation.getIP());
...
void onIndex(HttpRequest &request, HttpResponse &response)
{
TemplateFileStream *tmpl = new TemplateFileStream("index.html");
auto &vars = tmpl->variables();
vars["counter"] = String(counter);
vars["IP"] = WifiStation.getIP().toString();
vars["MAC"] = WifiStation.getMAC();
response.sendTemplate(tmpl);
}
void onFile(HttpRequest &request, HttpResponse &response)
{
String file = request.getPath();
if (file[0] == '/')
file = file.substring(1);
response.setCache(86400, true);
response.sendFile(file);
}