@César, although your voltage divider technique is acceptable, have you considered using opto-isolation to electrically separate the two circuits? May be a bit overkill, but a one dollar part would definitely protect your next treasured Espruino device.
@allObjects wrote a nice overview that may be read under heading 'Optocoupler' that I referenced
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Fri 2018.09.14
@César, although your voltage divider technique is acceptable, have you considered using opto-isolation to electrically separate the two circuits? May be a bit overkill, but a one dollar part would definitely protect your next treasured Espruino device.
@allObjects wrote a nice overview that may be read under heading 'Optocoupler' that I referenced
Quick Start Best Practices - Connecting a relay using isolation - optocoupler - 2 Relay Board Module
Are you able to post a picture of, and/or provide a schematic as @Jean-Philippe_Rey suggested?