Skip to first unread message

blacks pro

unread,
Oct 31, 2017, 7:40:28 PM10/31/17
to MIT App Inventor Forum

I am new to the mit app inventor and i just build a gas sensor alarm that can control the value when the alarm will be triggered with a slider. I keep on facing the cannot accept the argument {empty string } as shown below. Can anoyone help me figure it out how to solve this problem. Thank you!!
Screenshot 2017-11-01 01.48.18.png
Screenshot 2017-11-01 01.48.25.png
Screenshot 2017-11-01 01.53.34.png

gerrikoio

unread,
Nov 1, 2017, 5:21:28 AM11/1/17
to MIT App Inventor Forum
I keep on facing the cannot accept the argument {empty string }... 


As you may know, this is a runtime error message. So, usually to problem solve these sort of things, one needs to know when it happened. What did you do to trigger the error message? I'm guessing it happened after you picked something off a list.

blacks pro

unread,
Nov 1, 2017, 6:27:54 AM11/1/17
to MIT App Inventor Forum
The error is triggered when i connect my app to the bluetooth and starts to receive numbers.The error appears 5-10 seconds everytime after i dismiss it.

Abraham Getzler

unread,
Nov 1, 2017, 10:41:22 AM11/1/17
to MIT App Inventor Forum
Your test for input is incomplete.

It only has one level, connectivity.
It also has to test for data arrival.

The proper sequence in the Clock Timer is:

IF CONNECTED THEN
   IF BytesAvailable > 0 THEN
      set Label1.Text to (Get the text from BlueTooth)

ABG
P.S.  What are you doing to send the data? 
print or println?
That affects your delimiter usage.




Abraham Getzler

unread,
Nov 1, 2017, 11:58:45 AM11/1/17
to MIT App Inventor Forum
post your .ino file here,
so we can see the next error.

Also, Ask yourself what you will get into your Label
if you ask for bytes from BlueTooth regardless of whether
there are bytes available to be read, or not?

Search this forum for "gas sensor".

You are not the first.

ABG

blacks pro

unread,
Nov 1, 2017, 12:14:11 PM11/1/17
to mitappinv...@googlegroups.com
I think i might want bytes available to read because its same with my serial monitor.

(.apk removed, per board restrictions - ABG)
PWM_Serial_alap.ino

blacks pro

unread,
Nov 1, 2017, 12:19:45 PM11/1/17
to MIT App Inventor Forum
Please dont mind if i put the label box with text box.

Abraham Getzler

unread,
Nov 1, 2017, 1:00:24 PM11/1/17
to MIT App Inventor Forum



(.apk removed per board guidelines)


I see you are using println() in your .ino sketch to send the reading.

That means that you are using the NL (New Line) character as a line delimiter,
and that to have your AI2  app receive exactly one line at a time,
and no blanks or partial messages, you need to follow the AI2 Delimiter
strategy at this Faq post:


ABG

 const int gasPin = A0;  
 
int sensorValue = 0;        
int outputValue = 0;        

void setup() {
  Serial.begin(9600);
}

void loop() {
   int analogVal = analogRead(gasPin);
  Serial.println(analogVal);

  delay(1000);
  float IniVol = 75.0 / 1023.0 * 5.0;
  float FinalVol = analogVal / 1023.0 * 5.0;
  float ChangVol = FinalVol - IniVol;
  float ppm = 407.25 + 2800.0 * ChangVol;

 

blacks pro

unread,
Nov 1, 2017, 8:26:29 PM11/1/17
to MIT App Inventor Forum
I think i have solve the problem with changing the println to print and add a new block as shown below.
Screenshot 2017-11-02 08.17.59.png

Abraham Getzler

unread,
Nov 2, 2017, 9:26:22 AM11/2/17
to MIT App Inventor Forum
I think i have solve the problem with changing the println to print


Things that might still go wrong ...

How do the transmission and reception rates compare?

What will happen if two transmissions happen in the time span 
of a single Clock1.Timer event?  Will the input be the concatenation of two
transmissions, so if the device send 7 and then 9 the app will receive 79?

ABG

blacks pro

unread,
Nov 2, 2017, 9:54:23 AM11/2/17
to MIT App Inventor Forum
There is sometime when the clock timer receive two transmission. Sometime the app will receive 179180 which is 179 and 180.
How to solve this problem?

Abraham Getzler

unread,
Nov 2, 2017, 11:33:53 AM11/2/17
to mitappinv...@googlegroups.com
Sometime the app will receive 179180 which is 179 and 180

You just discovered the purpose of a Delimiter.

See this post from the FAQ:

ABG
 P.S.  You will need to switch back to println() for this to work.
(edit)

blacks pro

unread,
Nov 2, 2017, 12:57:53 PM11/2/17
to MIT App Inventor Forum
How do I put Delimiter in my case?
Screenshot 2017-11-03 00.53.37.png

blacks pro

unread,
Nov 2, 2017, 2:59:13 PM11/2/17
to MIT App Inventor Forum
I dont really know whats the meaning of delimiter and what is the function of it.

Abraham Getzler

unread,
Nov 2, 2017, 3:03:15 PM11/2/17
to MIT App Inventor Forum
See attached.
ABG
BlueToothClient1_Properties.PNG
Screenshot 2017-11-03 00.53.37.png

Abraham Getzler

unread,
Nov 2, 2017, 3:06:18 PM11/2/17
to MIT App Inventor Forum

2:59 PM (4 minutes ago)
I dont really know whats the meaning of delimiter and what is the function of it.


For this app, the LF is the delimiter between transmissions.

ABG
 
Auto Generated Inline Image 1

blacks pro

unread,
Nov 2, 2017, 3:15:49 PM11/2/17
to MIT App Inventor Forum
What is LF?

blacks pro

unread,
Nov 2, 2017, 3:28:47 PM11/2/17
to MIT App Inventor Forum
Like this?
Screenshot 2017-11-03 03.18.59.png

Abraham Getzler

unread,
Nov 2, 2017, 4:34:32 PM11/2/17
to MIT App Inventor Forum
See the attachment?

LF = Line Feed, also known as New Line

ABG



Screenshot 2017-11-03 00.53.37.png

blacks pro

unread,
Nov 3, 2017, 11:42:20 AM11/3/17
to MIT App Inventor Forum
Then what block do i need to use to replace the call.Bluetooth client.bytes available to receive

Abraham Getzler

unread,
Nov 3, 2017, 12:28:34 PM11/3/17
to MIT App Inventor Forum
-1

Reply all
Reply to author
Forward
0 new messages