0

I am just starting out a project and I am having a little bit of trouble. I want to send data collected from an IR distance sensor, and send it with an XBee Pro S2B to my computer so I can do other stuff with it. The code I am using right now is pretty simple:

void setup()
{
  Serial.begin(9600);
}
void loop(){
 int distance = analogRead(0);
  Serial.println(distance);
  delay(1000);
}

The problem I am having is that when I turn on the arduino with batteries and disconnect the usb cable, the tx light stops turning on and no serial data is sended, AND if I connect it to the computer via USB again it won't work anyway, only works right when I upload the code. The XBees are configured correctly, I have done the chat example on the Building Wireless Sensor Networks by Robert Faludy.

Is it some code error? I must be really obvious. By the way, when I upload the code and the serial data is sended throught usb, the data displayed on Arduino IDE's console is correct, so the sensor is wired correctly.

I am using an Arduino UNO and I have the XBee's and arduino's drivers installed correctly, and for the XBee I am using the XBee Explorer from Sparkfun

  • I have the same problem but in my design a supply both Arduino UNO board and XBEE module from a 1.5 A switched mode power supply.I noticed the LEDs on the XBEE module not on the UNO ARDUINO board and there is no blinking on TX or RX, so can any one help. – user2855 Jun 19 '14 at 11:41
  • 1
    TX/RX LEDs do not blink when used on external power. – CharlieHanson Jun 26 '15 at 12:28
  • Upvoted, I am having the same issue. This is not a noob problem either. The bare Arduino Uno serial is not working when powered from a 12V bench supply from Vin when USB is not plugged in. – Daniel Jul 21 '17 at 20:59
1

I suggest you try to flash the pin 13 LED in your loop(). It seems like the Arduino is not booting correctly on the batteries?

The serial port on the uno is kinda messy, it shouldn't really be shared with the usb port like that. I prefer the Leonardo for these applications - where the USB serial and serial pins are totally independent.

  • The usb isn't intended to be used, only the pins, but only works when I upload the code and I haven't disconnected the cable. I am going to try that, will edit with the results – Jairo Jun 17 '14 at 23:47
  • I just programmed it with a led flashing every second, and it works if I have the XBee disconnected, but once I plug the xbee the led starts flashing radomly very fast and no serial data is sent. I think is worth noting I am using the build-in led. Maybe it's because I am using the 5v output from the arduino to power the sensor AND the 3v3 for the XBee? – Jairo Jun 17 '14 at 23:58
  • What batteries are you using? It sounds like the Xbee is drawing too much power - you might need to move to bigger batteries. Another way of testing would be to power the Arduino with a plug pack on the barrel connector (saves batteries until you're ready to go mobile). – TomKeddie Jun 18 '14 at 0:04
  • I guess you're dropping down the 5V to make the 3.3v using a regulator? – TomKeddie Jun 18 '14 at 0:04
  • 1
    This is the beauty of open hardware, we have the schematic - arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf The 3.3v pin using an LM2985 regulator that can only supply 150mA, I don't think it is powerful enough for an xbee. From digi.com/products/wireless-wired-embedded-solutions/… the pro need 205mA, you should switch to the ZB, it needs only 40mA (or add a separate 3.3v power supply). Until you sort out the power, the system won't behave predictably. – TomKeddie Jun 18 '14 at 0:19
0

You have an XBee shield on top of the Arduino UNO?

Do you have an XBee attached to the computer?

Can you describe your setup a little more.

The TX Led on the Arduino is only on the USB side, and doesn't signify TX on the XBee. The XBee itself should/could have a TX/RX leds itself. Check the Arduino schematic to confirm this.

How are you reading the Serial on the computer? Thru the Arduino serial monitor? That won't work for the XBee. You'll need another Serial monitor for the XBee attached to the computer. ie, Arduino with XBee shield. Then an XBee connected via some breakout board to the computer. The Arduino Serial monitor won't see the XBee (use hyperterm on windows or some serial port monitor on other systems).

Also, check your switch on the XBee (if you have one), most redirect the USB/Serial connection between computer/Arduino and Arduino/XBee. It's one or the other not both.

  • I am sorry for not clarifying a bit more in the initial question, I thought this was something simple. I am not using a shield, only a XBee explorer with pins soldered to it, and I am reading the output with CoolTerm. And I didn't know that about the TX light only working for USB... So: XBee connected to arduino via an XBee explorer with pins soldered, and the receiving XBee connected to the computer via USB using another XBee explorer. Coolterm is configured correctly, I know that because I have used the xbee to do a chat between 2 computers, and the XBees themselves are configured correctly. – Jairo Jun 19 '14 at 1:42
0

Try interchanging the Tx-Rx pins of your XBee-Arduino connection.

Since you are getting correct values on the Arduino IDE, this means that both sensor and serial is working, but it sends values only when connected via USB which means that problem lies in your link between Arduino-Serial Device (in this case XBee)

0

Ok, I have verified this behavior with a bare Uno on an external power supply driven from Vin.

The serial is outputting, but because of the way the TX and RX LEDs are wired in the Uno, they do not activate unless the USB processor is active.

This is super dumb and super confusing, but you can clearly see it's wired up this way:

Arduino Uno schematic detail

I have confirmed that serial data is coming out of the Arduino with a logic analyzer, but the LEDs do not light up.

  • It's not super dumb. Putting an LED and its resistor on a couple of pins would alter the behaviour of those pins if they were used for something else (eg. input). On the earlier Arduino Unos they had an LED on pin 13, now it is driven by an op-amp to try to reduce this problem. – Nick Gammon Jul 22 '17 at 6:55
  • Yes, I think I would advocate for a dual comparator, or even a couple of transistors on the lines! I suppose it could be an already-fixed firmware problem with the Uno, but I haven't had time to get the DFU tools to find out. – Daniel Jul 23 '17 at 11:40
  • And yes, by oversight or design, I maintain that the Tx and Rx LEDs not lighting is "super dumb and confusing" – Daniel Jul 23 '17 at 11:42
0

Finally found out how to get the Arduino Uno serial port to work without a USB cable! I used a scope to see what was going on and found that using an external power supply on the Arduino power port only showed +3.3 volts on the +5 line. I pulled the plug on the external power supply and put a regulated +5 VDC on the +5 VDC pin. Now, both software serial and the UART ports work fine - hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.