• For the I2C slave, you could take a look at setWatch's data 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:

    • Connect all the TX pins of slaves together, and all the RX pins
    • Add a 10k pullup resistor to the Slave TX line
    • Slave TX -> master RX, Slave RX -> master TX
    • Ensure that after you set up all the Serial ports on the slaves, you set the pin mode of the TX pins to 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:

      // Slave
      var ID = 1; // change this for each slave
      
      // Master
      function sendCmd(id, cmd) {
      Serial1.println(`\x10if(id==${id})cmd;\n­`);
      }
      function gotResponse(d) {
      print("Got data ",JSON.stringify(d));
      }
      sendCmd(1,"print('Hello')");
      var lineData = "";
      Serial1.on('data',function(l) {
      lineData+=l;
      var d = lineData.split("\n");
      lineData = d.pop();
      d.forEach(gotResponse);
      });
      
  • 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. . . .

About

Avatar for Robin @Robin started