Add new library 'SmartSystem' to the library registry - simplified RPC over Wire and RF24 #5945
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add new library 'SmartSystem'. Readme below:
SmartSystem
SmartSystem is an Arduino library which simplifies building modular networks of Arduinos.
Functionality can be exposed by a Arduino module, and discovered, accessed, and executed remotely over either Wire or RF24 radio.
This library evolved from use of Arduinos in escape room setups, which required many Arduinos to be centrally controlled and monitored.
Installation
Use the Arduino library manager to install SmartSystem library.
At least 2 Arduinos are required to create a SmartSystem network.
If using Wire protocol
I2C Wire connections should use the default SDA and SCL pins for your Arduino (e.g. A4 / A5 for a Nano). This is not something that can be configured when using this library.
Using the
Wire_Settings
parameter at startup, it is possible to override the Wire connection speed.If using an RF24 radio device (such as NRF24L01)
The default settings are those for UNO / Nano:
Using the
Radio_Settings
parameter at startup, it is possible to override the pins marked with * in the table above. Note that using an INTERRUPT pin is absolutely required by this library!Radio_Settings
also let you control other selected parameters of the RF24 device, such asRADIO_SPEED
,RADIO_POWER
andCHANNEL
(which defaults to 108),In general, it is best to stick to the defaults where possible. This library generally favours simplicity and consistency over configurabilty!
Usage
The system setup always involves:
A SmartModule must always have strictly one communication method with the network - either Wire or RF24 Radio. This is selected at module startup using either
startOverWire()
orstartOverRadio()
function.The SmartController can use either communication method, or both at once. It can see and control all connected modules, regardless of the communication protocol they are using. This is selected at controller startup using the
usingWire()
andusingRadio()
methods.SmartModule setup
Simple SmartModule Arduino sketch, which provides a function that returns an integer, exposed over RF24 radio
SmartController setup
Simple SmartController Arduino sketch, which accesses the SmartModule's functionality over radio
Logging
To see more info on startup / connection issues,
SmartController.doSerialErrorLogging(true)
can be called at startup, which activates serial logging of any errors.Gotchas
Because the exposed functions on the modules are invoked from interrupt callbacks, the following rules apply:
volatile
If you fail to observe the above, things can fail in unexpected and unpredictable ways.
Further information
The provided examples cover most use cases.
The AllMethodTypesModule.ino sketch shows how all different function types can be exposed from a module.
The UniversalController.ino is an interactive controller sketch, which shows how to scan, iterate over modules and functions, extract metadata from them, and invoke methods with all the allowed function signatures.
Using the sketches above on 2 Arduinos demonstrates all the possible ways of calling functions using a SmartSystem, and constitutes a good test when setting up a new system.
Contributing
Pull requests are welcome!
License
MIT