My project idea is for a robot car (MEGA 2560) that can accept gesture commands ( from nano 33 ble sense) while Mastering over an arduino NANO for peripheral sound effects.
In a nutshell I believe I need the MEGA 2560 to act as a slave and a master at different times while coexisting with BLE sense chip configured as permanent master but how?
So MEGA 2560 should always be a slave except when it needs to play a voice( send 5 bytes command to NANO ; no need to explain what the bytes are for), it should then revert back to a slave mode, awaiting 'receive_event()' while controlling the car inside its own program.
Different events during program excecution will need different voices so periodically MEGA 2560 needs to Master it up and somehow deal with BLE sense.
NANO is a permanent slave and will respond to an incoming 5 bytes on the bus.
The low level data exchange is already tested and verified for
MEGA 2560 to NANO as well as
BLE sense to NANO
The 33 ble sense chip is master only. master only, gosh darnit!
I guess I need to somehow isolate SDA SCL on the BLE sense chip during the time MEGA 2560 is mastering. This does not sound like a good solution.
That's how I2C works. It has no defined master, each node can become a master whenever required.
In a multi-master environment bus collisions can occur. Please check which Arduino can handle such colissions properly, by breaking a transfer and reporting a failure. Then it's up to you to solve the colission by adequate code.
I am glad to hear that. That part of it will work out.
So now how to deal with ble sense chip being Master Only.
Actually The ble sense chip in the diagram is using softwarei2c to implement master. 'Wire' did not work for me but I (hehe) don't remember exactly why. I remember compile errors such like "no such library exists" for #include "wire.h";
only when ble sense board is selected in the IDE. I then looked around and saw
So I believe the dual Master solution presented " [Arduino I2C Multi-Master Approach - Why and How]" will work (howbeit a lot of extra hardware connections.) If it is robust it should be worth it.
My point for discussing all of this here on this forum is the hope that everything I am
proposing thus far will actually work.
It is going to take considerable effort and time to put dual Master sharing together and test it. I don't mind as long as the desired result can be assured at the end of it.
Having said all that I still would love to hear anyone who knows how to use NANO 33 ble Sense with the wire library.