Cooking Hacks Forum
https://www.cooking-hacks.com/forum/

Xbee modules
https://www.cooking-hacks.com/forum/viewtopic.php?f=59&t=10723
Page 1 of 2

Author:  Nour_Neifar [ Fri Oct 06, 2017 9:29 am ]
Post subject:  Xbee modules

Good morning,

I'm working with my Signals HW V1. I tried to use the Xbee modules to send the data of sensors but the modules of xbee are not working. I tried a basic exemple( light lamp of arduino ) to verify if they are ok or not but no result. The 2 modules could not send or receive data. When i used other Xbee modules they work fine. Does that mean my Xbee modules are defective ?
Have you got any solutions to solve this problem ?

Here is some pictures:
https://photos.app.goo.gl/xsbJZT9ya57EE1pJ3
https://photos.app.goo.gl/fWgYbypK90Y2RDwZ2

Thank you.

Author:  libelium-dev [ Mon Oct 09, 2017 8:07 am ]
Post subject:  Re: Xbee modules

Hi Nour_Neifar,

If you want to use the XBee modules, you need to use tge Libelium expansion board that allows your MySignals board to communicate wirelessly using Xbee.

Image

https://www.cooking-hacks.com/shop/wire ... 5-4-zigbee

Regards

Author:  Nour_Neifar [ Mon Oct 09, 2017 10:43 am ]
Post subject:  Re: Xbee modules

Good morning,

To verify if my Xbee modules work or not i used two arduino board without Mysignals shield (a transmitter and a receiver) but no result, no data transmitted. I changed the role of the 2 modules (the transmitter become the receiver and the receiver become the transmitter ) but no result also.
Is the problem with the Xbee modules ? Are they defective ?

Thank you

Author:  libelium-dev [ Tue Oct 10, 2017 7:24 am ]
Post subject:  Re: Xbee modules

Hi Nour_Neifar,

Here you have got a small tutorial to know how to configure the XBees:

https://www.cooking-hacks.com/documenta ... -tutorial/

Also, here you have got a x-ctu tutorial:

http://www.libelium.com/development/was ... -tutorial/

It seems that you have got the modules with a wrong configuration.

Regards

Author:  Nour_Neifar [ Wed Oct 11, 2017 11:20 am ]
Post subject:  Re: Xbee modules

Good morning,

I tried to follow the tutorial to configure the XBees. I uploaded the Communication | Physical Pixel sketch to one of the boards. I have tested it by connecting to the board with the Arduino serial monitor typing an H, and pressing enter. The LED turn on, Sending an L the LED turn off.
( the both jumpers on the shield are in the "USB" setting ) (I used an arduino M0 board and a Multiprotocol Radio Shield v2.0)

Then i uploaded the other sketch to the other board (jumpers are in the USB setting) and it's working. (I used an arduino Due board and a Multiprotocol Radio Shield v2.0)

Now i Switch the jumpers to the XBee setting on the two boards. I connect both boards to the computer. But the LED on the first board doesn't turn on and off.

Here is a picture of my two Arduino boards with XBee shields.
https://photos.app.goo.gl/zXe0LsyBhsaqboUj2

I don't know what is the problem.

Thank you

Author:  libelium-dev [ Mon Oct 16, 2017 8:07 am ]
Post subject:  Re: Xbee modules

Hi Nour_Neifar,

Our Xbee tutorials are developed to use with the XBee shield, not with the Multiprotocol, you will need to modify the codes to work with them.

Also, the Arduino M0 is quite different to the Arduino UNO, we have never tested it.

Regards.

Author:  Nour_Neifar [ Mon Oct 16, 2017 11:07 am ]
Post subject:  Re: Xbee modules

Good morning,

You said If you want to use the XBee modules, you need to use tge Libelium expansion board that allows your MySignals board to communicate wirelessly using Xbee.
What should i do to start the module? Should i work with MySignals.expanderState of The 3G (expansion board) ??
What is the code to use to send data from the Xbee in MySignals board to the other Xbee which will receive data?

The receiver Xbee is connected to the arduino with a Xbee_adp ( not usb adapter so i can't do the configuration with XCTU) and i have not an ArduinoXBee shield.

https://photos.app.goo.gl/YWybWx2krTPcaXtG3

Regards.

Author:  libelium-dev [ Tue Oct 17, 2017 7:22 am ]
Post subject:  Re: Xbee modules

Hi Nour_Neifar,

Nour_Neifar wrote:
What should i do to start the module? Should i work with MySignals.expanderState of The 3G (expansion board) ??


Correct, you need to use the same functions that allow the 3G/GPRS board to switch ON. Then you can send the command to the XBee module.

Nour_Neifar wrote:
What is the code to use to send data from the Xbee in MySignals board to the other Xbee which will receive data?

You don't need a specific code. Once you have paired both XBee's all the data that you send to one XBee the other receive the same data.

Regards

Author:  Nour_Neifar [ Tue Oct 17, 2017 1:17 pm ]
Post subject:  Re: Xbee modules

Good morning,

1) In order send command from mySignals HW v1 to Xbee i used this code. But answer is always 0 and it's sending AT every 2 seconds. This module does not start.

#include <MySignals.h>
#include <Wire.h>
#include "SPI.h"

