B4A Library IOIO board library

The request in this thread here introduced me to a product called IOIO that seems to have been designed by some Google engineers in the 20% of time that Google gives them to pursue their own interests,

The blog of the main mover of the project is at Microcontrollers, Electronics & Robotics: Meet IOIO - I/O for Android

The board will be available soon from here IOIO for Android - SparkFun Electronics

As the software has just been released I took a look at it and wrapped it in a couple of libraries for use with Basic4android. I obviously cannot test it as I have no board but the Basic4android library is a very thin veneer on top of the normal Android library so, typos and idiot errors aside, it should work with no problems and the software documentation should be pretty much applicable. I have copied a lot of the library help from the software documention so a B4A help viewer should give you a good grounding in how to use it.

I don't yet know if the board will be available this side of the pond - if anyone wants to ship me one for testing .... :)

EDIT :- Version 1.1 posted with INTERNET permission. See post #11 for details.

EDIT :- Version 1.2 posted with PulseInput. See post #37 for details.

EDIT :- Version 1.2 reposted with XML error fixed. See post #39 for details.

EDIT :- Version 1.3 posted with SPI and I2C support. See post #40 for details.

EDIT :- Version 1.3a posted with IOIOlib 3.2 included. See post #42 for details.

EDIT :- Version 1.4 posted. See post #47 for details.

EDIT :- IOIOlibBT 3.10 posted. See post#58 for details.

EDIT:- IOIOBT1.4 posted See post #63 for details

EDIT:- IOIOBT1.5 posted See post #77 for details.

THESE ATTACHMENTS ARE NOW OBSOLETE. SEE POST #105 FOR THE LATEST VERSIONS BY KOLBE: http://www.b4x.com/android/forum/threads/ioio-board-library.8942/page-6#post-90731
 

Attachments

  • IOIOBT1.5.zip
    102.3 KB · Views: 2,209
  • IOIO1.4.zip
    100.5 KB · Views: 1,668
Last edited by a moderator:

mrodriguez

Member
Licensed User
Longtime User
IOIO firmware does not support required firmware: IOIO0004

Hi, i have a new ioio-otg board from SparkFun.
I have tested it with my galaxy s3 phone and my galaxy note 10.1 tablet with the same error (over bluetooth).

ERROR:
IOIO1 ioio.lib.api.exception.IncompatibilityException: IOIO firmware does not support required firmware: IOIO0004

CONNECTION LOGS:
05-26 13:45:00.510 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.impl.SocketIOIOConnectionBootstrap
05-26 13:45:00.510 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.android.bluetooth.BluetoothIOIOConnectionBootstrap
05-26 13:45:00.515 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.android.accessory.AccessoryConnectionBootstrap
05-26 13:45:00.550 V/BluetoothIOIOConnection(32162): Attempting to connect to Bluetooth device: IOIO (A3:10)
05-26 13:45:01.935 V/BluetoothIOIOConnection(32162): Established connection to device IOIO (A3:10) address: 00:15:83:15:A3:10
05-26 13:45:01.955 I/IncomingState(32162): IOIO Connection established. Hardware ID: SPRK0020 Bootloader ID: IOIO0400 Firmware ID: IOIO0330

Kolbe can you help me with you library?
Thanks
 

kolbe

Active Member
Licensed User
Longtime User
Well it's connecting but the library doesn't like the firmware application version. Using this from the logs...

IOIO Connection established. Hardware ID: SPRK0020 Bootloader ID: IOIO0400 Firmware ID: IOIO0330

... we can see that your bootloader is 400 but your application firmware is 330. With v1.9 of the library it needs to be 400. So if you update your application firmware on the IOIO to 400 it should be fine. You could also go to an older version of the library that works with 330. See the release posts for details. For info on updating the application firmware goto Ytai's IOIO github.


Hi, i have a new ioio-otg board from SparkFun.
I have tested it with my galaxy s3 phone and my galaxy note 10.1 tablet with the same error (over bluetooth).

ERROR:
IOIO1 ioio.lib.api.exception.IncompatibilityException: IOIO firmware does not support required firmware: IOIO0004

CONNECTION LOGS:
05-26 13:45:00.510 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.impl.SocketIOIOConnectionBootstrap
05-26 13:45:00.510 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.android.bluetooth.BluetoothIOIOConnectionBootstrap
05-26 13:45:00.515 D/IOIOConnectionRegistry(32162): Successfully added bootstrap class: ioio.lib.android.accessory.AccessoryConnectionBootstrap
05-26 13:45:00.550 V/BluetoothIOIOConnection(32162): Attempting to connect to Bluetooth device: IOIO (A3:10)
05-26 13:45:01.935 V/BluetoothIOIOConnection(32162): Established connection to device IOIO (A3:10) address: 00:15:83:15:A3:10
05-26 13:45:01.955 I/IncomingState(32162): IOIO Connection established. Hardware ID: SPRK0020 Bootloader ID: IOIO0400 Firmware ID: IOIO0330

Kolbe can you help me with you library?
Thanks
 

Gaver Powers

