Wemos d1 mini for FAN control with Zwift

Posted on
  • Hello,

    I'm new in the Espruino Forum. I've a basic question. I want to use a Wemos D1 mini for FanContol - similar to this approach . The basic idea is to use that device and Espruino, include the Library into it. Therefore I have directly access to the Zwift-Server and get the data like power, heart beat, speed and can control a PWM circuit to control a fan.
    Is this possible with Espruino. Until now, I've no experience with Espruinio. I've some applications runing with Arduino + Wemos D1 mini and some basic Arduino Boards (Uno, Mini,...)

    Best regards Em

  • ...sure, give it a try... Since you want to use PWM and quite some Web access, I'd chose an Espruino-Wifi.

    Depending how you code it in JavaScript, Wemos D1 mini can work. You have to be aware that the ESP8266EX - which is the core - has to tend unconditionally every so often to the Wifi stack, and if you have some blocking code running - code that runs beyond the time of the window between the tending to the Wifi, ESP8266 / Wemos D1 mini will reset... not exactly what you are looking for.

    A more robust solution it Espruino Wifi, where the ESP8266 ESP-07(s) - mounted on it has just to do with Wifi and your application with all the features runs on Espruino STM32F4.

    Starting with Wemos D1 mini does no harm... you always can move up to pair it with a Pico to not throw Wemos D1 mini out... latter will then just do Wifi, and the Pico does your application work.

    But as said, Espruino-Wifi is the more elegant solution...

  • I tried to flash the Wemos D1 mini with the new Espruino Firmware - and it seems that all was fine. But how can I now access to the device? The Espruino WEB IDE shows the message "Connected to COM3 (No response from board)" when I try to send the demo to the board.
    Flashing a second time is also not possible.
    With Arduino IDE I can get the Board-Info (only USB device?). Flashing also not possible.

    esptool.py --port COM3 --baud 460800 write_flash --flash_freq 80m --flash_mode qio --flash_size 32m 0x0000 "boot_v1.4(b1).bin" 0x1000 espruino_esp8266_user1.bin 0x37E000 blank.bin

  • change the WebIDE baud rate to 115200 and try again

  • That was it...

  • Sorry, but another question.
    Hint: Blink demo is working, WIFI demo is working
    Now, how can I have access to the library "zwift-mobile-api"? Or in other words, where have I to store the directory including files (download from git)? Any changes in the WebIDE?

    In source code I have after that to add...

    var ZwiftAccount = require("zwift-mobile-api");


    Best regards Em

  • Espruino does not handle npm modules.

    Check this page for details about modules https://www.espruino.com/Modules

  • Sorry, I'm realy a rookie regarding Espruino and JS.

    But is it not possible to store the directory dowloaded on a local drive and use it like other moduls from Web http://www.espruino.com/modules/
    or no chance to use that library in Espruino?

  • The issue here is that node.js loads dynamically - at runtime - from a structured file system implemented by node.js' require(...) implementation. Espruino does it upfront quasy statically before loading your application main fr0m a fixed directory and there is only one fixed directory (out of the box)... it though follows the node.js module concept.

    If you have access to the zwift source and you put all the files in modules folder and remove any path information from the require(), it may work.

    You may run into space issues, which you may resolve by minifiying (w/ google closure comiler service. You put the minified files in the modules folder w/ .js.min extension.

    Good luck... in a positive way...

    How many files are we talking about?

    PS: 1st lots of lots of brain/boring coding exercise, then muscle exercise on the bicycle... ;-)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Wemos d1 mini for FAN control with Zwift

Posted by Avatar for Wemos4Hobby @Wemos4Hobby