# Is it possible to control many microcontrollers using a single microcontroller/microprocessor? [closed]

I am presently working on Home Automation Projects, having no of home appliances. I would like to know the ways that I can control many micro-controllers using a central micro-controller/micro-processor(wired/wireless)?

## closed as too broad by PeterJ, Ignacio Vazquez-Abrams, placeholder, Keelan, Leon HellerSep 28 '14 at 9:40

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• On what distance, and what speed? – Keelan Sep 28 '14 at 6:01

## Attention - this answer is not correct.

### I2C is a protocol that applies for a distributed system INSIDE THE SAME BOARD, no distributed in a house.

One of the basics and proved method is the $I^2C$ protocol. Many microcontrollers implements it and this protocol is designed for velocity and few lines of transmission (only needs 2 lines).

To implement this protocol, you should define a device as master (the main microcontroller) and the rest of the devices as slaves (auxiliary microcontrollers).

• This answer is so narrow and incomplete that it deserves a -1. Martin, have you ever tried to have an I2C master on one side of a house and I2C slave on the other side of a house? Have you though about what would happen? – Nick Alexeev Sep 28 '14 at 19:10
• Maybe I miss-understand the question. Of Course, I2C can't be implemented as protocol for a distributed system in the dimensions of a house. I understood that the question related to a system (a board) where live several microcontrollers. Sorry for the inconvenience. I have implemented many distributed systems, based on Modbus, ProfiBUS, CAN, etc, but surely not I2C beyod 20 cm length... The downvote is welcome. – Martin Petrei Sep 28 '14 at 19:27

I assume you want to have one master controller, and several slave microcontrollers located in other rooms of your house. Another answer has mentioned I²C protocol, however the standard implementation is not a good choice for this purpose as I²C was originally designed for connecting IC's on a single or interconnected PCB's, and not for carrying signals distances much over a meter or so.

However using techniques such as twisted pair for each of the SCL and SDA signals, CAT5, and I²C-bus buffers it is possible to extend the range to tens of meters.

Another serial protocol to stay away from for the same reason is standard SPI protocol, which is good for 5 to 10 feet. however using techniques like running over an RS-422 data link, it too can be extended over tens of meters.

If you are going to connect your microcontrollers together using wires, then for long distances you are better off using a system that with differential signalling which will do a better job of mitigating any noise. Here are a couple of choices:

RS-485
Ethernet


An RS-485 system is much like an RS-232 system, in that it can use the UART built into virtually all microcontrollers; but it requires special RS-485 interface chips to add the differential signalling capability. The disadvantage of using an RS-485 system is that you would have to write all of the networking protocols yourself, unless you could find something to use on the web.

Ethernet of course is the how we used to connect all of our computers up to the Internet before Wi-Fi came along. Using it only makes sense if the microcontrollers you are using already have an Ethernet interface built-in. The advantage of using the Ethernet is there is a lot of software already available.

The other way to go, which is probably what you had in mind, is a wireless system. Here you have quite a few choices, roughly in order of cost per node:

433 MHz ISM
ZigBee
Bluetooth / BLE
Wi-Fi


Modules for the 433 MHz ISM (industrial/scientific/medical) band are very cheap (transceivers + antenna for $3) but the disadvantage is there is no built-in protocol -- you just have access to a stream of bits and have to create everything from scratch, same as for a wired RS-485 network. ZigBee modules cost two to three times as much as bare ISM ($5-\$7), but have the advantage that the networking protocol has already been provided. Modules can either be a coordinator (only one in a system), router, or end point. The range is only 10-20 meters, but because of the routers, signals can hop from one node to the next. Another advantage of ZigBee, is since it was designed for home automaton (among other things), there are lots of lighting controls, dimmers, etc. that already come with it built in (at a pretty hefty price).

Bluetooth modules are going to cost about the same as ZigBee. BLE is Bluetooth Low Energy, part of Bluetooth 4.0. You will have one master, and all the slaves will talk directly back to it. This works since the range of Bluetooth is up to 100 meters.

Finally, there is Wi-Fi, which everyone is familiar due to our using it for both desktops, laptops, and other devices throughout the home. Wi-Fi modules are available for a few dollars more than ZigBee of Bluetooth.

The advantage of using Wi-Fi, like the Ethernet interface already mentioned, is there is a lot of software already available. Another advantage of using Wi-Fi, is that you could tie this all into your desktop computer, and have a GUI showing everything that is being controlled.

• You could write a PC GUI pretty easily for any of the approaches you've suggested, not just Wifi. – markt Sep 28 '14 at 8:49
• @markt For the Wi-Fi (and Ethernet), I was thinking in terms of running a web server on the main microcontroller, and then you could just create a web page and run it in a browser on the PC. Granted, for all of the other modalities, it would be possible to write a desktop GUI application also. – tcrosley Sep 28 '14 at 17:11