• Does someone already tried to install Espruino on the Heltec/TTGO/Lolin/WEMS (or any of its dozen names) esp32 lora board?

    This board features:

    • an esp32 controller
    • a sx127x lora module
    • an OLED screen (don't know which model)
    • a cp2102 micro USB interface
    • a battery connector and charging circuit

    Ex: https://www.aliexpress.com/item/TTGO-LOR­A32-868-915Mhz-SX1276-ESP32-Oled-display­-Bluetooth-WIFI-Lora/32840222847.html

    The controller is an ESP32 so I guess that it's possible to flash it with Espruino but I'm not 100% sure...

  • Yes, have a couple of the Heltec boards with Lora 868/915 and one with just the Wifi Kit.

    Espruino generally works very well. With connected sensors, power sensitivity seems pretty fussy at times so see more reboots than I was expecting but otherwise able to get OLED, Lora, WiFi client all working well.

    Support for Wifi Base, Bluetooth and ESPNow are not yet functional as far as I can see.

    Example to use OLED:

     I2C1.setup({ scl: D15, sda: D4 });
     var g = require("SSD1306").connect(I2C1, startLogo, { rst: D16 });
    
  • Thanks @guycreate, I received my two TTGO boards and it was really easy to install Espruino on it.
    I started to play with it and it sounds really promising :)

    Do you know if it is possible to use the built in RST and PRG buttons with Espruino ?

    Here is the pin diagram of my board: https://ae01.alicdn.com/kf/HTB1V_aBbTnI8­KJjSszbq6z4KFXaH.jpg

    I don't know which pins correspond to these buttons :(

  • Answer to my own question: the RST button works perfectly with Espruino if you don't forget to call the "save" function to save your code in the board. Always read the doc...

  • Can U paste here, the lora connection code too? The oled is working for me. (but wifi connection is not with espruino version espruino 1v95)

    this is what is not working for me:

    SPI1.setup({ sck:D5, mosi:D27, miso: D19 });
    
    var sx = require("SX127x").connect({spi: SPI1, cs: D18, rst : D14 });
    
    setInterval(function() { sx.onIRQ(); }, 100);
    
    var config = {
      rxContinuous : true,
      bandwidth: 2
    };
    
    
    /*
    sx.setRxConfig(config);
    
    // enter receive mode
    sx.rx(function(err, inf) {
      // Error, or you get signal strength and data returned in an object
      if (err) console.log("RX ERROR");
      else console.log("RX>",inf);
    });
    // after a while, stop receiving
    setTimeout(function() {
      sx.standby();
    }, 10000);
    
    */
    
    
    
    sx.setTxConfig(config);
    
    sx.send("Hello", function() {
      console.log("TX done");
    });
    
  • Hey, pelase see the files attached at the end of this thread and tell me if they work for you. They are supposed to resolve the Wifi, and Bluetooth issues with the Heltec boards.

    http://forum.espruino.com/conversations/­324188/#comment14397759

    Good luck :)

    -=hfc

  • Thanks! I downloaded your binaries.

    Do you have example code for?

    • rx and tx with lora module
    • bluetooth

    Yesterday I successfully created a code to drive the oled, but with this espruino version I got this:

    >WARNING: jshI2CSetup: driver installed, sda: 4 sdl: 15 freq: 100000,
    ERROR: jshI2CWrite:, slave doesn't ACK the transfer.
    

    And the the code worked yesterday does not drive with this espruino version.

  • The RST pin is important in the Wifi Kit 32 board, I would assume it is in your case as well.

     I2C1.setup({scl:D15,sda:D4});
     
    function start () {
        // put your startup code here. 
    }
    
    g = require("SSD1306").connect(I2C1, start,{rst: D16});
    

    There are a series of NRF classes in the reference documents, that I believe the ESP32 uses for Bluetooth. I'm not sure how much of it is fully complete as its a feature in development.

    I don't have a LoRa board, so I cannot help you with that one.

  • Okay, the reset pin was wrong. Now, its working thanks.

    Anybody have an espruino example code with lora on a helltech board?

  • Can u post here a lora example?

  • Thread necro :)
    ("solved", see the next post)

    I have a pair of TTGO Lora32 boards, and following the examples in SX127x, and comparing it with Arduino examples feels like TX power settings are way off. Or this board needs some special config.
    My setup:

    First LoRa board running OpenMQTTGateway pushing to messages with RSSI to influxdb. Visualization with Grafana. Did some testing with various antennas, and results been consistent. It does receive messages from both Arduino and Espruino, just messages from Espruino have a much lower RSSI. Same software, same position, same antenna in the following results.

    Second LoRa board with Arduino OLED_LoRa_Sender example, it's transmitting at 17dB by default. RSSI is around -15db when both boards are on my desk, and -90db when the sender is at the other end of the house (50cm main walls...). Lowering TX power does lower RSSI as expected.

    Second LoRa board with Espruino 2v04 and basically two liner from the sample (full code at the end):

    sx.setTxConfig(config); // tried some `power` values
    sx.send("Hello", function() {
      console.log("TX done");
    });
    

    RSSI with the two boards sitting ~50 cm apart: -100-110db. Almost 100db less than the Arduino sample. This actually doesn't make much sense, as the TX power range is -4dBm .. +20dBm, so you can't even set TX power that low. It's as low as when I was changing antennas on the receiver: no antenna on the receiving side, but still got the messages. Like something is not connected when transmitting from Espruino?

    My first guess was frequency or coding or something is a bit off. But both run the same "default-ish" config. After checking it with my RTL-SDR, I think it's really transmission power: The arduino example's transmissions are clearly visible, but I see nothing when transmitting with Espruino. In this case all antennas are 20-50 cm distance.

    Full Espruino code:

    
    var g = null, sx = null, sxSpi = null;
    var ix = 42;
    var SSD = require("SSD1306");
    var SX = require("SX127x");
    
    var config = {
        power: 17
    };
    
    function start() {
        g.setFontVector(14)
         .drawString("Hello Espruino!", 0, 0)
         .flip();
    }
    
    function send() {
        ix++;
        var msg = `pwr: ${config.power}, ix: ${ix}`;
        sx.send(msg, function () { print('TX Done: ', msg); });
    
        g.clear()
         .setFontVector(14)
         .drawString(msg, 0, 0)
         .flip();
    }
    
    function onInit() {
        // gfx
        I2C1.setup({ scl: D22, sda: D21 });
        g = SSD.connect(I2C1, start);
        start();
    
        sxSpi = new SPI();
        sxSpi.setup({ sck: D5, miso: D19, mosi: D27 });
        sx = SX.connect({ spi: sxSpi, cs: D18 });
        print("call setTxConfig", config);
        sx.setTxConfig(config);
        setTimeout(function () {
            // Until DIO0 line irqs are implemented we need this:
            setInterval(function () { sx.onIRQ(); }, 100);
        }, 10);
    }
    
  • Update: manually setting the 0x9 RegPaConfig register to values stolen from the Arduino sample yields similar RSSI values.

    Update 2: Most likely the RFO output pin is just not connected on the TTGO module, so you have to use the PA_BOOST output. At least the RadioHead library and a blogpost mentions that Hope RF's RFM95 doesn't have RFO pin connected. The TTGO branded LoRa module has a metal shield on it, but has the same pinout and physical size so I assume it's the same design as well. Of course this isn't documented in the datasheets...
    Looks like libraries I have checked so far use the RFO pin only for the lowest power settings, while that could be used up to +14dBm output power. But instead use PA_BOOST for everything other than <2dBm. Didn't make any sense first, but looks like it's the workaround for the not connected pin...

    Update 2.5: tested with an RFM95W: same behaviour - as expected. RX works, TX with an RSSI in -100db at a short distance, but works better after changing the Pa Config register and switching to PA_BOOST pin.

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

Espruino on the Heltec/TTGO/Lolin/WEMS esp32 lora board

Posted by Avatar for Grumpf @Grumpf

Actions