Some time ago I tested Mongoose OS, early days and I had a lot of difficulties. This blog is a partial re-write because I see no reason to leave information lying around that is well out of date – there is a lot of that on the web already – and the current setup is MUCH easier to use than before. I have to tell you that the version changed as I was writing this so make sure you have the latest mos.exe
So – Mongoose – on a Windows 10 PC at least (they support other operating systems but I only have the one), you go to their site and download a program called MOS.EXE. I put it on my desktop. It wants a folder for its stuff so I made one on the desktop called “mos”. You may choose to do things differently. I put the actual MOS.EXE program into my c:\windows folder. The docs suggest that somewhere.
So assuming you have an ESP8266 in an FTDI of some sort, or, depending on the board simply plugged into a USB lead, ready to program up – in my tests I used a bog-standard ESP-12 – I do not recommend even considering the earlier boards such as ESP-01 with limited FLASH (512K) – just too restrictive and anyway, ESP12-based boards are usually dirt cheap. My Wemos D1 was only a couple of pounds from AliExpress.
I opened a DOS box and ran “mos” – and a browser opened in Windows – with the above control panel in it. I followed the instructions after telling it what chip I’m using and what COM port… from the command line on the desktop (don’t worry this is not command line stuff generally)
I also told it about my WIFI and the software went off and created a new chip, ready to run with an example program in it. This is SO very different to the earlier versions which involved messing around on the command line.
In my case for one board when doing the above I held GPIO0 low on reset to put the board into programming mode – it may be that whatever board you are using handles that using DTR… which Mongoose supports – kind of like the Arduino IDE does.
From there on it was plain sailing – I tried their example of a button press triggering an MQTT message… realising there was no reference to my MQTT broker in their script – in “prototyping mode” I hit the configuration tab in the web UI and in the middle of THAT (device config) (simple view)… was the MQTT setup. If you’re using a public MQTT then life is easier as you don’t have to make changes – you can use their default – but I like to use my own.
No reference to ports so I put my MQTT address as “192.168.1.19:1883” – added username and password and saved the config – the UI uploaded that to the board and rebooted it. I could see in the console message that all was working well.
I set my MQTT client on the PC to subscribe to /devices/# and noted that the light on the ESP8266 board was flashing (which if you look at the example code they default to – it is supposed to). I shorted the relevant pin – in this case the connector marked D3 – to ground and sure enough – just as the Mongoose interface confirmed I had published a message – it appeared on my MQTT client.
Now, sending an MQTT message is one thing – but does the MQTT recover from lost connections – and more importantly does it re-subscribe? Well, I spoke to Sergey Lyubka and he says absolutely YES. If true this is a really good start!!!
So is Mongoose OS any use? After all we can program these boards in Arduino IDE or in C using the SDK and you can write BIG programs in C without worrying too much about storage?
Right now in the setup there is only one access point name – a backup one would be nice… also I note that I2C is set up automatically on GPIO12 and GPIO14 but you CAN disable it – just as you CAN enable SPI – all in the setup.
I did all of this again on my ESP32 board and that worked just as well – however my £6 ESP32 board does not have a LED connected to a pin – so I had to wire up a LED – and that worked well.
So very much to learn but i have made contact with Sergey Lyubka of Mongoose – and I’ve let him know of small issues I’ve encountered ( like what looks like an error but isn’t in the image above – bottom right panel) – expect more updates soon. This looks well worth progressing. It is worth noting that the FREE RAM in this example on an ESP8266 is considerably more than the FREE RAM I encountered when play with microPython. Of course on an ESP32 there will be a lot more but as the ESP8266 is very cheap – it is important that this has enough resources.
With MQTT working an examples of how to read and write ports – that’s one hell of a start..