Arduino Project with spark fun WRL-11812 and Xbee S2C #602-1858-ND

Okay guys I hope this is allowed here. It’s my 1st post and is about a project. I’m a rookie with this programming and component selection. There’s not a lot in the search results for how to link the arduino with the spark fun WRL-11812. Here’s a step-by-step outline of what I am trying to accomplish.

I want to program the xbee with spark fun WRL-11812 and then leave it on a breadboard as a “hat” on an arduino. The arduino and WRL-118212/Xbee will remain on the bread board and be linked together through the board and jumper wires. The purpose of the setup will be to fire an external relay. This relay will turn on a drier fan. This fan and relay are existing. This is a large 240VAC 70A fan. Today it’s triggered with a 120V signal being turned on through a regular 120 switch at 10-15A- nothing special. Here are the steps listed more explicitly and in a linear fashion:

1.) An Arduino powered with 7V 2A and Xbee with the WRL-11812 will be on a breadboard.

2.) At my choosing I will send a command from a home server from the signal xbee (SB) to the receiver xbee (RB).

3.) RB’s output pin can’t supply enough voltage to meet my relay’s minimum trigger voltage (3V) reliably from what I read, so I’ll use the Xbee’s max 2.7V output to send signal to an input pin on the arduino. When the arduino sees the input pin as HIGH it will then send a 5V output from another pin to my fan relay, and the fan will turn on. I will drop signal from the xbee from the same server when I want to turn the fan off.

4.) I would like to manage this through putty and openhabian via a raspberry pi home MQTT openhabian server. It would be ideal to be able to send this signal from the home raspberry pi/ openhabian server and openhabian app on my phone. The SB will be on a breadboard that has a 3V power supply on it that powers the Xbee. This SB is the inerface between the server and the RB- I think???

I am a no0b in all respects and need some guidance. Thanks.

I have additional information. Here is an email I sent to the sparkfun support email address:

Spark Fun Team,
These are not configured with the newest firmware, but I’ve tried the same setup with newest firmware v2003, older firmware, and on older firmware in the general Zigbee function set with the same results. In the general Zigbee function set the “end device” can be configured as a “router.” This is how most videos configure their end devices. I’ve tried that, but the behavior was the same in that the devices communicated through their terminal when hooked up to the PC, but seemingly do not communicate wirelessly through Arduino. Hardware involved is:
1.) Elegoo Arduino Uno (x2)- running all the latest firmware through Arduino IDE. Libraries are the latest.
2.) Digi Xbee S2C Model: S2CTH (XB24CZ7WITB003) (x2)
3.) Sparkfun explorer board #WRL-11812 (https://www.sparkfun.com/products/11812 ) (x2) I soldered the header pins on to be able to plug it into a breadboard.
Here’s the video ( https://www.youtube.com/watch?v=J5lw0Zq … e=youtu.be ) that does a very nice job explain the hardware setup and the program setup of the system. I’ve found this example most helpful for testing, and it is also probably very close to what I need in the end if the system is to not operate on a server. I have conceded server operation at this point given the time constraints. There are at least two additional interfaces and protocols I’d have to fight to get that working. I think I’ve included all the pertinent information for you to investigate. Please note the MY (16-bit source address) parameters in the .xpro files I’ve attached do not match those shown in the video, but I have tried his exact setup with no luck.
I can only get the two devices to communicate through the XCTU software terminal when the devices are hooked up to my PC via their USB ports on the sparkfun board. When powered through the Arduino they don’t do anything. Do I have to changed a parameter to enable receipt and transmission of serial data through the sparkfun board’s DOUT and DIN pins? I’m powering the XBee via your dev board’s 5V pin. Is this ok? DO the DOUT and DIN pins need to be configured to read a particular voltage coming from the Arduino serial software pins 2 & 3 or from the RX and TX pins?

Here’s my arduino coordinator code:

#include <SoftwareSerial.h>;
#include <XBee.h>;

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 7;    // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin

// Variables will change:
int ledState = HIGH;         // the current state of the output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers


SoftwareSerial XBee(2,3);//RX, TX

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  XBee.begin(9600);

  // set initial LED state
  digitalWrite(ledPin, ledState);
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH), and you've waited long enough
  // since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer than the debounce
    // delay, so take it as the actual current state:

    // if the button state has changed:
    if (reading != buttonState) {
      buttonState = reading;

      // only toggle the LED if the new button state is HIGH
      if (buttonState == HIGH) {
        ledState = !ledState;
      }
    }
  }

  // set the LED:
  digitalWrite(ledPin, ledState);
  XBee.write(ledState);
  Serial.print(ledState);

  // save the reading. Next time through the loop, it'll be the lastButtonState:
  lastButtonState = reading;
}

Here’s the code for the receiver/end device arduino:

#include <SoftwareSerial.h>;
#include <XBee.h>;

SoftwareSerial XBee(2, 3);

int data= 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  XBee.begin(9600);
  pinMode(7,OUTPUT);
}

void loop() {{
 
  while(XBee.available())
  
    data = XBee.read();
    Serial.print(data);
}   
  if(data== 1){
    digitalWrite(7,HIGH);
  }   
    if (data == 0){
    digitalWrite(7,LOW);
 }
}

The Xbee is plugged into a breadboard via the sparkfun WRL-11812 with the DIO pins 2 & 3 from the elegoo arduino uno lining up with the DOUT and DIN pins for the explorer board. I’m wondering if not having level shifting on the sparkfun explorer is causing me issues. I didn’t initially think it was a problem. I can see data from the arduino in the coordinator XCTU terminal when the XBEE and arduino are powered via the usb cord into the sparkfun explorer board, but I’m just looking at hardware now. I’m at a total loss.

Here’s a demo to use XBees like a wireless switch, does it help?

https://www.digi.com/resources/examples … witch-xbee