Member
Licensed User
Longtime User
IOIO and USB Connection

Kolbe,

Pardon my confusion here...
Can the IOIO OTG be used with the newer model Tablets and Phones in USB mode or must they be connected via BlueTooth?
Or... does building an application using older versions of a library enable USB connections, if so, which IOIO / Firmware version will work with which B4A library?

I apologize if this has been addressed elsewhere.

Thanks for all your effort in moving the IOIO B4A process in the right direction!

GP
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
Hello,

All IOIOs support connection to Android through, USB ADB, USB Open Accessory, and Bluetooth. In recent Android releases however they have added more security to USB ADB. These new security "protocols" aren't implemented on the IOIO and because Open Accessory and BT are available, Ytai doesn't foresee this being added. The problem is that I have never been able to get Open Accessory to work in the B4A library with any Android version. The library uses lower level methods to create a connection (as opposed to the helper API Ytai provides for direct Java development) and I've never figured out how to "manually" make an Open Accessory connection. So.... for Android 4.1 and above, as far as B4A is concerned, we only have BT. Markon promised to help but he just took the code and ran it seems. I tried twice now to figure it out but after a few days gave up. Maybe my third attempt will be the lucky one but honestly I'm happy with BT at the moment.

Kolbe,

Pardon my confusion here...
Can the IOIO OTG be used with the newer model Tablets and Phones in USB mode or must they be connected via BlueTooth?
Or... does building an application using older versions of a library enable USB connections, if so, which IOIO / Firmware version will work with which B4A library?

I apologize if this has been addressed elsewhere.

Thanks for all your effort in moving the IOIO B4A process in the right direction!

GP
 

Gaver Powers

Member
Licensed User
Longtime User
For sake of clarification...

Kolbe,

Is it possible to create our programs in B4A and target to an earlier firmware/library version and utilize USB ADB connections on newer model phones and tablets? Is that what Stulish did?

I'm trying to build a system with a dedicated tablet to cycle a relay and open a door / drawer. I would prefer not to communicate over BT and instead over a dedicated hardwired connection (USB ADB) if possible.

Is there someone else (Ytai ?) that would code another helper library to facilitate use of the Open Accessory protocol for a fee?

GP
 
Last edited:

markon

New Member
Licensed User
Longtime User
Not Forgotten

Not forgotten.

However, after going thru the code I found too many items that do not work with the latest firmware.

So, after studying the Yati's code. I started a re-write from scratch. I am about 40% on this. As I get free time, I work on it. Once I have it running, where it supports OpenApp for both the old version 1 and the much improved version 2 (IOIO-OTG) I will share it back and to the Group.

Mark:)
 

kolbe

Active Member
Licensed User
Longtime User
Good to hear from you. I'm curious to hear the details. What doesn't work? Admittedly I'm still using the original IOIO, not the OTG but I did upgrade to 4.00

Not forgotten.

However, after going thru the code I found too many items that do not work with the latest firmware.

So, after studying the Yati's code. I started a re-write from scratch. I am about 40% on this. As I get free time, I work on it. Once I have it running, where it supports OpenApp for both the old version 1 and the much improved version 2 (IOIO-OTG) I will share it back and to the Group.

Mark:)
 

Eduardo Morales Sanchez

Member
Licensed User
Longtime User
awesome, pinoy_ako ! :sign0098:

I've just received a IOIO board and I want to read a sensor (inductive), but I'm quite lost, I can't find in the documentation how to read the data: should I just use digitalInput.Read in a Timer ?

Or perhaps I need to send a value to the serial port and then read it? Do I need Serial library or IOIO library can do this?

many questions... :sign0013:
 

Eduardo Morales Sanchez

Member
Licensed User
Longtime User
The light sensor is this one.

http://www.sparkfun.com/datasheets/Sensors/Imaging/TSL235R-LF.pdf


The humidity sensor is this one.

http://www.sparkfun.com/datasheets/Sensors/Temperature/HH10D.pdf


The sample rate is overkill for the humidity sensor but it works.

B4X:
Dim yoyo As IOIOBT

Dim hfreq As PulseInput
Dim lfreq As PulseInput

hfreq = yoyo.OpenPulseInput(6,hfreq.IP_FLOATING,hfreq.RATE_2MHZ,hfreq.FREQ_SCALE_16,True)
lfreq = yoyo.OpenPulseInput(31,lfreq.IP_FLOATING,lfreq.RATE_2MHZ,lfreq.FREQ_SCALE_16,True)

humid= Round2((7665-hfreq.Frequency)*(380/4096),2)
lux= Round(lfreq.Frequency)

If your pulse is not 3.3v then you will have to make some changes to this. The output is connected directly to the IOIO pin. Make sure the wires aren't too long, < 12"
 

kolbe

Active Member
Licensed User
Longtime User
Que diferencia hay entre la librería IOIO y la IOIOBT y cual es la aplicación de cada una de ellas

In your two post above this one you don't seem to be adding anything but just replying to other posts? Is there a question?

The latest library is simply IOIO. Earlier versions of the liberay had both the IOIO and the IOIOBT part but this is now depricated code. Use simply the latest IOIO library v1.9.
 

Eduardo Morales Sanchez

Member
Licensed User
Longtime User
hola buen día

Hoy probé el código de IOIODEMO con la IOIO, y me arrojo este mensaje de error

ERROR OCCURRED
An error has occurred in sub:
main_activity_resumen (java line:269)
java.lang.
NullPointerException
Continue?
YES NO

y no me deja corre la aplicación, a que se debe que me saliera ese error
 
Last edited:

kolbe

Active Member
Licensed User
Longtime User
hola buen día

Hoy probé el código de IOIODEMO con la IOIO, y me arrojo este mensaje de error

ERROR OCCURRED
An error has occurred in sub:
main_activity_resumen (java line:269)
java.lang.
NullPointerException
Continue?
YES NO

y no me deja corre la aplicación, a que se debe que me saliera ese error


Sin ver tu código no puedo saber. Lo mejor sería estudiar este ejemplo para entender cómo utilizar el IOIO con B4A.
 

Eduardo Morales Sanchez

Member
Licensed User
Longtime User
El código con el que probé mi tarjeta IOIO es
B4X:
' IOIO Demo
' Simple Test of IOIO from a B4A application
' Same action as IOIO demo Application HelloIOIO
' Connects to IOIO and a button press toggles the yellow LED on Pin 0 (LED_PIN)
'
'    GW 21/05/2011
'    V 0.1
' Tested and works on Samsung Galaxy S and HTC Desire
'
' **NOTE**
' From the IOIO wiki at http://codaset.com/ytai/ioio/wiki/IOIOLib-Basics
'
' "Make sure your application declares using the android.permission.INTERNET permission.
' This can set by opening the AndroidManifest.xml File found at your project's root,
' going To the Permissions TAB > Add... > Uses Permission > Select android.permission.INTERNETunder "Name"."
'
' I added the following line to AndroidManifest.xml for this project:
'      <uses-permission android:name="android.permission.INTERNET"></uses-permission>
' Changing AndroidManifest.xml to Read=Only will prevent it being overwritten by the B4A editor

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim YOYO As IOIO
    Dim led As DigitalOutput

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim btnLED As ToggleButton
    Dim Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
    If FirstTime Then
        YOYO.Initialize
        YOYO.WaitForConnect()
        led = YOYO.OpenDigitalOutput( 0,led.OP_NORMAL ,True) ' Enable LED_PIN for output
    End If
End Sub

Sub Activity_Resume
    Label1.Text =Label1.Text & ". LIB Ver: " & YOYO.GetIOIOVersion(YOYO.VER_IOIOLIB)

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    If UserClosed Then
        led.Close
        YOYO.disconnect()
    End If
End Sub

Sub btnLED_CheckedChange(Checked As Boolean)
    'led_.write(!button_.isChecked());
    led.Write(Not (btnLED.Checked)) ' Turn on/off stat LED, active LOW
End Sub


tambien lo puedes descargar de la primera pagina de este foro, cabe mencionar que la comunicación la quiero hacer por USB y con Bluetooth
 

macsboost

Member
Licensed User
Longtime User
Can anyone share an example reading multiple analog channels at the same time? What would be the preferred method?
 

macsboost

Member
Licensed User
Longtime User
I am attempting to read multiple analog inputs for 20-100 samples simultaneously, then service the buffers at 10hz with a timer, and filter the results to have a high resolution stable readout on five gauges that update at 5hz. am I headed down the right path?
 

kolbe

Active Member
Licensed User
Longtime User
I am attempting to read multiple analog inputs for 20-100 samples simultaneously, then service the buffers at 10hz with a timer, and filter the results to have a high resolution stable readout on five gauges that update at 5hz. am I headed down the right path?

The only "simultaneous" command the library has is the batch command and that only works for digital writes. The analog read sample rate set in firmware is 1KHz. Using the analog buffer read you shouldn't have much of a problem getting 5Hz. You're best bet is to use a nice fast android device and stick with USB connection. Be aware the USB connection doesn't work for android 4.1 and above. This might actually work well enough even with BT. If you are trying to get precise timing, a reading every 100ms or whatever, this is not the platform for you, too much lag and jitter between the IOIO and the device, plus android is not designed to be real-time. I'd recommend a picaxe or arduino if you need precise timing. You can always then interface it with the IOIO and have the best of both worlds.
 

kolbe

Active Member
Licensed User
Longtime User
revise tu ejemplo y me marca un error en la linea 57
B4X:
Dim caps As CapSense
, a que librería pertenece esta declaración de variable

¿has solucionado tu problema? Para el problema que tu mencionas aquí, necesitas el firmware v4 para la ioio
 

kolbe

Active Member
Licensed User
Longtime User
Try
B4X:
in = IOIO.openDigitalInput(37, in.Spec.Mode.PULL_DOWN)
[/quote]

Ignore the quote above... just trying to get your attention.

After changing to the new forum software, the link you created to my libraries from your post #1 to post #105 no longer works. Could you please fix this. Thanks
 
Top