B4R Tutorial HC 05 Classic Bluetooth

Status
Not open for further replies.

tigleth

Member
Licensed User
Longtime User
Hello

i am using the hc 06 and arduino micro which has serial1 and the b4r code seems running when i connect with Bluetooth terminal i see the millis; the b4a side errors on opening line 30 ... attempt to invoke virtual method ... null object reference

thank you
 

Cableguy

Expert
Licensed User
Longtime User
You should create a new thread in the questions sub forum, and also post a bit more info, specially as it seems to be B4A related too... If possible, the problematic sub should also be posted so that we can try to help you better
 

emexes

Expert
Licensed User
How do I send strings?
Probably like this sample:
B4X:
Sub Timer1_Tick
  astream.Write("Millis here: ".GetBytes)
  astream.Write(NumberFormat(Millis, 0, 0).GetBytes)
  astream.Write(Array As Byte(10)) 'end of line character. AsyncStreamsText will cut the message here
End Sub
from post #5 of this very thread.
 

rad

Member
Licensed User
Longtime User
The code from post #1 will only work on a device with multiple hardware serial ports, like Arduino Due or Mega.

The code from post #5 uses SoftwareSerial instead and will work on the Arduino Uno.
Hi Erel...

I have try the code form post #5, and the result is I can turn on and off the led from android via bluetooth.
The question is, on the image/photo from post #1 we can see that there is a message received from device (Millis here : 1987095), but why this message is not appear on my android application, it still wrote "Device Message:"
 

rad

Member
Licensed User
Longtime User
Hi Erel...
Previously, I have changed pins 10 and 11 to 0 (rx) and 1 (txt).

Just now, I try to restore it as you suggested, using pins 10 and 11 instead of 0 (rx) and 1 (tx) pins.
And the results are as I expected, work like a charm ....

Thank you very much for your attention to my question.
 

vali khandangoll

Active Member
It means that the data wasn't sent properly. Maybe the BT module is not connected correctly.
Hi all of you.
i use your code and connect zs-40 to UNO and see this error.
B4R Version: 3.00
Parsing code. (0.00s)
Building folders structure. (0.01s)
Compiling code. (0.01s)
Building project (0.04s)
Compiling & deploying Ino project (Arduino/Genuino Uno - COM12) Error
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
Uploading...
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x33
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x33
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x33
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x0d
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x0a
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x33
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x33
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x31
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x0d
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0a
An error occurred while uploading the sketch

there is not any different when connect
RX to 10 & TX to 11
or
revers.
and can not solve that.
 

tolisn

Member
Licensed User
Longtime User
Is there anyway to auto connect when the application opens without the need to press the "connect" button?
 

Beja

Expert
Licensed User
Longtime User
Hi Erel,
After many years I tried to run this app, but utterly failed. Here're the logs:

Looking for library 'user32'
Adding paths from jna.library.path: null
Trying user32.dll
Found library 'user32' at user32.dll
Looking for library 'shell32'
Adding paths from jna.library.path: null
Trying shell32.dll
Found library 'shell32' at shell32.dll
Looking for library 'Ole32'
Adding paths from jna.library.path: null
Trying Ole32.dll
Found library 'Ole32' at Ole32.dll
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
C:\Arduino\B4R\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Arduino\B4R\Arduino\hardware -tools C:\Arduino\B4R\Arduino\tools-builder -tools C:\Arduino\B4R\Arduino\hardware\tools\avr -built-in-libraries C:\Arduino\B4R\Arduino\libraries -libraries C:\Users\Control Acer\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin -warnings=null -prefs=build.path=C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -verbose C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\src\src.ino
C:\Arduino\B4R\Arduino\arduino-builder -compile -logger=machine -hardware C:\Arduino\B4R\Arduino\hardware -tools C:\Arduino\B4R\Arduino\tools-builder -tools C:\Arduino\B4R\Arduino\hardware\tools\avr -built-in-libraries C:\Arduino\B4R\Arduino\libraries -libraries C:\Users\Control Acer\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin -warnings=null -prefs=build.path=C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Arduino\B4R\Arduino\hardware\tools\avr -verbose C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\src\src.ino
Using board 'uno' from platform in folder: C:\Arduino\B4R\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Arduino\B4R\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Arduino\B4R\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\src.ino.cpp" -o "nul"
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\AsyncStreams.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RArduino.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RCore.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RSerializator.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RStream.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\ByteConverter.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\RandomAccessFile.cpp
Using cached library dependencies for file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\Scheduler.cpp
"C:\Arduino\B4R\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\b4r_main.cpp" -o "nul"
Generating function prototypes...
"C:\Arduino\B4R\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\src.ino.cpp" -o "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Arduino\B4R\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\AsyncStreams.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RArduino.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RCore.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RSerializator.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\B4RStream.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\ByteConverter.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\RandomAccessFile.cpp.o
Using previously compiled file: C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\Scheduler.cpp.o
"C:\Arduino\B4R\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Arduino\B4R\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\b4r_main.cpp" -o "C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\b4r_main.cpp.o"
C:\Users\CONTRO~1\Desktop\APKs\ADRUIN~1\B4RSAM~1\Objects\bin\sketch\b4r_main.cpp: In function 'void SerialNative1(B4R::Object*)':
b4r_main.cpp:18: error: '::Serial1' has not been declared
::Serial1.begin(9600);
^
b4r_main.cpp:19: error: '::Serial1' has not been declared
b4r_main::_serialnative1->wrappedStream = &::Serial1;
^
exit status 1
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…