I am trying to slot a particle into an SPI connection between my hot tub control panel and its main board. My end goal is to remotely monitor and control my hot tub.
I used me Open Bench Logic sniffer to analyze the signal.
If I use the SPI interface with the setClockDivider set to the max the slowest I can transmit the data is 100 microseconds on the SPI interface or 200 microseconds on the SPI1 interface.
Does any one know how to slow either of these interfaces ?
Is there a bit-blaster SPI implementation that I could run slower ?
I believe the receiving end needs the clock to be running at 60 kHz. I had limited success using SPI1 with the max clock divider e.g 100Hz. When I sent a series of bytes recorded with my Bus Pirate the display lit up and displayed correctly, but I can’t reliably make this work.
@skinks, is the Particle device like a “man in the middle” for the SPI? That seems like a very slow SPI clock but you could do it with software SPI (see below). By adding delayMicroseconds(), you can slow down the software clock to whatever speed you need.
/**
* Implement software SPI tranfer using bit banging
**/
byte SPIxfer(byte data) {
byte b=0, bit;
for (bit = 0; bit < 8; bit++) { // walks down mask from bit 7 to bit 0
digitalWrite(_mosiPin, !!(data & (1 << (7 - bit)))); // set the MOSI pin
digitalWrite(_clockPin, HIGH); // Clock the data to the slave
delayMicroseconds(2); // adjust this delay to make sure slave is clocking the data
b |= digitalRead(_misoPin) << (7 - bit); // read the data back from the slave (if it applies)
digitalWrite(_clockPin, LOW); // reset clock to next cycle
delayMicroseconds(15); // delay total 17us for approx 60KHz SPI clock
}
return b;
}