-->
Page 1 of 2

Different ways to program ESP8266

PostPosted: Thu Sep 01, 2016 11:18 am
by Singman
Hi,
I'm new to ESP programs and I'm totally lost.
I dont want to use LUA but C instead. I found many PDF or documentation about ESP but it's really hard to understand the environnement .
I've tried Arduino IDE with ESP installed, but I dont like how that IDE want to organize projects with multiple source files (maybe do you have a good llink about that ?)
So I've switched to minGW + tools and everything is working fine.

But then, I'm totally puzzled about documentation and different ways to program ESP. Some docs are using functions like pinMode(), digitalWrite(). Other include files like ESP8266WiFi.h to connect to Wifi via a single call to WiFi.begin(), while I'm using a lots of code lines with wifi_set_opmode(), wifi_station_set_config()....

I understand ESP could work with two different OS (non OS and RTOS), but I've certainly missed a good documentation that explain the difference between the two, how to set up a dev plateform for each and where I could find API documentation about both (I already have "2c-esp8266_non_os_sdk_api_reference_en.pdf" and "20b-esp8266_rtos_sdk_api_reference_v1.4.0_0.pdf").

Thanks.

Re: Different ways to program ESP8266

PostPosted: Mon Sep 05, 2016 6:22 am
by Singman
Ok, it's clearer now after some research.
If you are using the Arduino IDE to program your ESP8266, you can choose 2 modes to write programs :
    use the pure Arduino with some minor diffs like the include (ESP8266Wifi.h instead of Wifi.h) and you will use the typical setup() and loop() structure
    use the native ESP8266 includes and functions (include like "etc_sys.h" and functions like wifi_set_opmode()) and gain a different program structure to use timer and avoid blocking function (related to RTOS ?). But doing that inside Arduino IDE is not easy (need to move include files, etc...

I still have some questions about non-OS and RTOS programming (like using Arduino IDE only lead to non-OS ? Using native only to RTOS ?). If someone could explain, thanks.

Re: Different ways to program ESP8266

PostPosted: Thu Oct 27, 2016 5:18 pm
by EngKeera
I am completely new to the ESP too, but as far as I can understand:

--RTOS uses an OS in which you can use the API functions (built in functions) of the ESP to get things like WiFi and UART working with minimal effort.
--Non-OS is what it sounds like; no OS. The chip runs as if it is a simple microcontroller and to use things like WiFi would be much more complex.

Anyone with more experience on this, please correct me as I myself barely know what I am doing :D :lol:

Re: Different ways to program ESP8266

PostPosted: Fri Oct 28, 2016 2:08 am
by piersfinlayson
EngKeera wrote:I am completely new to the ESP too, but as far as I can understand:

--RTOS uses an OS in which you can use the API functions (built in functions) of the ESP to get things like WiFi and UART working with minimal effort.
--Non-OS is what it sounds like; no OS. The chip runs as if it is a simple microcontroller and to use things like WiFi would be much more complex.

Anyone with more experience on this, please correct me as I myself barely know what I am doing :D :lol:


I've not used the RTOS but the non-OS SDK is not really that complicated to get working. The trick is to realise You essentially schedule everything off of either:
- a timer (so if you want to do something repeatedly, or at some point after something else happens)
- a callback (for example, you can register a callback to be called when IP packets are received, or when the wifi state changes)
- an interrupt (GPIO state change, etc).

My view is that the Arduino approach is the easiest to get going with (assuming you want to use C/C++ - there's other options for stuff like Basic, LUA, Python, ...). However, using one of the SDKs (RTOS or non-OS) gives you far more low-level control over what you're doing. For many, the Arduino environment abstracting that away is useful though.

I you intend to go SDK at some point, Arduino is still a nice easy way to start understanding the platform better.