I think I have still not been clear. The pin I want to control from Smoothieware is the pin 12 of the ESP. And I wanted to control it from the standard M80/M81 gcodes.
Anyway, I got it working with some help from Wolfmanjm (smoothieware). Just added 2 lines in the communication module of Smoothieware, in the GcodeDispatch.cpp file, in the "Mcodes" management section: (if it can be useful to others):case 80: THEKERNEL->streams->printf("[ESP201]P12 V1\r\n"); break;
case 81: THEKERNEL->streams->printf("[ESP201]P12 V0\r\n"); break;