Serial block component

Hello,
It is a nice component.
I’m (almost successfully) using it with ESP8266 and CP2102 (TTGO board).
It works fine with 9600bps but not with 115200bps. It looks like baud rate is not being set with BaudRate property… just a guess…

Thank you!

Good to read that you connected the ESP8266 with the Serial1 extension
Can you post the blocks you used to connect, please ?

Sure!
I was testing the baud rate setting so it is set in Screen.Initialize. Setting it in design view also works.

Serial.aia (3.3 KB)
Glad to help.

Thanks for sending the aia file.
On attaching the Arduino Uno, access to the app is requested (see screenshot), but not when the ESP8266 is attached. I don’t think that the CH340 chip is accepted by the Serial extension.

2 Likes

Thanks for the information. :slight_smile:

Hi,
Doesnt work for me!
I’m directly looking the output of my usb-otg of my phone with an oscilloscope.
When I press the button in my test app, I have a short notification thad says “Wrinting : TEST” but nothing on any pin of the USB.
Maybe it needs more than Android 4.4 ?

tried a lot - without success - with the nano - now I understand - sad but true :wink:
the uno is bigger than the phone so some mobile applications wont make sense
but I'll try a uno if the programming will work as intended

Another option is an ESP32 dev board, which has Bluetooth to connect to the mobile phone.

With an UNO and an OTG adaptor USB-C -> USB-A the serial blocks works very fine

grafik

Just send some ASCII chars to the arduino e.g. 'A' for set a pin high / 'a' for low thats working perfectly reliable

may to try not an arduino but an RS232 cable with FTDI chip instead:
https://www.adafruit.com/product/4364 but around factor 10x too expansive :wink:

So - some experiments later... :wink:
UNO works fine - all other attempts didn't work - tried several usb/rs232 adapers - and a bare FTDI chip (FT232RL) which all were recognized with the app 'serial USB terminal 1.38' but not with the app inventor projects...

for the FT232RL i get following error message:
'Failed resolution of: Lcom/ftdi/j2xx/D2xxManager;'
which could be interpreted as 'want to work with but cannot work with'

is there a update in pipeline to support more serial devices? would extend the opportunities for so many new (low cost) projects :wink:

Maybe you can try my extension and report if it works for you::

What is the 'set Status . Text' Block? I get that it's purpose is to open the serial communication, but what type of component is 'Status' and what did you chose in Designer to add that in?

THank you!

the last row in the 'connect' block is just to call the 'open serial'
'status' is a label (text field) on the frontpanel that gets the return message from the 'open serial' which can be true or false

there is a fantastic solution contributed by rkl099

he implemented an extension over the last months you can find on github:

and follow the discussion here

it works with arduino nano clones (CH340) as well as FTDI Serial adapters

here a basic test program for input/output by clicking buttons:

Hi. Have you figured it out how to set different baudrate than 9600?
For me it works only at 9600
Michał

Hi!
There's a long time I don't visit this thread.
I didn' t try these settings but...
Michal, have you tried changing Serial1.baudRate variable?
There is a set of allowed values which depend on hardware and software. Usual values are: 9600, 14400, 28800, 57600, 115200, ...
Hope this helps.
Fábio.

Are you using SerialOTG?
What device are you trying to connect to?

Hi @Diego I really hope that you can help me.
I am using appinventor to command an arduino uno wifi rev 2 that has to drive an attached servo motor. My commands in the app are a calibration and a turning on and of some modalities of driving. All is work properly!
What I need is to see inside a window of the app what I can see in the serial monitor of arduino. Indeed, the code has many Serial.println. How can I do?

Thanks

Hi Django.
Where your sketch uses the Serial.println statement, send the same data to the port that is in communication with the Android device. In the app, read the received data and display it in a label.

What is the comms channel between the Android device and the Uno? Is it wifi?

Nope @NissanCedric. Thank you firstly! By the way, I show you my superficial code and a draw of the system. All is setted to 57600 baud rate. I can't avoid it because this is the standard for dynamixel.
By the app , I can only send A and B. I can read the output only if I open the serial monitor at pc and if I connect the arduino via USB to the pc. It work perfectly .
I want the same stuff but with the Bluetooth at [7,8] pins

#include <SoftwareSerial.h>  //comunicazione Bluetooth

SoftwareSerial BTSerial(7,8);

#include <Arduino_LSM6DS3.h> //accelerometro
#include <DynamixelShield.h> //attacco DXL

//SETUP DXL
const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;
DynamixelShield dxl;
//This namespace is required to use Control table item names
using namespace ControlTableItem;
#define DEBUG_SERIAL Serial

int Object_position_A;
int Object_position_B;
int walk_state;
int read_acc;
int state_Athr=0;
int state_Bthr=0;

float x,y,z,Athr,Bthr;

void setup() {
DEBUG_SERIAL.begin(57600);
delay(1000);
BTSerial.begin(57600);
delay(1000);
IMU.begin();
delay(1000);
dxl.begin(57600);

// Set Port Protocol Version. This has to match with DYNAMIXEL protocol version.
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);

// Turn off torque when configuring items in EEPROM area
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);

// dxl.torqueOn(DXL_ID);
DEBUG_SERIAL.println("Connect the device via bluetooth") ;

}

String line;
void loop() {
if (BTSerial.available()){
line = BTSerial.readStringUntil('\n');
}

// WALK MODE
if(walk_state==0 && line == "1"){
dxl.torqueOn(DXL_ID);
DEBUG_SERIAL.println("FUNZIONE ABILITATA");
walk_state=1;
read_acc=1;
DEBUG_SERIAL.println(Athr);
DEBUG_SERIAL.println(Bthr);
}
if(read_acc==1){
IMU.readAcceleration(x, y, z);

                      DEBUG_SERIAL.print("X:");
                      DEBUG_SERIAL.print(x);
                      DEBUG_SERIAL.print(",");
                      DEBUG_SERIAL.print("Y:");
                      DEBUG_SERIAL.print(y);
                      DEBUG_SERIAL.print(",");
                      DEBUG_SERIAL.print("Z:");
                      DEBUG_SERIAL.print(z);
                      DEBUG_SERIAL.print(",");
                      
                      DEBUG_SERIAL.print("\t");
                              if (y<A_thr ){         
                                                dxl.setGoalPosition(DXL_ID, Object_position_A,UNIT_DEGREE);
                                                delay(100);
                                                DEBUG_SERIAL.println("A setted");
                              }
                              else if(y>B_thr ){                        
                                                   dxl.setGoalPosition(DXL_ID, Object_position_B,UNIT_DEGREE);
                                                  delay(100);
                                                  stance=0;
                                                  swing=1;
                                                   DEBUG_SERIAL.println("B setted");
                              }
                              else {
                                              
                           }
                 }

if(walk_state==1 ){
dxl.torqueOff(DXL_ID);
DEBUG_SERIAL.println("FUNZIONE DISABILITATA");
walk_state=0;
read_acc=0;

}
}