• I still have a problem with my query not being sent out on the serial port after power on.
    The setup is that I have the MDBT42Q connected to an ESP32 based board, this board has a console on its main serial port where I have to send a command and read the respons.

    I have attached the core running right now.

    Senario1: I power on both the esp32 and the MDBT42Q at the same time, the MDBT42Q gets it 3V3 from the ESP32 board. There is now no query sent. The LED flickers so the timer is running, but there is no bytes coming out of the MDBT42Q module.

    Senario2: I power on the esp32 and leave the MDBT42Q unpowered, this skips load of start up messages etc etc. Have TX and RX connected and connect VCC. Same as Senario1, no query is sent.

    Senario3: I disconnect the RX pin on the MDBT42Q, apply power, wait until one flicker of the LED (one query is send), and then connect the RX pin. The system now runs.

    So I can not have the RX pin connected during boot of MDBT42Q, doing so makes the TX pin silent.

    For senario 1 and 2, if I after power on connect via BLE the console does not show the traffic from the ESP32 board. And sometimes I get "New interpreter error: BUFFER_FULL" on the console just after connecting.

    With senario 3 I get the console messages as expected when connected via BLE.

    Any suggestions?


    1 Attachment

  • How are you saving this code to Espruino? If you're uploading to RAM and then doing save() then the Serial1.setup code might not run at boot time, which I guess is possibly what is causing the problem?

    Saving to flash should work fine, but I would try removing the Attempt to clear the serial buffer before main code starts. code as I'm not sure it'll be doing anything and worst case could end up locking up the device if data comes in faster than can be handled.

  • I always use the "save to flash".
    And before every upload I run "require("Storage").eraseAll();reset()" to clear the board.

    The reason I run "require("Storage").eraseAll();reset()" before every upload is that uploads have a tendency to fail half way if not. I am guessing the BLE update instruction running every 2s might interrupt the BLE transfers??

    I removed the "Attempt to clear" section and re did the same tests. No change, still cant have the RX pin connected.

    Just to point out. The status of the TX pin on the ESP32 will be unknown if it's transmitting data. During a cold power on this is most likely the case.

  • The New interpreter error: BUFFER_FULL means that your ESP32 feeds the output to MDBT42Q
    javascript interpreter console. as these are not javascript commands you should move console away.
    But perhaps the

    E.setConsole('Bluetooth',{force:true});
    Serial1.setup(115200, { tx:D6, rx:D8 });
    

    is too late and maybe will be always too late as the serial buffer will be filled with garbage sooner than those lines can run. Either there is a way to flush Serial1 somehow after you redirect console or maybe better is to simply use different pins.

    Serial can be on any pins you chose, so if you actually don't plan to use Serial1 as Espruino console you may setup it on any other pins so it does not interfere with expected Espruino console input at boot time. So connect ESP32 to pins e.g. D11,D12 and then setup serial as Serial1.setup(115200, { tx:D11, rx:D12 });

  • I moved the serial connection to D14 and D15, everything works OK now.

    I read the page about pins for the serial port and must have mixed up pages as my memory said it could not be moved....

    Thank you very much for the help :-)

  • Great! Glad that fixed it :)

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

Serial1 does not send data when RX is connected on boot.

Posted by Avatar for JohanWinas @JohanWinas

Actions