atmega328p-PU and HC-05 BT module

Hello,
I have a problem that I currently can’t solve on my own. Hopefully someone here will be able to help me.

HC-05 module works fine (sends data) if it’s connected to Arduino UNO, but doesn’t work with Atmega328p-PU (BT device is visible and I can connect to it, but no data is received).

I have connected HC-05 BT module to atmega328p-PU by connecting:

  • 3.3v → LiPo battery’s + (if connected to Arduino, then 3.3v pin)
  • GND → GND
  • TX → Digital pin 10
  • RX → Digital pin 11
  • LED1 (Status) → Digital pin 7

Based on:
HC-05 pinout: https://developer.mbed.org/media/uploads/edodm85/x1-881-.jpg.pagespeed.ic.KWMSdIqAcB.jpg
Atmega328p-PU pinout: http://cdn.instructables.com/F2S/FHSD/H3Z3V3P4/F2SFHSDH3Z3V3P4.MEDIUM.jpg

And on Atmega I have a code:

#include <SoftwareSerial.h>// import the serial library

SoftwareSerial Genotronex(10, 11); // RX, TX

int led=13; // Blinking LED
int inPin=7; // Read HC-05 state

void setup() {
  Genotronex.begin(9600); //Baud rate 9600 was read with AT commands
  pinMode(led, OUTPUT);
  pinMode(inPin, INPUT);
}

void loop() {
     if(digitalRead(inPin) == HIGH)
     {
       delay(1000);
       digitalWrite(led, HIGH);
       delay(1000);
       digitalWrite(led, LOW);
       Genotronex.println("BT Test!");
     }
     else
     {
       pinMode(led, INPUT);
       int val = digitalRead(led);
       pinMode(led, OUTPUT);
       if (val != HIGH)
       {
          digitalWrite(led,HIGH);
       }
     }
}

What could be the problem? Why LED is working as it should, but I can’t receive any data from the BT module if it’s attached to Atmega?

P.S. I have a HC-05 BT module without base board.

How do you have your setup wired? How about a schematic? (hand drawn is fine)

Can you please share the schematic and layout of the board that your 328p is on as well?

The Uno and a barebones ATMega328p should be identical for this purpose, assuming you did everything the same way - so something is different.

. I am concerned that you say you were supplying 3.7-4.2 volts to a bluetooth module that is spec'ed as requiring 3.3 - that's probably too high for it, but I can't seem to find a real datasheet

Normally, you would check for serial data using the Arduino serial function "available( )".

Printing to the PC serial console helps with debugging. Try something like this...

void Setup() {
  Serial.begin(9600);
  SoftwareSerial gneotronex(10, 11);
  genotronex.begin(9600);
}

void loop() {
  if (genotronex.available() > 0 ) {
    int inByte = gneotronex.read();
    Serial.println( inByte );
  }
}

What does serial.available() have to do with it? He isn’t reading serial data in his sketch, only printing it.

It looks like all he’s doing is sending data to the BT module. But that should work on the standalone board - it should result in the bluetooth serial port spewing “BT Test” repeatedly.

I think this is almost certainly a wiring problem.

He is attempting to use the BT module's LED1 for determining when a serial data stream is available to read from his Atmega. I'm sure that's not the intent of the LED status light. He is also incorrectly using the serial console function "println()" to serially send data from the Atmega to the UNO.

I'm assuming his Atmega 328 has the Arduino bootloader and a serial connection to his PC for program uploading via a FTDI basic programmer. So I'm suggesting he can use the PC's serial console to debug his serial communications problem.

Very pleasant to see so many answers - thank you.

borland:
He is attempting to use the BT module’s LED1 for determining when a serial data stream is available to read from his Atmega. I’m sure that’s not the intent of the LED status light. .

Incorrect - LED1 is used to determine whether BT module is connected with some BT device or not. This part works flawlessly (judging by blinking of the LED and that it also works on Arduino). I put this part because otherwise when connection with a BT module is established, I received all previously sent, but not received data (because there was no device to receive it) in a single line. After this first line all further lines are as they should be: “BT test”.

borland:
He is also incorrectly using the serial console function “println()” to serially send data from the Atmega to the UNO

I’m not sending data from the Atmega to Arduino UNO. I’m trying to send “BT test” to any BT device that is connected to the HC-05.
If I have the same wiring and code on the Arduino (not Atmega), everything works great. If I change Arduino UNO to Atmega, nothing works - I can connect to HC-05, but I can’t receive anything. And Atmega understands that a BT connection is established - LED13 goes from ON to blinking.

DrAzzy:
I am concerned that you say you were supplying 3.7-4.2 volts to a bluetooth module that is spec’ed as requiring 3.3 - that’s probably too high for it, but I can’t seem to find a real datasheet

I tried to connect HC-05’s 3.3V and GND pins to Arduino, while leaving rest of the pins attached to Atmega - same situation, can connect to BT module, Atmega understands that, but I don’t receive anything.

And I also found:
VCC, voltage supply for logic, the standard voltage is 3.3V, and can work at 3.0-4.2V
Source: http://www.tec.reutlingen-university.de/uploads/media/DatenblattHC-05_BT-Modul.pdf
Paragraph 4, page 7

DrAzzy:
How do you have your setup wired? How about a schematic? (hand drawn is fine)
Can you please share the schematic and layout of the board that your 328p is on as well?

Schematics:

Please don’t be harsh about my drawings - fritzing doesn’t have a normal HC-05 without base board, that’s why I created these ones in Inkscape.

Bump: Just tried to power the HC-05 with LiPo while its TX and RX pins are connected to Arduino UNO - works great. So, it shouldn't be a power problem.

Do anyone have any ideas?

have a HC-05 BT module without base board.

I need schematic for making a bluetooth shield.

Please if anyone have help me. I really need this.