Connecting to Espruino

Troubleshoot:

Sometimes, it helps to close Web IDE, open minicom (keep trying until no longer device busy message) hitreturn a few times. Then close minicom, open Web IDE and try connecting again.

If that doesn't help, try
sudo minicom
After that, it may connect as regular user again.

Autostart Code

When the project is deployed, we want the code to start when the Espruino is powered on.

Code structure

Espruino is designed such that the following function will be run automatically after start:
function onInit() {
..
}

so add this function to your code and place a call to your function inside

Save your code in Flash

Save code in Flash so that it is available after powerup:
run
save();

Modules

Espruino provided modules

http://www.espruino.com/modules/

write your own modules

Save Modules in Flash

Make sure firmware is at least 2.0.
In the Web IDE, set the following options:
Modules uploaded as Functions
Do not check "Save on Send Direct to Flash" because this may cause problems with code staying in Flash that should not be there. (See Troubleshooting)

Saving Data to Flash

The module Storage makes it possible to save data as named variables to Flash.

require("Storage").write("MyFile", "Some data");
print(require("Storage").read("MyFile"));

Show what is stored:

require("Storage").list();

To remove what is in the storage currently:

require('Storage').eraseAll();

then

save();

Run Espruino directly from Battery or through Buck Converter?


Supply voltage from one battery directly to Espruino:

U P
3.7 V 0.09 W
4.2 V 0.12 W

Supply voltage from batteries through Buck Converter 1 to Espruino:

U in U out P
8.0 V 3.3 V 0.15 W
4.0 V 3.3 V 0.18 W

Supply voltage from batteries through Buck Converter 2 to Espruino:

U in U out P
8.0 V 3.3 V 0.09 W

Supply voltage from batteries through Buck Converter 3 to Espruino:
(with power LED on)

U in U out P
8.0 V 3.3 V 0.10 W

Useful commands in Web-IDE

Reset Espruino:
run
reset();

Remove modules from Flash:
run
reset();
save();
or may have to use
E.setBootCode()
http://forum.espruino.com/conversations/256465/

Load Modules from disk

http://forum.espruino.com/conversations/286424/

Which Espruino?

Espruino Wifi- Wifi distorts PWM signal on A0 causing the buck converter to not function.
Need an Espruino where the Wifi is not mounted to the Espruino.
Pico?
Can be put into sleep mode with 0.02 mA power consumption
http://forum.espruino.com/conversations/273005/
Add Wifi:
https://www.espruino.com/ESP8266
Name CPU MHz Flash RAM PWM SPI I2C
Espruino Wifi STM32F411CEU6 100 512KB 128KB 20 3 3
Espruino Pico STM32F401CDU6 84 384kb 96kb 21 3 3
Original STM32F103RCT6 72 256KB 48KB 26 2 2



Web Server

https://www.espruino.com/Internet
https://www.espruino.com/Posting+Forms
https://www.espruino.com/File+Converter
Send javascript file separately
https://techtutorialsx.com/2018/10/04/esp32-http-web-server-serving-external-javascript-file/ https://stackoverflow.com/questions/14243100/response-writehead-and-response-end-in-nodejs