Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking into using Atmel's 2051 microcontroller with an Xbee and a HC-05 Bluetooth module, the micro however has only one serial connection and no possibility for expandability with memory-accessed peripherals. Is this doable or do I have to choose only one of the two?

share|improve this question
An Atmel's what? – Ignacio Vazquez-Abrams Apr 9 '14 at 2:23
Sorry, I got the numbers wrong. – Sanuuu Apr 9 '14 at 3:19
up vote 2 down vote accepted

Use/find/implement your own Arduino style software-serial library for slow baud-rate serial comms to one of the devices, and use the hardware UART (serial) to the other one.

You could even do software serial for BOTH bluetooth and Xbee if data rates are kept low, and you dont have any crazy hard-realtime system (higher priority control) which may cause loss of data too often.

share|improve this answer
This. +1. Right here. Just borrow a couple of other pins on the controller and away you go. – Sean Boddy Apr 9 '14 at 5:02
I don't know how difficult it is to adapt Arduino code to run on 2051, but here's a library that apparently runs quite fast: the AltSoftSerial library, as recommended in this post: arduino.stackexchange.com/questions/854/…. – gwideman Apr 9 '14 at 5:16
No need for Arduino code (Excessive bloat...) implenting a "soft serial port" is pretty simple if you are at all good at programming and carefully read through and understand the very basics RS-232 communication. Although I must admit, transmit is MUCH simpler to code than Receive. It should all be interrupt based. I communicate to serial peripheral on ATtiny devices without a USART port all the time. – Kurt E. Clothier Apr 9 '14 at 5:34
yeah, bit-banging is pretty damn easy, with nice and neat use of ISRs, I agree with @KurtE.Clothier The data rate should be kept as low as possible though to reduce errors. Maybe test at higher rates if you want, but expect failures in strange places – KyranF Apr 9 '14 at 6:55

Yes, You can use both. You might want to look into multiplexers. You can buy dual multiplexers. Depending on the sort of IC you use, it will normally have one input to connect your microcontroller to and two outputs. Or a long way could be to build your very own perhaps using high speed transistors or even mosfets. Although using an IC is recommended

share|improve this answer
Another option is to use software (ie "bit-banged serial") to run the serial port. – Eric Gunnerson Apr 9 '14 at 3:47
@EricGunnerson, that would be one channel right? – David Norman Apr 9 '14 at 4:03
You can make it run for multiple devices over a single port using the bit banging method, provided that device being controlled is sophisticated enough to have to get properly addressed, using a name header or something. Not sure exactly how well the Xbee will tolerate listening to garbage intended for the bluetooth, but it might be able to behave itself. – Sean Boddy Apr 9 '14 at 5:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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