Simple SPI communication between photons

Hello!!!.., Greetings to all, I comment that I am new in the use of Photon, I have a project with SPI communication with 2 photon, but I have several attempts and I can not establish communication, I could support myself to check if I have any errors in the code, Thank you very much … greetings.:

===Master===

void setup() 
{
    pinMode(SS,OUTPUT);
    digitalWrite(SS,HIGH);
    Serial.begin(9600);
    SPI.begin(SPI_MODE_MASTER,SS);
    SPI.setClockSpeed(1, MHZ);
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE3);
}

void loop()
{
    digitalWrite(SS,LOW);
    byte sendData = 0x05;
    SPI.transfer(sendData);
    digitalWrite(SS, HIGH);
    Serial.print("\nEnviado a Slave=");
    Serial.print(sendData);
    delay(500);
}

===SLAVE===

void setup() 
{   
    Serial.begin(9600);
    SPI.begin(SPI_MODE_SLAVE,SS);
}

void loop()
{
    byte recvData;
    recvData = SPI.transfer(0x00);
    Serial.print("\nRecibido de Maestro=");
    Serial.print(recvData);
    delay(500);
}

Thanks…

You need to make your slave code event driven, so that it will respond when the SS pin goes low
Have a look at the docs
https://docs.particle.io/reference/firmware/photon/#onselect-

1 Like

Hello!!!..

Thanks for the information, I commented that I make a simple program with the option marked OnSelect, but I still do not complete the communication between 2 photons, either a simple byte or DMA, I do not know if someone has made the communication between 2 devices, Otherwise to make the report to the person in charge of the subject in the university that this device does not meet the necessary characteristics and that is discarded for future practices, thank you for your comments on this … greetings.