• Hi,

    I need to use WIFI and have an original espruino and an esp32 lying board around. Eventually will just get an espruino WIFI, but seems like fun to tinker using the esp32 as the wifi 'board' so I did :)

    So the strategy I have in mind is connecting the two via serial have them communicate that way. Tried the simple loopback test and seemed to work fine. With the actual connection I'm getting garbage character most of the time.

    on ESP32:

    setInterval(function(){ Serial2.send("Hello from ESP32")},1000);

    On Espruino:

    Serial4.on('data', function (data) { print("<Serial4> "+data); });


    <Serial4> ª
    <Serial4> µ
    <Serial4> l
    <Serial4> o
    <Serial4> f
    <Serial4> v
    <Serial4> m
    <Serial4> E
    <Serial4> S
    <Serial4> P
    <Serial4> 3
    <Serial4> 2

    Is there anything different I need to do? Thanks!

  • I'm not sure. I'd maybe try different pins on ESP32, also maybe disconnect the two boards, short RX and TX on each board, and see if you can receive what you sent on the same board - it's a good way of problem-finding.

    It looks like you might be able to run an AT command firmware on ESP32, in which case this code might get you proper WiFi on the original Espruino.

    Of course if you had an ESP8266 lying around that'd probably be preferable in this case!

  • Thanks Gordon - Sorry it was me being a N00b: GND need to connect between the 2 boards. Kept forgetting about that one :/

  • I thought UART2 on ESP32 was on 16 and 17?

  • @DrAzzy this is the board I’m using:

  • Hmm. Per this page: http://www.espruino.com/ESP32 UART2 is on 16 and 17... (and it works beautifully on these pins)

    So something isn't making sense here...

    Another thing that's strange here is that - at least at 115200 baud - on ESP32 side, the on('data') callback is called only once, with the whole blob of data, rather than once per char...

  • For information only, there is an overlapping of GPIO16/17 on some boards
    For WROVER boards, those with additional 4MB PSRAM, 16/17 are used for the PSRAM.
    For WROOM boards like yours it should'nt be a problem.

  • I switched board to another one (NODEMCU ESP32), switched to GPIO16/17, and did a simple test


    Serial2.setup(115200,{rx:D17, tx:D16});

    on Espruino

    Serial2.on('data', function (str) {

    Strange. Can confirm that message sent from Espruino is received on ESP32 as entire blob instead of per character...

  • I switched the pins and did


    Serial2.print("lorem ipsum dolor");

    Got on Espruino:

    um d
  • How many characters you receive at a time depends on lots of things, so I wouldn't worry about it - for instance if Espruino is busy running some code then you'll get lots of characters at once.

    It might be related to the fact that ESP32 will have to send out the data it received out of a UART that is the same speed as the UART it receives data on.

  • @Gordon for my purpose I have to get the entire message before deciding next step of actions. Does this mean it’s best practice to always buffer the data for the busy case you mentioned above even for Espruino boards? I’ve been wrapping the message from ESP32 board with a start and end chars (<,>)so Espruino can understand whole messages, is there a proper way to detect start and end of transmission?


  • Yes, I'd always buffer it. I think it's pretty common practice to just use the newline character:

    function handleLine(l) {...}
    function setup() {
      var line="";
      Serial2.on('data', function (str) {
        var l = (line+str).split("\n");
        line = l.pop();
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Espruino original <> ESP32 serial communication

Posted by Avatar for n00b @n00b