Closed Jaytt closed 6 years ago
Hello please provide some code!
As stated on the readme, you can find your vid/pid with the lsusb
command on Linux or Android
`serial.requestPermission( // if user grants permission function(successMessage) { // open serial port serial.open( {baudRate: 9600}, // if port is succesfuly opened function(successMessage) { open = true; // register the read callback serial.registerReadCallback( function success(data){ Recieved(data); }, // error attaching the callback errorCallback ); }, // error opening the port errorCallback ); }, // user does not grant permission errorCallback );
function Recieved(data){
// decode the received message
var view = new Uint8Array(data);
if(view.length != 0) {
for(var i=0; i < view.length; i++) {
// if we received a \n, the message is complete, display it
if(view[i] == 13) {
str = str.replace(/(\r\n|\n|\r)/gm,"");
if(str.length > 7){
cardUD = str;
readNew = true;
}else if(str.length > 2 && str !=Test){ //==============================================
consumption = parseInt(str);
}
if(str != "0" && str !=Test){
time = 0.0; // if not idle reset timer
}
Test = str;
AnyText++;
str = '';
}else{// if not, concatenate with the begening of the message
var temp_str = String.fromCharCode(view[i]);
var str_esc = escape(temp_str);
str += unescape(str_esc);
}
}
}
}`
nothing special on my code it's basicly the exemple you guys made with a bit of string processing
i found my problem, it's an interference with reles, after using a phototransistor everything worked just fine
I'm try to make a constant connection with android 4.0 but after a few minutes it disconnect and i can't get it back to work. I've tried 2 different android tablets, an arduino uno ch340q and an origianal arduino mega, but the none can hold the connection. I also would like to know how to get vendor-id product-id, it would be useful for me.