void setup()
{
//Write here you correct baud rate
Serial.begin(115200);

MySignals.begin();

//Enable 3G module power -> bit0:0
bitClear(MySignals.expanderState, EXP_3G_ON);
MySignals.expanderWrite(MySignals.expanderState);

MySignals.initSensorUART();
MySignals.enableSensorUART(EXPANSION);


delay(2000);

// checks if the module is started
uint8_t answer = sendATcommand("AT", "OK", 2000);
if (answer == 0)
{
delay(3000);
// waits for an answer from the module
while (answer == 0)
{
// Send AT every two seconds and wait for the answer
answer = sendATcommand("AT", "OK", 2000);
}
}
MySignals.println("Connecting Xbee");
sendATcommand("AT+ATID?", "OK", 6000);
sendATcommand("AT+ATSH?", "OK", 6000);
sendATcommand("AT+ATSL?", "OK", 6000);

delay(1000);
}

void loop()
{
delay(5000);
}

int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout)
{

uint8_t x = 0, answer = 0;
char response[500];
unsigned long previous;

memset(response, '\0', 100); // Initialize the string

delay(100);

while ( Serial.available() > 0) Serial.read(); // Clean the input buffer

delay(1000);
Serial.println(ATcommand); // Send the AT command


x = 0;
previous = millis();

// this loop waits for the answer
do {

if (Serial.available() != 0)
{
response[x] = Serial.read();
x++;
// check if the desired answer is in the response of the module
if (strstr(response, expected_answer1) != NULL)
{
answer = 1;
MySignals.println(response);
}
}
// Waits for the asnwer with time out
}
while ((answer == 0) && ((millis() - previous) < timeout));

return answer;
}


This is a screen shoot of the outout of this code.
https://photos.app.goo.gl/wCxtSRPnvLW5aFgk2

Have you got any idea about this problem?

2) If i want to send data from the shield to Xbee should i use this code ?:
String toSend="abc";
int len =toSend.length();
String lengt=String(len);
String cmd="AT+CIPSEND=";
cmd+=lengt;
sendATcommand(cmd,"OK",20000);
sendATcommand(toSend,"OK",20000);

3) Can i pair the 2 Xbee with using AT command by defining the XBee Destination
Address on the first Xbee and by defining The the same ID and CH parameter for both xbee?

Regards.

Author:  libelium-dev [ Wed Oct 18, 2017 8:22 am ]
Post subject:  Re: Xbee modules

Hello Nour_Neifar,

please try this code, if it doesn't work, change the baudrate to 115200.

Code:
#include <MySignals.h>
#include <Wire.h>
#include "SPI.h"



void setup()
{
  //Write here you correct baud rate
  Serial.begin(9600);

  MySignals.begin();

  /*
    expanderState is initialized with B10100001

    Expansor pin library names:

    EXP_3G_POWER
    EXP_ESP8266_POWER
    EXP_BT_POWER
    EXP_BT_KEY
    EXP_ADC_CS
    EXP_BLE_FLOW_CONTROL
    EXP_BLE_POWER
    EXP_ROVING_POWER
  */

  //Enable expansion board power -> bit7:0
  bitClear(MySignals.expanderState, EXP_ROVING_POWER);
  MySignals.expanderWrite(MySignals.expanderState);

  MySignals.initSensorUART();
  MySignals.enableSensorUART(EXPANSION);


  delay(2000);

  if (enterConfig(2000))
  {
    MySignals.println("XBee OK");
    delay(1000);

    int8_t answer = sendCommand("AT", "OK", 2000);
    if (answer == 1)
    {
      MySignals.println("AT OK");
    }
    else
    {
      MySignals.println("AT no OK");
    }


  }
  else
  {
    MySignals.println("XBee no OK");
  }
}

void loop()
{
  delay(5000);
}




int8_t sendCommand(const char* Command, const char* expected_answer, unsigned int timeout)
{
  char response[300];
  uint8_t x = 0,  answer = 0;
  unsigned long previous;

  memset(response, 0, sizeof(response));    // Initialize the string

  delay(100);

  while ( Serial.available() > 0) Serial.read();   // Clean the input buffer

  Serial.println(Command);    // Send Command

  x = 0;
  previous = millis();

  // this loop waits for the answer
  do
  {
    if (Serial.available() != 0)
    {
      // if there are data in the UART input buffer, reads it and checks for the asnwer
      response[x] = Serial.read();
      x++;
      // check if the desired answer  is in the response of the module
      if (strstr(response, expected_answer) != NULL)
      {
        answer = 1;
      }
    }
  }
  // Waits for the asnwer with time out
  while ((answer == 0) && ((millis() - previous) < timeout));

  return answer;
}


int8_t enterConfig(unsigned int timeout)
{
  char response[100];
  uint8_t x = 0,  answer = 0;
  unsigned long previous;

  memset(response, 0, 100);    // Initialize the string

  delay(100);

  while ( Serial.available() > 0) Serial.read();   // Clean the input buffer

  Serial.print("+++");    // Send Command


  x = 0;
  previous = millis();

  // this loop waits for the answer
  do
  {
    if (Serial.available() != 0)
    {
      // if there are data in the UART input buffer, reads it and checks for the asnwer
      response[x] = Serial.read();
      x++;
      // check if the desired answer  is in the response of the module
      if (strstr(response, "OK") != NULL)
      {
        answer = 1;
      }
    }
  }
  // Waits for the asnwer with time out
  while ((answer == 0) && ((millis() - previous) < timeout));

  return answer;
}




Regards

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/