Code Monkey home page Code Monkey logo

sming's Introduction

Sming

Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.

ESP8266 C++ development framework

Join the chat at https://gitter.im/alonewolfx2/Sming Download

Summary

  • 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
  • OTA (cloud) firmware updating
  • Build-in file system: spiffs
  • Build-in powerfull network and wireless modules
  • Build-in great JSON library: ArduinoJson
  • MQTT protocol based on [libemqtt] (https://github.com/menudoproblema/libemqtt)
  • Open source LWIP stack
  • Simple and powerfull hardware API wrappers
  • Based on Espressif SDK v1.0.1b1

Getting started

You can find more information about compilation and flashing process by reading esp8266.com forum discussion thread.

Examples

More information at Wiki Examples page.

Simple GPIO input/output

#define LED_PIN 2 // GPIO2
...
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);

Connect to WiFi and start Serial communication

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

Read DHT22 sensor

#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();
}

HTTP client

HttpClient thingSpeak;
...
thingSpeak.downloadString("http://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");
}

Embedded HTTP WebServer

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);
}

sming's People

Contributors

anakod avatar automationd avatar nik-sharky avatar tavalin avatar alonewolfx2 avatar hreintke avatar danielnilsson9 avatar j0hncc avatar justacatru avatar markusgritsch avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.