Using uart to send light level collected from micro:bit to app inventor

Hi everyone,

I am using MakeCode to collect the light level from the micro:bit, send the light level using uart in Bluetooth and receive the light level in the app inventor side. The light level can be successfully read in the app inventor side, however sometimes it is not the same as the one displayed on microbit (for example, the light level show on microbit is 30, but the app inventor side read 27), occasionally the reading between the two are the same. (Remarks: reading of 0 light level is always the same between the transmitter and the receiver)

May I know what is the reason on that? The micro:bit remains in position during the whole process.

Since it has been little information on uart sending light level between micro:bit and app inventor, hence a topic is opened for that.

Thanks.
It would be a great pleasure for me if you can answer this question.

Hi, can you show the MakeCode code and App Inventor code. I would be interested in testing that. I use MicroBlocks to code my micro:bits.

Take special note of the milliseconds per loop on the transmitting and receiving sides.

Freeze the m:b display for a few seconds after sending data.
Or, ensure enough delay to send/receive one sample at a time.
Or, use some kind of flow control - do not send a sample until you receive an ACK from the MAI.

Thanks all. The problem is solved before you guys reply.