loading

Hello,

I was trying to send some data from an Arduino Ble4 device to a mobile device (android). I tried with the wonderful MIT App Inventor 2 but the Ble features are not implemented yet.

So after looking around for a while, I have found an app called Kino App Inventor, that is written for Iphone and Ipad devices.

The app is really easy and good looking and in a few I was able to do a lot of interesting things.

Unfortunately it's hard to find a complete documentation or other resources on line.

This is how it works at a glance.

Assume that you have:

  • Arduino with a BLE device and that you are sending raw data with the Serial.print(data) command.
  • BLE device (I am using a Xadow Ble from Seeed Studio) that is already paired with your Ipad.
  • Kino App Inventor running (more or less 10$).

Step 1: Intro

In Kino App Inventor you have a section related to the input (internal as the Gps or Gyroscope of your mobile) or linked to external resources as the Bluetooth or Internet, that is calles "Controllers" (A in the image).

A second section is dedicated to the so called "Receptors" aimed mostly to show some features. (B in the image). The third and really useful part is called (Labels), and it's used to show the results coming mostly from the Controllers (C in the image below).

Another useful part is called "Metters" (the developer is Spanish and maybe there is an incorrect double T in Meters). This part is useful to show graph and other meters of the data. (D in the image).

Last but not least you can do your own scripts in Lua and this add a great performance to your experiments. Now we can start.

Step 2: Add a BLE Controllor on the Kino

  • Switch on your BLE device (I am using a Xadow Ble from Seeed Studio, but it should work with any other).
  • Find in the controllers section the "Bluetooth 4.0". Drag it and keep it pressed until a panel is sliding on the right side of the screen.
  • press th "+" sign and add your Ble device

Step 3: Check If It's Working

  • Go in the Receptor part and drag into the screen a Green led.
  • Keep it pressed and wait for the panel.
  • Choose as Source "BLE1"
  • Choose as target "ONLINE"

A warning should appear to ask you if you want to switch to the Ble device. Say Yes.

If everithing is all right you should see the green light on to tell you that the Ble is online.

In the previuos steps we told to the receptor to get the data from the Ble device called "online". This is 1 if it's working. If the data is =1 the led is green, otherwise it's not working.

Step 4: Send Data From Arduino

In Arduino you can easlily send data with the Serial.print command.

I suggest to use the Software Serial example in order to have a second virtual serial port in Arduino, different from the standard 0 and 1 digital pins used for the standard serial transmission.

For instance if we want to see something in the Serial Monitor we use the Serial.print(data) command, and if we want to send it through the BLE device we use Serial1.print(data) - where Serial1 is the virtual/software serial port.

To be sure that the transmission is fine we can send numbers from Arduino with a simpe code like the following.
This produces a series of numbers starting from 0 to 99, and then starts again. This is commonly called "saw curve".

Now we have to decode the data in Kino.

Step 5: Get Data in Kino

In Kino go the the Label part (see step 1) and:

  • drag a Label into the screen
  • keep it pressed and wait for the panel
  • choose BLE1 as source and ffe0/ffe1 as target.

Now you are able to see the data coming from the BLE.

In the next step we can use the coming data in a script.

Step 6: Use the Data in a Script

Open the script part (letter E of the first step)

and write this:

____

dim value as integer

value = [BLE1.ffe0/ffe01]

____

In the first row we are declaring that the variable "value" is an integer number.

In the second row this variable is equal to [name_of_the_controller.name_of_the_feature] - (Mind the brackets!).

Now we can use this variable in our sketch.

  • Use a Label (see previuos steps) and use Script as source and "int.value" as target.

if everything is fine you should see the same value in both labels (the first coming directly from the Ble device, the second passing through the Scripts in the first image).

Why should we use the script instead of getting raw data directly from the controller?

Simple, to use it in logical statements. For instance if you want to switch on a led if the values is going below 50 you can add the following lines, as in the second image:

_____

dim led as integer

if value < 50 then led = 1

else led = 0

end

______

Step 7: Show the Results!

Now we can add other features from Metters, always using script as a source and int.value as target.

You can do a lot more with the Kino App Inventor and Arduino Ble (Xadow), enjoy!

Step 8: Example: Send and Check the Battery Charge of Xadow Board

To do this we need to add few lines and to send the value of the battery charge.

You can refer to the first image to get the value from the Xadow.

Now we have to remap the values to get the charge range from 0 to 100%.

At a maximum charge my battery can give 4.23 volts and below 3.3 it's dead.

So I do 4.23-3.3 and I have 0.93.

100/0.93 gives 107.5 that is the proper ratio to have my values in a percent base.

So I add:

dim charge as double

charge= [BLE1.ffe0/ffe01]

charge=(charge-3.3)*107.5

At this point I can Use this value to display the battery charge with a meter.

In the second image you can se the volts (3.95) the remapped value (71) and a graph.

<p>It was a pity that I don't have an iPhone.</p><p> I was also looking BLE implementation libraries for Android App Inventor 2, but no luck so far. Any one know about this?</p>
<p>Yes, it looks like you can't.</p><p>I <br>did it with a trick: use a third part software for ble (for instance Ble <br> tool from Tony was perfect for me) and use his log file in App Inventor <br> 2. It works in real time.</p>
<p>Where can I find the third party s/w for BLE for app inventor2?</p>
<p>https://groups.google.com/forum/#!topic/app-inventor-open-source-dev/QVo4K4smLpE</p>
<p>Interesting. Thanks for sharing.</p>

About This Instructable

10,874views

15favorites

License:

More by fabiodagnano:Kino App Inventor 1.2 and BLE (Bluetooth Low Energy) + Xadow 
Add instructable to: