Go Down

Topic: Wiring Arduino Micro with Xbee Radio (Read 19348 times) previous topic - next topic

pamin

Hi Jack,
Thank you so much for your time.

I am trying to do scenario in post #13: connection between 2 xbees using Arduino and X-CTU.

I am using two Xbee S1. One  is coordinator and the other is end device. They have the same Channel (C) and PAN ID. DH and DL of one Xbee are the appropriate addresses of the other.

Xbee#1 is connected to Arduino. I use SERIAL MONITOR to send data to Xbee#2.

From Xbee#2 (controled by X-CTU) I tried two ways: 1) keying directly on CONSOLE LOG window and 2) adding package and send (just below the CONSOLE LOG window). But Xbee#2 --> Xbee#1 is not successful.

JChristensen

I've never worked with S1 modules configured as coordinator/end device. Is there some reason for not using just the regular peer-to-peer configuration? Maybe you have already done this, but what I would do first would be to get the microcontroller out of the picture, connect both XBees to XCTU or some other terminal program, i.e. run two copies of the terminal program and verify that they can communicate. End devices can be a bit tricky, making sure they wake up appropriately to communicate.

Sorry but not sure I can be of much more help than that.

pamin

Thank you Jack.

I tried two Xbees connected to laptop using two Xbee Explorers + X-CTU. They worked well. That's why it was so confusing when they did not work when I added Arduino.

BTW, please correct me if I am wrong. I though in a network, one Xbee should be Coordinator and the other should be End Device. Is it wrong?

GoForSmoke

Can the End Device talk back and if so, how? Because that is where you are having the problem, no?

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen


Thank you Jack.

I tried two Xbees connected to laptop using two Xbee Explorers + X-CTU. They worked well. That's why it was so confusing when they did not work when I added Arduino.


OK, good. Sounds like a code problem then.

Quote

BTW, please correct me if I am wrong. I though in a network, one Xbee should be Coordinator and the other should be End Device. Is it wrong?


Well, that is one of two ways XBee 802.15.4 modules (f.k.a. Series 1) can be configured. There is also a peer-to-peer configuration and I believe that is the way they come from the factory. I also think most of the discussion I've seen here on the forum is for peer-to-peer. If you don't have the product manual, download a copy.

XBee ZB modules (f.k.a Series 2) OTOH require one coordinator in every network. The rest of the network can consist of routers and/or end devices.

I would assume that the XBee 802.15.4 modules configured as coordinator/end device operate somewhat differently than the XBee ZB modules. How much different they are I cannot say. My experience is primarily with the XBee ZB modules, so I can't comment much more on the XBee 802.15.4 modules and especially when they are configured as coordinator/end device.

So let's have a look at the the code. How about reposting it just so we know we are looking at the latest code. Put the code between code tags (#), not quote tags. See http://forum.arduino.cc/index.php/topic,148850.msg1118324.html#post_codetags

pamin

Hi Jack,

1) This is the code I am using now at Xbee#1 (connected to Arduino)

Code: [Select]
#include <SoftwareSerial.h>

uint8_t pinRx = 4, pinTx = 5;
SoftwareSerial mySerial(pinRx, pinTx);

long BaudRate = 9600;

int led = 12;

void setup()
{
  pinMode(led, OUTPUT);
 
  Serial.begin(BaudRate);
  mySerial.begin(BaudRate); 
  mySerial.listen();
}

void loop()
{
  // transmit
  if (Serial.available())
  {
    char gotChar = Serial.read();
    Serial.print(gotChar);
    mySerial.print(gotChar);
    digitalWrite(led, HIGH);
    delay(20);
    digitalWrite(led, LOW);
  }
 
  // receive
  if (mySerial.available())
  {
    char gotChar = mySerial.read();
    Serial.print(gotChar);
    digitalWrite(led, HIGH);
    delay(20);
    digitalWrite(led, LOW);   
  }
}

2) I changed both Xbee to End Device.
3) I can send data from Arduino to Xbee#2 connected to laptop. The voltage at pin DOUT (pin 2) of Xbee#1 (connected to Arduino) is around 4.8V. Is it ok?

JChristensen


3) I can send data from Arduino to Xbee#2 connected to laptop. The voltage at pin DOUT (pin 2) of Xbee#1 (connected to Arduino) is around 4.8V. Is it ok?


Not OK. XBee is a 3.3V device and is not 5V tolerant. How is it being powered? Not sure how the DOUT pin could be that high if it's connected to an input pin on the Arduino unless the XBee is being powered by more than 3.3V.

pamin

It also confuses me. I measured pin 1 and pin 3, both voltages were 3.3V (easily seen from your circuit). Then I measured pin 2 of Xbee, it was 4.8-4.9V. Then I removed the wire connecting pin 2 of Xbee to the Rx of Arduino and measured the output of Rx pin of Arduino, the Rx pin was 4.9V. That means Arduino pulled the Rx pin to HIGH. I cannot explain this.

JChristensen

Well it looks like SoftwareSerial enables the pullup resistor on the RX line:
https://github.com/arduino/Arduino/blob/master/libraries/SoftwareSerial/SoftwareSerial.cpp#L368

GoForSmoke

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen

Can't use a diode like on the MCU-to-XBee line, because the XBee will still have to pull down the 5V. I'd go with a MOSFET level shifter like this.

GoForSmoke

#26
Aug 11, 2014, 07:21 pm Last Edit: Aug 11, 2014, 07:47 pm by GoForSmoke Reason: 1

Can't use a diode like on the MCU-to-XBee line, because the XBee will still have to pull down the 5V. I'd go with a MOSFET level shifter like this.


My thinking is that AVR INPUT_PULLUP current is through 20k-50k ohms, the 3.3V device should be able to take that below 1V without much problem. Maybe the .7V drop through the diode helps?
You're the one that first showed me using the diode and pullup for TTL serial to a 3.3V sound module (you may have gotten from Sparkfun).

Anyway I learn a bit more about MOSFET's that I haven't used yet. It makes sense *now that I think about it* that the voltage difference controlling the gate has to be relative to something! And that something is the source?

Quote
When the GPIO is 'high' the MOSFET is off (the gate-source voltage is near zero), and R2 pulls the 5V side high.


Am I understanding that right or just agreeing for the wrong reason?
The difference between tech and poetry is that poetry doesn't smoke and burn if it's not right, it often sells!

Quote
Q1 has a (hidden) diode between the source and drain terminals - if the 5V logic side is driven low, this will pull the GPIO low through the diode.  


That gate will always be HIGH won't it? Is that why there's a "hidden" diode? Because if the gate were to go LOW, there wouldn't be any current flow regardless of 5V or 0 on the drain would there?

Quote
When the 5V logic side is high, everything is off and the GPIO will be pulled to 3.3V via R1.


Is that because without flow through the MOSFET, the 3.3V pullup is the signal on GPIO?

If I have this right, I'm another step along in learning MOSFETs.

2N7000, 10 cents at Futurlec. But I spend $20 or more to justify the $7 shipping, and they have other goodies.
Or ~40 cents at DigiKey but I can get them in less than 3-4 weeks (days) and for less shipping last time I checked.

I could see keeping a bag of those in a parts bin and getting more 4.7k resistors.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen


My thinking is that AVR INPUT_PULLUP current is through 20k-50k ohms, the 3.3V device should be able to take that below 1V without much problem. Maybe the .7V drop through the diode helps?


That's what my gut tells me too, but not so. It's about the voltage when the pin is high, not current when it's low. They're slicing things so thin these days (in a figurative sense, there's no slicing going on, but the transistor structures are extremely thin) that 5V can cause a breakdown when 3.3V won't. Electric field strengths (measured in volts/meter) can get pretty impressive when the size of the structure is measured in nanometers.

GoForSmoke



My thinking is that AVR INPUT_PULLUP current is through 20k-50k ohms, the 3.3V device should be able to take that below 1V without much problem. Maybe the .7V drop through the diode helps?


That's what my gut tells me too, but not so. It's about the voltage when the pin is high, not current when it's low. They're slicing things so thin these days (in a figurative sense, there's no slicing going on, but the transistor structures are extremely thin) that 5V can cause a breakdown when 3.3V won't. Electric field strengths (measured in volts/meter) can get pretty impressive when the size of the structure is measured in nanometers.


I'm thinking of the wrong setup totally. The diode would block the 5V and that would only work if the 5V side is doing the signalling, which it was on the other circuit. Yeah, you can't drag the pin low if you block current leaving it.

Smart thing is to add (a) function(s) to the library that doesn't turn the pullup on then and use that?
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

JChristensen


Smart thing is to add (a) function(s) to the library that doesn't turn the pullup on then and use that?


The pin will still be at 5V when driven high by comms. I'd go with the MOSFET if it were me.

Go Up