Difficulty sending more than one variable from a Microchip microcontroller using BLE (HM-10) and MIT APP inventor

Which is how an App Inventor List is structured. Hmm.

Can you upload a screenshot? I'm going to ask the author of the extension, Evan Patton, for his advice.

Ah - in main fixed.txt:

sprintf(sVals,%d,%d\0",PanTempSetpoint,ProbeTempSetpoint);

Should be:

sprintf(sVals,"%d,%d\0",PanTempSetpoint,ProbeTempSetpoint);

(missing speech mark)

Chris,
I believe that I have been using correct syntax on the spintf
sprintf(sVals,"%d,%d\0",PanTempSetpoint,ProbeTempSetpoint);

Screenshot:

I have popped the question but I think I can guess the answer - we have to allow the Block to build the List in stringValues.

So we should not send the comma. Instead:

printf("%d\0",PanTempSetpoint);
printf("%d\0",ProbeTempSetpoint);

...and App Inventor inserts the commas.

A worthy experiment, for whoever has the hardware.

1 Like

BTW, the PIC is well specified and I can't see anything that would adversely affect the values to be sent with the straight forward functions we are using. The PIC is innocent your Honour!

OK...I used the two printf statements instead of the -elegant- sprintf statement,
and we are back to both values being superimposed in the yellow band ["151"] on top of ["169"], etc

Status: Data Fail
Labels still report PAN TIME

But did you have the Null values there Patrick? That has been confirmed by Evan as the missing link.

printf("%d\0",PanTempSetpoint);
printf("%d\0",ProbeTempSetpoint);

Both values should be in the Yellow band, that is by design so we can at least see what has been received. EDIT: Oh hang on, you mean the 2nd value replaced the 1st.

..in case the data is arriving too fast:

printf("%d\0",PanTempSetpoint);
delay(20);
printf("%d\0",ProbeTempSetpoint);

I really need to setup a board and run some tests but currently our house is a building site and I don't have the space unfortunately. If you get fed up with this distraction Patrick I fully understand, I just wanted you to have the most efficient, reliable code.

Chris,
I'm OK with working on this... every time you and ABG post, I learn something ...

Hello,
It was a while ago when I last time used PIC micros but as for sending multiple data as a list, why don't you put them into a string first and send the string instead of sending them separately. Well, the sprintf does something similar putting them into a character stream, but it is worth a try. Unfortunately i don't have a PIC right now so I cant try it, but maybe I can do some trick with the ESP to program its serial in similar way (assuming I will have enough time this week).

.....like you shouldn't have listened to us in the first place? :grin:

Hi Patrick

Could you try this Project
Swirlworks3B.aia (199.0 KB)

with this Script? Ugo (Usane) suggested going back to sprinf(). I think he could be on to something because we had some success before.
main3.txt (15.6 KB)

Edit: I have replaced Swirlworks3.aia with a revised project, Swirlworks3B.aia, removing a self-inflicted bug and improving status report.

Hello Chris...
Please see screenshot... I tried something similar by the way...

"B" version

Hello Chris
This statement is not correct.

Ugo = uskiara.
I am a different person.

Sorry Ugo, but I had to align the name with the forum name for it to make sense to anyone else.

Thanks Patrick - I hope I haven't made your hair go grey!

I think what is happening is that the Block's separation of values is not triggered because they are not accompanied by BLE characteristic data - so I guess we are lucky we can get data in.

Kidology:

main4.txt (15.2 KB)

EDIT: On second thoughts, this is not enough to work.

A final attempt using an array. Swirlworks3B.aia with this script:
main5.txt (15.3 KB) :crossed_fingers: