Android communications

Started by Tinine, July 01, 2023, 16:44:33

Previous topic - Next topic

Tinine

Does SmallBASIC utilize the Bluetooth and/or USB to connect with, say, microcontrollers?

Craig

J7M

Haven't tried yet, but you can use an usb-otg adapter to connect an Arduino with your Android device. Then you can transfer data using rs232.
If your microcontroller is connected to a network, you can use tcpip sockets for communication. Works very well with Raspberry pi.
See OPEN() for examples for rs232 and socket communication.

Tinine

#2
Oh, I have been shipping control systems for the past 11years where a microcontroller is commanded by a ruggedized Android tablet. I have been using B4A (by Anywhere Software) and RFO BASIC and use Bluetooth for comm's.

I don't care for Arduino, BTW. Today I use the Parallax Propeller (FlexBasic compiler) and the Picomite (RPi Pico with MMBasic interpreter onboard).

I only use the Android device as a HMI, all the critical stuff is handled by the microcontroller(s). It's a great solution because I constantly come across critical production machinery that is dead for the sake of failed screen or keypad. Production lines can be down for days/weeks and a replacement screen can be $4,000. With an Android device, simply load the app and pair/connect the Bluetooth. 8)

Picomite (Basic interpreter with onboard editor)


Tinine

#3
Quote from: J7M on July 01, 2023, 23:12:55Haven't tried yet, but you can use an usb-otg adapter to connect an Arduino with your Android device. Then you can transfer data using rs232.
@J7M

Really interested in this possibility  8) What commands would I use in Android? Simply OPEN COM1?

Craig

J7M

Yes and no. I found this question on stackoverflow:
https://stackoverflow.com/questions/33845332/android-serial-communication-via-c-program
Unless you have rooted your Android device, it will most probably not work.

Tinine

#5
Ah, rooted is a problem because my end-users need to simply swap-out the device in the event of a failure and install the SB app.

I know that the IOIO stuff runs without requiring root and the B4A guys created a wrapper for it.

IOIO support with SmallBasic could open-up a world of external control. Don't know what's involved, though.

Craig

Edit: Just found this

Tinine

Or even Bluetooth support which is what I currently use with RFO BASIC to link with microcontrollers.

Android tablets make for awesome HMIs for industrial control systems  8)

chrisws

That all sounds pretty interesting. The Java API of IOIO wouldn't be too much of an issue. 

Tinine

Quote from: chrisws on December 01, 2023, 00:56:14That all sounds pretty interesting. The Java API of IOIO wouldn't be too much of an issue.

 
A combination of Android, SB and low-cost input/output devices (readily available) would constitute the most powerful and easy-to-program PLC (programmable logic controller) ever.
The cartel traditional suppliers of industrial controllers are pulling one heck of a scam. The car industry refers to this as "the new rust". Built-in obsolescence using on-board microcontrollers that convince the car owner that the vehicle needs repairs that can cost more than the residual value of the vehicle.  :D

The vast majority of failures that I come across with industrial process machinery is a dead UI. Proprietary and if not obsolete then ridiculously expensive. There is nothing more ubiquitous nor powerful than an Android device.
  • Processing power
  • GPU
  • Memory
  • Storage
  • Bluetooth
  • WiFi
  • Battery backup
I have been shipping industrial controllers for > 10 years where the Android device is the "front-end". I have relied on a BT link which has been totally reliable but for some clients, this is too much of a paradigm shift. They prefer a hardware solution (USB->Serial).

Industrially ruggedized tablets are showing-up, more and more on the plant floor.  8)


chrisws

Quote from: Tinine on December 04, 2023, 06:42:17
Quote from: chrisws on December 01, 2023, 00:56:14That all sounds pretty interesting. The Java API of IOIO wouldn't be too much of an issue.

 
A combination of Android, SB and low-cost input/output devices (readily available) would constitute the most powerful and easy-to-program PLC (programmable logic controller) ever.
The cartel traditional suppliers of industrial controllers are pulling one heck of a scam. The car industry refers to this as "the new rust". Built-in obsolescence using on-board microcontrollers that convince the car owner that the vehicle needs repairs that can cost more than the residual value of the vehicle.  :D

The vast majority of failures that I come across with industrial process machinery is a dead UI. Proprietary and if not obsolete then ridiculously expensive. There is nothing more ubiquitous nor powerful than an Android device.
  • Processing power
  • GPU
  • Memory
  • Storage
  • Bluetooth
  • WiFi
  • Battery backup
I have been shipping industrial controllers for > 10 years where the Android device is the "front-end". I have relied on a BT link which has been totally reliable but for some clients, this is too much of a paradigm shift. They prefer a hardware solution (USB->Serial).

Industrially ruggedized tablets are showing-up, more and more on the plant floor.  8)


So what early Christmas present would I need to buy :) - something like this? https://www.sparkfun.com/products/13613

How do you envisage the API? What would a blinking led SmallBASIC program looks like?

J7M

I checked IOIO a little bit more in detail. Really nice think. What I didn't fully understand yet, can it work also on the PC? What I like is, that IOIO comes with a serial interface. It would be simple to connect an Arduino or a Pi Pico to the Android device.

A minimal SB-API could be either the way IOIO is doing it in JAVA or like Arduino in the Arduino IDE. Arduino would have the advantage that people are more used to it. But probably it would be easier to stay with IOIO as described here: IOIOLib Core API ยท ytai/ioio Wiki (github.com) .

A SmallBASIC program using IOIO-like-API could look like this:

import IOIO as ioio                  ' Automatic connection to the IOIO board

Pin1 = ioio.openDigitalOutput(1)     ' Open pin 1 as digital output

for i = 1 to 10
 Pin1.write(0)                       ' Set pin 1 to low (LED off)
 delay(500)
 Pin1.write(1)                       ' Set pin 1 to high (LED on)
 delay(500)     
next

Tinine

I have been looking everywhere for my IOIO boards. I have the earlier and the newer version but never even plugged them in. I would happily forward them on.

Oh, we have UART, I2C, SPI, Device-charging, etc. and it's all open source. I already have ideas for expansion boards. No interest in Arduino though, we need to stick with BASIC and there are some awesome BASIC-programmable MCUs to add-on.

Here's what the other guys are doing.


Tinine

Quote from: J7M on December 06, 2023, 10:43:01I checked IOIO a little bit more in detail. Really nice think. What I didn't fully understand yet, can it work also on the PC?
Oh yes  :D

SB is gonna be attracting a whole new following  :D

chrisws

I've ordered the board, so that's a start :)

Tinine

Quote from: chrisws on December 08, 2023, 06:36:40I've ordered the board, so that's a start :)
Big excitement over here  :D 8) ;D

I have a controller board here (12 MCUs onboard). Testing phase right now. If SB can become the front end then WOW (watch out, world)
:D