Skip to first unread message

Ghica

unread,
May 1, 2019, 8:33:31 AM5/1/19
to MIT App Inventor Forum
Could you post your relevant blocks here and a sample of the data you send to your app?
Cheers, Ghica.

TimAI2

unread,
May 1, 2019, 8:34:56 AM5/1/19
to MIT App Inventor Forum
Have you searched the forum and FAQ for information on connecting your phone / app with bluetooth / arduino / AD8232 / HC06 ?
Plenty here...

If this doesn't help to resolve things then you will need to provide more information:

Sketches / ino files
Blocks images
Project file

Others may not have your hardware it is therefore often difficult to test recomendations

Bahattin Gok

unread,
May 1, 2019, 10:13:12 AM5/1/19
to mitappinv...@googlegroups.com
I made app by youtube video and, after I use this app. I made too but I think I remove it because I cant find so I upload these app. My arduino code and app files here this link. Thank you.

Ghica

unread,
May 1, 2019, 10:43:10 AM5/1/19
to MIT App Inventor Forum
If you want further help, we need an .aia and delete that .apk! 
Cheers, Ghica.

Bahattin Gok

unread,
May 1, 2019, 10:56:13 AM5/1/19
to MIT App Inventor Forum
Okey, I am sending ASAP

Bahattin Gok

unread,
May 1, 2019, 11:41:02 AM5/1/19
to MIT App Inventor Forum
Okey I dont know my link work or not. Here you are. I am using this app.

Link is here
And its image(ss)  is here. Thank you.

app_ss.png


http://ai2.appinventor.mit.edu/?locale=en#6322817839267840

ABG

unread,
May 1, 2019, 1:53:49 PM5/1/19
to MIT App Inventor Forum
Here's your sketch, to save trouble for the other reviewers ...

#include <SoftwareSerial.h>

SoftwareSerial btSerial(2, 3); // RX, TX

int in = A0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(38400);
  btSerial.begin(38400);

  pinMode(in, INPUT);
  pinMode(10, INPUT); // Setup for leads off detection LO +
  pinMode(11, INPUT); // Setup for leads off detection LO -
}

void loop() {
  // put your main code here, to run repeatedly:


  if ((digitalRead(10) == 1) || (digitalRead(11) == 1)) {
    Serial.println('!');
  }
  else {

    float val = analogRead(in);
    Serial.println(val);

  }
  //Wait for a bit to keep serial data from saturating
  delayMicroseconds(1000);



}


 I marked the important parts in bold.

The default connection speed is usually 9600 bps.
Will this fast 4x speed connect okay?  Maybe.

You do a  println('!') but don't check in AI2 for that in your plotting math.

You do a println() of a float value, but do a readBytes in AI2.
AI2 does not know to assemble and decode the println text back into a number.
Instead, use an AI2 BT delimiter of 10 (line feed) and BT read text to get complete transmissions of the text form of the number:
Use println() to separate messages when you transmit.
Set Delimiter = 10 in BlueTooth Designer.
Check for Bytes Available > 0 in blocks,
but then request -1 bytes to get only full  messages.

Your sending delay is 1000 microseconds = 1 millisecond.
AI2 can't process that quickly.
AI2 must read twice as often as your hardware sends, to avoid choking.
Adjust your Clock.Timer accordingly (20 ms?) and your .ino delay() longer (30000 uS = 30 ms?)

Guard your AI2 plotting math to excluded non-numeric messages (like '!')

ABG

Reply all
Reply to author
Forward
0 new messages