So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Titan Rain
#61599 Couple questions that might be newbish/outlandish.

I know I can mod a NodeMCU (esp8266) board to run MicroPython, but can I install MicroPython on the raw esp8266 chip? http://www.taydaelectronics.com/breakout-boards/esp8266.html

The NodeMCU is a power hog for my general use case, since serial is always on or running and furthermore not always needed/wanted. As depicted here: https://tinker.yeoman.com.au/2016/05/29/running-nodemcu-on-a-battery-esp8266-low-power-consumption-revisited/

The idea here is, can I install MicroPython on bare bones ESPy that offers low power consumption in a small size?

If so, then perhaps I can find a way to port minimalist/slimmed down libraries like Skulpt, Karrigell, etc... since I prefer Python, but that's for a different form.

If not, I know HTML is standard for ESP8266, can I also use or incorporate CSS and/or Javascript? I've dabbled enough in each to know my way around, just wondering if I would be able to utilize them to, for instance. display a pie graph that changes on the fly to represent signal strength. If CSS/JS is an option, can you provide some source/example code?

TL;DR
* Can I run MicroPython on raw esp8266? (not NodeMCU, Huzzah, etc...)
* If not, can I add CSS and/or Javascript to ESP8266's HTML for a more interactive web GUI?
User avatar
By efess
#61613
I know I can mod a NodeMCU (esp8266) board to run MicroPython, but can I install MicroPython on the raw esp8266 chip?


There's only "one" chip that executes code, no matter which board (NodeMCU, ESP1-12, etc). They only differ by including serial->usb chips, power regulators, and different size flash. Only the size of flash may be of concern to you, but the NodeMCU and ESP12 both include a 4MB flash.

The idea here is, can I install MicroPython on bare bones ESPy that offers low power consumption in a small size?


I haven't used it, but micropython does support the esp8266. See here:
https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/index.html

On the HTML/CSS/js, these are browser resources that you use when you navigate to a page. These don't actually "run" on the ESP8266, the esp8266 can only store these files and "serve" them to a web browser if you run web server code on the ESP. I know Arduino provides a decent web server implementation, it looks like micropython also provides a simple example here:

https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/network_tcp.html#simple-http-server

In order to provide useful sensor data to your browser pages, you'll need to either insert them into the HTML while serving with the above http server - using some sort of tokenized string replace or dynamically generate the HTML, or make a separate call to the ESP with javascript and AJAX functions - which is much more complex.
User avatar
By Titan Rain
#61624 Thanks for your help. That clarifies several things for me. Especially, the 'run' vs 'serve.' To do what I would want, intermittently display a sensors variables using HTML via webserver, that's spruced up by CSS/JS, I would have to use some kinda crazy while loop that updates the HTML source code using string substitution.

I'm thinking the desired effect will be much different than what I have in mind, simply because these little guy's are hardware and fundamentally different from the software API, Orangepi, SBC world that I'm coming from but I'll just have to hack it and see what comes out.

Worst comes to worse, I'll just stick to what I know, keep the basics on the ESP and write up some quick, hodge-podge android app to do the crunching. Thanks again for your input.
User avatar
By jeffas
#61704 I'm impressed that you can create a "quick, hodge-podge android app". I've had a couple of goes at getting my head round Android apps, with little success. I'd be very interested in seeing anything that you come up with.

You're right about using text substitution to patch sensor data into a returned HTML page, but you don't need any sort of while loop. Just collect sensor data each time your web server is asked for the page, and generate the page from a set of fixed strings. String manipulation in C++ can be tricky, but in Python it's really easy. So if you do put MicroPython on, that should make it a lot easier. If the sensors are slow to read, then you could use the standard loop() function to maintain a set of current values, and patch those into the page when it's requested.
If you want to use JS/CSS, and you have a webserver somewhere off the ESP, you could serve .js and .css files from there, rather than filling up the ESP with them.