• Hi! Glad you got something working! Personally I think there is a tidier way of getting it going though - it's to let the Pico collect the data and push it out itself, then to just listen to the USB serial port for data.

    So I'll just use temperature from the chip as anyone can try that - but all you need to do is replace E.getTemperature() with bme.getData():

    // push data every 2 seconds
    setInterval(function() { 
      USB.println(E.getTemperature()); 
    }, 2000)
    

    Now you can just do cat /dev/tty.usbmodem00000000001A1 on the host PC and it'll display data.

    Now you might just be able to open that as a file in Node.js, or potentially you can use child_process(https://nodejs.org/api/child_process.htm­l) to run cat /dev/tty.usbmodem00000000001A1 and respond when you get data from it: https://nodejs.org/api/child_process.htm­l#child_process_child_process_spawn_comm­and_args_options

    const { spawn } = require('child_process');
    const ls = spawn('cat, ['/dev/tty.usbmodem00000000001A1']);
    
    ls.stdout.on('data', (data) => {
      console.log(`stdout: ${data}`); // your data comes in here
    });
    
    ls.stderr.on('data', (data) => {
      console.error(`stderr: ${data}`);
    });
    
    ls.on('close', (code) => {
      console.log(`child process exited with code ${code}`);
    });
    
About

Avatar for Gordon @Gordon started