Arduino to Arduino by Bluetooth


hello!

i've got hm-10 bluetooth module. i've pulled putty , @ at kommand "at" "ok" in regards works. want 2 of them talk each other, , i'm having problems.

to accomplish use softwareserial library, , copy pasted example code. stuffed somewhere, because not work. i'll post code , maybe spot it:

node 1, sending data:
code: [select]
#include <softwareserial.h>

// 10 - goes hm-10 module pin marked "tx"
// 11 - goes hm-10 module pin marked "rx"
softwareserial btserial(10, 11); // rx | tx

void setup()
{
  // setting serial com pc
  serial.begin(9600);

  // setting serial hm-10 module
  btserial.begin(9600);

  // init complete
  serial.println("init done!");
}

void loop()
{
  // outputting know it's doing _something_
  serial.println("writing data...");

  // write simple data hm-module
  btserial.write("foo");

  // sleeping 1s before going @ again...
  delay(1000);
}


node 2, receiving data:
code: [select]
#include <softwareserial.h>

// 10 - goes hm-10 module pin marked "tx"
// 11 - goes hm-10 module pin marked "rx"
softwareserial btserial(10, 11); // rx | tx

void setup()
{
  // setting serial com pc
  serial.begin(9600);

  // setting serial hm-10 module
  btserial.begin(9600);
  btserial.listen();

  // init complete
  serial.println("init done!");
}

void loop()
{
  // checking if there data on hm-module, ifso output it
  if(btserial.available())
  {
    serial.println("got data!");
    serial.println(btserial.read());
  }
}


"got data" never appears :'(. these 2 arduino uno. leds on bluetooth module blinking steady. got idea?

okey, got them working!

i had put 1 in "central" mode, in sense have have 1 "master" , rest "slave". works in project since i'm making hub works api , communicates other nodes/slaves.

i achieved writing "at+role1" "master" device.

but got problem... (thats development ya'll). while working, how send @ commands? before connected use btserial.write("at..."), when connected making mcu write "at..." outputs command on wire! haha!
so; while connected cant sleep because cant send @ commands device connect , write command on wire instead of executing it.

any clue?


Arduino Forum > Topics > Home Automation and Networked Objects > Arduino to Arduino by Bluetooth


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts