You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Hi - Serial is a built-in object, so by setting it to Serial1 you're probably causing yourself a lot of trouble. Try the following:

      var serial=Serial1
      USB.setConsole(true);
      serial.setup(9600);
      serial.on('data', function (data) {
        console.log(data);
        if (data==='1'){
          LED1.write(1);
          serial.print("test\n");
        }
        if (data==='0'){
          LED1.write(0);
        }
        if (data==='d'){
          LED2.write(1);
          serial.print("sensor: t="+temp_act+", p="+press_act+", h="+hum_act);
          LED2.write(0);
        }
    });
    

    Using Serial2.setConsole should work, but I'd set Serial2 up first or it'll use the default pins. Personally I'd use USB.setConsole(true) (as above) because then the console is still available on USB for updating code.

About

Avatar for Gordon @Gordon started