Voltar ao ranking

SmingHub/Sming

C++sming.readthedocs.io

Sming - powerful open source framework simplifying the creation of embedded C++ applications.

esp8266espressifiotwifiembeddedsmingssl-supportarduinoasyncrbootc-plus-plusinternet-of-things
Crescimento de estrelas
Estrelas
1.6k
Forks
347
Crescimento semanal
Issues
80
5001k1.5k
mar. de 2015dez. de 2018out. de 2022jul. de 2026
README

Sming

Sming is an asynchronous embedded C++ framework with superb performance and multiple network features. Sming is open source, modular and supports multiple architectures including ESP8266, ESP32 and Raspberry Pi Pico (both RP2040 and RP2350).

Examples

Gitter (chat) Backers Sponsors Download Build Codacy Badge Coverity Badge

If you like Sming, give it a star, or fork it and contribute!

GitHub stars GitHub forks

Getting Started

Sming supports multiple architectures and has a plethora of features. Choose the architecture of your choice to install the needed development software.

You can also try Sming without installing anything locally. We have an interactive tutorial that can be run directly from your browser.

Documentation

The purpose of Sming is to simplify the creation of embedded applications. The documentation will help you get started in no time.

Releases

Stable

  • Sming V6.2.0 - great new features, performance and stability improvements.

Development

To follow the latest development you will need to clone our develop branch:

git clone https://github.com/SmingHub/Sming.git

Examples

The examples are a great way to learn the API and brush up your C++ knowledge. Once you have completed the installation of the development tools, you can get the latest source code:

git clone https://github.com/SmingHub/Sming.git

And check some of the examples:

Blinking is something like the "Hello World" example for the embedded world. You can check it using the commands below:

cd Sming/samples
cd Basic_Blink
make # -- compiles the application
make flash # -- tries to upload the application to your ESP8266 device.

More information at Sample Projects page.

Simple GPIO Input/Output

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

For a complete example take a look at the Basic_Blink sample.

Start Serial Communication

Serial.begin(9600);
Serial.println("Hello Sming! Let's do smart things.");

Connect to WiFi

WifiStation.enable(true);
WifiStation.config("LOCAL-NETWORK", "123456789087"); // Put your SSID and password here

Read DHT22 sensor

#include <Libraries/DHTesp/DHTesp.h> // This is just a popular Arduino library!

#define DHT_PIN 0 // GPIO0
DHTesp dht;

void init()
{
  dht.setup(DHT_PIN, DHTesp::DHT22);

  float h = dht.getHumidity();
  float t = dht.getTemperature();
}

Take a look at the code of the Humidity_DHT22 sample.

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

For more examples take a look at the HttpClient, HttpClient_Instapush and HttpClient_ThingSpeak samples.

OTA Application Update

void doUpgrade()
{
  // need a clean object, otherwise if run before and failed will not run again
  if(otaUpdater) {
      delete otaUpdater;
  }
  otaUpdater = new Ota::Network::HttpUpgrader();

  // select rom partition to flash
  auto part = ota.getNextBootPartition();

  // The content located on ROM_0_URL will be stored to the new partition
  otaUpdater->addItem(ROM_0_URL, part);

  // and/or set a callback (called on failure or success without switching requested)
  otaUpdater->setCallback(upgradeCallback);

  // start update
  otaUpdater->start();
}

For a complete example take a look at the Basic_Ota sample.

HTTP Server

server.listen(80);
server.paths.set("/", onIndex);
server.paths.set("/hello", onHello);
server.paths.setDefault(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);
}

For more examples take a look at the HttpServer_ConfigNetwork, HttpServer_Bootstrap, HttpServer_WebSockets and HttpServer_AJAX samples.

Email Client

SmtpClient emailClient;

emailClient.connect(Url("smtp://user:password@domain.com"));

MailMessage* mail = new MailMessage();
mail->from = "developers@sming";
mail->to = "iot-developers@world";
mail->subject = "Greetings from Sming";
mail->setBody("Hello");

FileStream* file= new FileStream("image.png");
mail->addAttachment(file);

emailClient.onMessageSent(onMailSent);
emailClient.send(mail);

...

int onMailSent(SmtpClient& client, int code, char* status)
{
    MailMessage* mail = client.getCurrentMessage();

    ...

    if(!client.countPending()) {
        client.quit();
    }

    return 0;
}

See the SmtpClient sample for details.

Live Debugging

Applications based on Sming Framework that are flashed and running on an ESP8266 device can be debugged using interactive debuggers. In order to debug an application it has to be re-compiled with the ENABLE_GDB=1 directive. And then flashed on the device. As shown below:

cd $SMING_HOME/../samples/LiveDebug
make clean
make ENABLE_GDB=1
make flashapp # <-- this will update only the application firmware.

Once the debuggable application is flashed on the device the developers have to run GDB. The easiest way to run the command-line GDB is to execute the following command:

make gdb

Developers using Eclipse CDT can have debugging sessions like the one below: Debugging Session in Eclipse CDT

See LiveDebug sample for details.

Contribute

You can contribute to Sming by:

  • Providing Pull Requests with new features, bug fixes, new ideas, etc. See Contributing for details.
  • Testing our latest source code and reporting issues.
  • Supporting us financially to acquire hardware for testing and implementing or out of gratitude

Financial contributions

We welcome financial contributions in full transparency on our open collective page. They help us improve the project and the community around it. If you would like to support us you can become a backer or a sponsor.

In addition to that anyone who is helping this project can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.

Backers and sponsors

Thank you to all the people who have backed Sming backer

or sponsored it.

sponsor
Repositórios relacionados
arendst/Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

CGNU General Public License v3.0tasmotafirmware
tasmota.github.io/docs
24.6k5.1k
wled/WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP32 over WiFi!

C++European Union Public License 1.2lightesp8266
kno.wled.ge
18.4k4.3k
Aircoookie/WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!

C++lightesp8266
kno.wled.ge
15.6k3.4k
SpacehuhnTech/esp8266_deauther

Affordable WiFi hacking platform for testing and learning

COtherwifiarduino
deauther.com
14.9k2.8k
justcallmekoko/ESP32Marauder

A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32

C++esp32arduino
11.6k1.4k
esphome/esphome

ESPHome is a system to control your ESP32, ESP8266, BK72xx, RP2040 by simple yet powerful configuration files and control them remotely through Home Automation systems.

C++Otherhome-automationiot
esphome.io
11.4k5.5k
platformio/platformio-core

Your Gateway to Embedded Software Development Excellence :alien:

PythonPyPIApache License 2.0iotembedded
platformio.org
9.4k897
nodemcu/nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

CMIT Licensenodemculua
nodemcu.readthedocs.io
7.9k3.1k
tzapu/WiFiManager

ESP8266 WiFi Connection manager with web captive portal

C++MIT Licenseesp8266configuration-portal
tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
7.2k2.1k
bblanchon/ArduinoJson

📟 JSON library for Arduino and embedded C++. Simple and efficient.

C++MIT Licensearduinoc-plus-plus
arduinojson.org
7.2k1.2k
martin-ger/esp_wifi_repeater

A full functional WiFi NAT Router (and now also a WiFi Repeater)

CMIT Licenseesp8266nat
5.2k981
blinker-iot/blinker-library

An IoT Solution,Blinker library for embedded hardware. Works with Arduino R4, ESP32.

C++MIT Licensearduinoesp8266
diandeng.tech
5.2k236