Sensor reading, bluetooth data reading

All correct. Any ideas on why this is happening?

No, but we can first find out if anything at all is received by the App by temporarily dumping the DataRecieved into the Label_Msg. Change this block by adding the code outlined:

A hardware question for you - how is your UNO being powered? How many milliAmps is it getting?

It is powered by the USB port on my pc, I can't tell how much is it. sorry

EDIT: nothing shows up... it says connected, but no data :frowning:

OK. This may not be 'it' but it is worth trying.

It's possible that there isn't enough power for the UNO. I found this with mine when powered from a PC USB. In fact, on any PC, not all USB ports have enough power to charge your fitness watch for example.

If you don't have a multi-meter to check, do you have an AC to DC Power Adaptor? 9v to 12V max DC output, at least 300mA to 1A max current output. It could have a 2.1mm diameter plug which is centre pin positive, or USB. Another alternative would be a battery pack.

can't I use a powerbank 5V 1A DC? I don't have such power adaptor, all power adaptor I have are 5V 1A DC.

what about this way? What should I do? I can always give a try

You can try your powerbank. The Amperage is OK but the voltage is low. Probably outperforms your PC USB though. :grin:

If you have a battery pack that can output between 9v & 12v with 300mA to 1A, that would be better.

It turns on... but no data.

How should I connect the battery pack to arduino?

Depends on the cable of the pack, 2.1 connector or USB.

.... but I have spotted an omission from the Sketch! Give me a couple of minutes.

Right - no pin mode set in the Sketch! Also, set the baud rate a bit lower.

Read_DHT11.txt (1.9 KB)

Chris. I will never be able to thank you for this help. If it won't work, I'll find another way.
For now, I'll try the battery pack way, it is more efficient than the adaptor for what are my needs.
Do I need some kind of shield? or the onboard fuse is enough?

It's important that the Power Source is simply within the Volt/Amp spec, then there is nothing to worry about.

....... You will need a good power supply, but right now the PC USB power could be enough - the Sketch had a fault (my bad again) so I'm hoping for better results with the fixed version I just uploaded.

Dear @ChrisWard,
I'm almost sure that the HC05 is still set into its default baudrate, which is typically 38400 bps.
But are we sure that it has been paired correctly ?
There are some HC05 clones that are very unfriendly :frowning_face:
I have collected in the past some hints that I've found on the web when I was getting crazy in trying to make them working.
The annexed pdf contains that collection.

@Noobie
please take a look on it, mainly the last two pages.
So before trying to code the AI2 app, verify whether your BT is really sending data to your phone.
Load on the phone a serial BT monitor app (Serial Bluetooth Terminal is a pretty good one) and try to pair the HC05. Once paired you should see the red LED of the shield to stay steady or to blink slowly (it depends upon the shield firmware version :upside_down_face:): until you don't get this step, you will never know if it is the app, the skecth or the HW that isn't working.
HC06 Connection_3_3VDC.pdf (714.6 KB)
Also don't care if my notes are relevant to the HC06, the same applies to the HC05 "clones".
Never give up!!!

1 Like

Hard to find a definitive rate. 38400 is generally for AT mode. The two most popular that I found were 9600 and 19200. App Inventor Apps have reliability issues with very high rates.

The address list produced by MIT's BT Client only includes paired devices. Noobie's device does get listed and connection is confirmed by the App. The confirmation is reliable with Android 4.0.4 and up. Samsung Galaxy A52 is Android 11 or 12. There might be a Google Security issue.

Edit: So in this case, we know the devices are paired.

1 Like

Agree with above. Both 9600 and 38400 are mentioned in my documentation. (38400 for AT mode if you need to change HC05 parameters)

I would begin to test the hw HC05 by simply connecting rx and tx. Then use the bt terminal, pair the phone with HC05. Now check that what you type will be sent back (echo).

Then make a simple Arduino sketch to read a char and then write it back to the HC05, to check software serial, connection to the Arduino and baudrate.

When this is ok, write a simple app in AI to send a char and read it back. When all this works, then you can start to test your real application, step by step.

1 Like

Hi @ChrisWard ,
definitely agreed, if the phone has the HC05 paired, this means that the phone is linked to the HC05, but this does not mean that the Arduino is effectively sending data to the shield.

As far as : App Inventor Apps have reliability issues with very high rates", is concerned, honestly I had different experiences: for example in my OBDII app, I exchange data @115200 from my Arduino Mega to the HC05. The AI2 app that receives the data from BT has no problem at all. I don't miss any character. And I update the data shown by the app every 250 milliseconds. I need such updating speed to avoid flickering. in addition, in my understanding the BT speed is much faster (typically transfer rate is roughly 0.25 MB/second).
Anyway, when I have troubles in finding the correct baudrate between Arduino and shield, I use this chunk of Arduino code:

#include <avr/io.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
String command = ""; // Stores response of the HC-06 Bluetooth device
long baud = 115200;

void setup()
{
// Open serial communications:
Serial.begin(115200); // to PC monitor
Serial.println("Checking communication to HC-06");
mySerial.begin(baud);
mySerial.write("AT\r\n");
delay(800);
if(mySerial.available())
{
while(mySerial.available())
{ // While there is more to be read, keep reading.
command += (char)mySerial.read();
}
}
Serial.print("Received: ");
Serial.println(command);
mySerial.write("AT+UART?\r\n");
delay(800);
if(mySerial.available())
{
while(mySerial.available())
{ // While there is more to be read, keep reading.
command += (char)mySerial.read();
}
}
Serial.print("Received: ");
Serial.println(command);
delay(800);
}

void loop()
{
// nothing to do
}

If it does not work, I reduce the baudrate to 57600, then 38400, then 19200, then 9600, until it works.

@Noobie where are you ?

1 Like

Hi @rkl099,
I'm absolutely with you: before trying anything else we must be sure that a "simple" communication works between Arduino and the phone. To this purpose I suggested to use a Serial BT monitor App. Let's see what happens ... :smiley: :smiley: :smiley:

That's very handy code Uskiara, which we can put to good use in this case.

The reliability issues may well be influenced by other factors too - since we never have the exact setup in our hands when helping we are very reliant on people's diligence.

...and that's where Noobie comes in. Not currently a confident programmer and has unintentionally got little things wrong even under careful guidance. Has been a very willing learner though and that's why I put together a packaged solution for Noobie to test with. However, my hardware is in mothballs (building work in the house) so I could not test the Arduino side. The Sketch I wrote compiled but it had an error.

So I don't want Noobie to try anything else until the corrected Sketch is tested, as that is the easiest task for him/her. If it fails, then I would like Noobie to use your code to establish the correct baud rate for the HC-05.

What we don't know - is the hardware setup 100% correctly.

1 Like

Hi @ChrisWard,
Yep, the HW/SW integration can be done as a Big-Bang or as a step-by.step.
The latter being the best approach (for me) to avoid big burnt of pcb's (and headaches). :face_with_head_bandage:
Keep in touch,
Ugo.

1 Like