Since I decided to palm off the networking stuff, the MQTT and the LCD messages to a small Atmega328, it will be necessary to have one MCU tell the other what it is doing. The 1284 will be switching the radios off and on, but the 328 will need to know what its doing, so it can display on the LCD the proper messages.
The are several ways to get one arduino to talk to the other. Some are basic, others complicated. In my home automation all of the arduinos ( 37 now in all) talk to each other over the network using MQTT broker. The broker keeps the messages and the arduinos subscribe to the topics they are told to....its a great system, easy fast, but would be over kill in this application. You can serially talk between arduinos, you can also use I2C or TWI. I went an even more basic route.
The simplest way to "talk" between arduinos is simply using a few digital signals. In my case to alert the 328 that the 1284 is doing something, I added "bits" to the sketch. Each "bit" is turned high when the 1284 is doing something.
The " bits" are self explanatory. When the repeater COR goes HIGH ( receives a signal) then the corresponding "bit" is set HIGH. This digital line is then tied to the other arduino ( through a pulldown resistor) When the bit is driven HIGH, then the 328 knows the COR is HIGH, and executes the appropriate code. This was the simplest way to tell one arduino what the other one was doing and keeping it basic.
No comments:
Post a Comment