publiclab / webjack

a JavaScript library that uses an audio software modem to communicate with an Arduino via a headphone jack
https://webjack.io
GNU General Public License v3.0
135 stars 26 forks source link

Not receiving anything #73

Open markusschweitzer opened 6 years ago

markusschweitzer commented 6 years ago

Hi,

I'm successfully sending text from my browser (pc) to my arduino. But the other way around (from arduino to the pc) doesn't work. I have attached a recording of what my pc receives - for me it "sounds" at least reasonable. The webjack example page doesnt receive any text. I made shure the the site uses the right mic and even if I look in the debug tools (firefox) the decode function is triggered but it always ends at the START or PREAMBLE part.

Does someone know whats wrong here?

Hardware

Arduino Uno + Circuit from the README

Software

Arduino Sketch

#include <SoftModem.h>

SoftModem modem = SoftModem();

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  delay(100);
  modem.begin();
}

void loop() {  
  while(modem.available()){1
    int c = modem.read();
    if(isprint(c)){
      Serial.print((char)c);
    }
    else{
      Serial.print("(");
      Serial.print(c,HEX);
      Serial.println(")");      
    }
  }
  if(Serial.available()){
    modem.write(0xff);
    while(Serial.available()){
      char c = Serial.read();
      modem.write(c);
    }
  }
}

Recording

This should be "test123" sent from the arduino to the pc (recorded with https://webaudiodemos.appspot.com/AudioRecorder/index.html):

https://drive.google.com/file/d/17KitinnCN22WofGULNnbO2h8TRfkN8a0/view?usp=sharing

Thanks in advance, Markus

jywarren commented 6 years ago

Oh goodness I missed this issue! So sorry. I'll try this out but are you sure you're receiving audio at all -- can you play in the youtube demo clip from https://webjack.io/#plotting and receive that? Just to be sure it's an issue with decoding rather than an issue with actually hearing anything at all.

This improvement will make it much easier to confirm that you're receiving /something/ -- hope to get it implemented soon! https://github.com/publiclab/webjack/issues/30

jywarren commented 6 years ago

Here's a waveform of your file on top, and the demo YouTube clip on bottom. I wonder if the generated sound is at the right speed? It seems significantly slower, no?

screen shot 2018-05-31 at 11 38 53 am