PWM - how-to? With ESP8266, need some tips, please.

(ESP8266) Love mongooseOS, got everything running, LED blinking, I2C devices running, MQTT mqtt-ing like crazy and OTA editing of files!

Except ... PWM. I found one mention somewhere seeming to show how to do it (see below).

I can do everything described in that short how-to except the:
"add line "mgos_pwmset" to the list of exported symbols"

Where would that be? I am not very familiar with C++, more a C# guy.

The usage (once activated) should be:
let PWM = { set: ffi('int mgos_pwmset(int, int, int)') };
Is that correct?

Some info I found here:

PWM is only available on esp8266 currently.
If you want to use it, do checkout mongoose-os repo
cd to fw/examples/mjs_base
add line "mgos_pwm_set" to the list of exported symbols <<< Where would I do that???
type "mos build --arch esp8266"
type "mos flash"
Now you can use PWM from JS: let PWM = { set: ffi('int mgos_pwmset(int, int, int)') };


  • bump! this is a very pertinent question... someone please clarify!

  • SergeySergey Dublin, Ireland

    we'll add pwm api soon, eta - week after next

  • JohnCzJohnCz Canada

    Thanks, Sergey! :)
    Then I can get rid of LUA and use MOS for my Wifi HVAC flap project, V 2.0.
    While the current LUA solution works, the LUA limitations bug me quite a bit.
    V 2.0 with MOS and bi-directional MQTT data exchange and easy to change Wifi password thanks to MOS will be significantly better.

  • SergeySergey Dublin, Ireland

    could you elaborate on the lua limitations please?

  • JohnCzJohnCz Canada

    The nodeMCU LUA is nice to get one's feet wet, but limitations compared to MOS are:

    1. Timer, very complicated to have a larger program running or use larger than a few lines web pages served w/o having to deal with the timer issues or have the ESP8266 panic and reboot. Made me put all the HVAC selection HTML onto an external (NanoPi2 Fire) web server, which does other nefarious things too. I know there are some tricks to circumvent that issue, but too much hassle.

    2. No built in OTA FW or file update. (Big one!) It is kind of possible, to a degree, but very cumbersome in the execution, thus I'd say not really feasible with LUA/nodeMCU

    Admittedly, compared to using the Arduino IDE with ESP8266 support approach I used first, the one good thing with nodeMCU LUA is when using the free ESplorer (Java software), one can "relatively" easy and quickly test programs, by just editing them and then uploading them, a little bit like MOS.

    But again, not easily possibly via OTA, a killer feature of MOS.

    MOS will give me the best of both worlds in this respect. Easy to update OTA, in any respect, no more timer woes, MQTT built in, very easy to program, perfect!

  • SergeySergey Dublin, Ireland

    @JohnCz , thanks for the elaborate answer, appreciated

Sign In or Register to comment.