Converting values in mit app inventor

yes, the voltage measured from hardware is 430mV, so how do i adjust? Sorry i am not clear of "(/1000)". Sorry for the late reply, i used up my full post limit yesterday (didnt know that)

For the 1st picture, what does the warning means? "Sets this variable to be equal to the input".
For the 2nd picture, my bluetooth connection is successful and it shows the voltage reading as same as in serial monitor of arduino IDE. Just my glucose level does not get the value of voltage reading, so can be edited in the blocks editor? Thanks

1st Pic
That is the descriptive tool tip for the set variable block, it is not an error message
2nd Pic
in relation to your blocks Pic, you have not placed the calculation blocks in an event block anywhere, so it won't do anything! Put them at the end of the Clock Timer event ?

Thanks for replying, do you mean i put the "set global glucose level " under the clock timer "set real reading" that part?

Yes. Or you could have a separate button so you are not calling it all the time....

Hello, i got an error after i put the "set global glucose level " under the clock timer "set real reading" that part which means my glucose level result failed to come out. What should i do?

Please show your relevant blocks

Testing.aia (73 KB)


Done

use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

I have connected my companion, and i tried to use the Do It at the blocks editor and it showed me this (same thing i guess). It seems it doesnt help me to debug. Everything is fine above just this glucose calculation keep on error.

Hello Raphael

That is a specific runtime error message, it has nothing to do with output by Do It.
What it is reporting is a very strange list of values - is that what you are sending from the Arduino?

Hello ChrisWard, yes the voltage value shown on the apps is same as the serial monitor of arduino ide there. So "strange" means? Thanks for replying anyway.

Hi

I was trying to establish where the string list in the error message comes from. When you send data from the Arduino, it should just be a value without decoration e.g.

160 :heavy_check_mark:
voltage reading = 160 :heavy_multiplication_x:

The values seem to arrive in quick succession? The art of good communication of data is to send it at the slowest rate that serves it's purpose. It's also essential that the App process time is faster than the Arduino process time to prevent overlap. So, for example, if the Arduino sends data every minute, the App must be able to complete it's process in less than a minute - say 800 milliseconds. However, if the value only really needs updating every hour or so, then do that.

As Tim mentioned before, you could do the glucose calc in the Sketch, thus sending a final value to the App - I'm sure your App would only need to display the value of interest.

Hi, thanks again for helping ChrisWard. Oh now then i know that it should send numbers only. If i send the IDE code here for you to take a look, will i violate the rule here?

You would not violate any rules :upside_down_face: - but we expect you to try to fix it yourself first!
Unfortunately, I cannot spare extended time this week as I have other urgent work to do - though I'm sure another Power User could help you.

Its okay ChrisWard, no problem and really thank you for at least informing that 160 thing. Have a nice day!

Does it all work now ?

At IDE there, i let the serial monitor to show only numbers no string anymore. And i connect it to my apps, still saying the operation cannot accept the argument. Actually which one is argument in my blocks?

Sounds like you are still getting more than one reading back. Do as Chris says and slow down your arduino....

You probably need to use a message Delimiter to stop receiving the text in clumps and fragments ...

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.

Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check
Is the BlueTooth Client still Connected?
Is Bytes Available > 0?
IF Bytes Available > 0 THEN
set message var to BT.ReceiveText(-1)

This takes advantage of a special case in the ReceiveText block:

ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.