-
Mon 2019.07.29
RATS!! You would have to spoil our spacey dreams with an actual reliable way that would work, @Gordon ! wink, wink ;-)
All kidding aside, thank you for detailing how we ought to be doing this task. For my project, running short of pins and didn't want to add a MUX chip as well. But it is nice to have confirmation on how it should be done. Thank you for detailing that snippet.
rethink and redesign underway. . . .
-
@Gordon I plan to write binary data using the Uint16Array object. The master will send this to one slave, and the slave will respond back with a Uint16Array object. Total bytes in each direction will be < 100 bytes.
Since I want to control the send and receive, I'm thinking of using Serial.write(data), then Serial.read() to receive the response from the slave. But Serial.read() appears to be a blocking call (no callback). So I'm not sure if my idea is the right approach. Thoughts?
For the I2C slave, you could take a look at
setWatch
'sdata
pin option (so you setWatch SCL and use SDA for data) - although things may still be a bit tricky to get it working nicely.What I always suggest for things like this is just to use Serial communications with the UART. This generally works really nicely:
opendrain
Create some kind of software system to ensure that the slaves only write data when they're asked to by the master. The simplest is just to use the built-in JS REPL to execute code that does some kind of
if (id=myId) doSomething()
type thing: