Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Arduino webserial data filtering

I have an Arduino kit and a webserial API setup to receive the data into a html div with the id of target.

At the moment it is logging all the data into one stream (there are a few dials and switches on the Arduino).

The data looks like this...

RADI 61 RADI 62 RADI 63 RADI 64 WIND 1 WIND 0 WIND 1

...RADI being a dial value and WIND being an on / off switch.

Is there a way to separate this information into RADI and WIND chunks...ideally into separate HTML text boxes so I can manipulate that data?

Any help would be appreciated

Here is my current javascript code...

document.getElementById('connectButton').addEventListener('click', () => {
    if (navigator.serial) {
    connectSerial();
    } else {
    alert('Web Serial API not supported.');
    }
});

async function connectSerial() {
    const log = document.getElementById('target');
    
    try {
    const port = await navigator.serial.requestPort();
    await port.open({ baudRate: 9600 });
    
    const decoder = new TextDecoderStream();
    
    port.readable.pipeTo(decoder.writable);

    const inputStream = decoder.readable;
    const reader = inputStream.getReader();
    
    while (true) {
        const { value, done } = await reader.read();
        if (value) {
        log.textContent += value + '\n';
        }
        if (done) {
        console.log('[readLoop] DONE', done);
        reader.releaseLock();
        break;
        }
    }
    
    } catch (error) {
    log.innerHTML = error;
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming you have a couple of textboxes:

<input id='textbox1'></input>
<input id='textbox2'></input>

You can update your log references to the following:

const log1 = document.getElementById('#textbox1');
const log2 = document.getElementById('#textbox2');

Then in your loop:

if (value) {
    let parse = String(value).split(' ');
    if(parse[0] ?? '' == 'WIND') log1.value = parse[1];
    if(parse[0] ?? '' == 'RADI') log2.value = parse[1];
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!