hello,
for a project I have to read the current and the voltage values of an MPPT (STEVAL-ISV009v1) via SPI,
here is the code wich I have made, but the problem is that the miso no data send to the arduino, and the value of readspanning is 0
can someone help me with this problem?
/*
* CS - to digital pin 10 (SS pin)
* tdata - to digital pin 11 (MOSI pin)
* Dout - to digital pin 12 (MISO pin)
* tCLK - to digital pin 13 (SCK pin)
*/
#include <SPI.h> // include the SPI library:
int slaveSelectPin = 10; // set pin 10 as the slave
void setup()
{
Serial.begin(9600);
pinMode (slaveSelectPin, OUTPUT); // set the slaveSelectPin as an output:
SPI.begin(); // initialize SPI:
SPI.setBitOrder(MSBFIRST);
}
void loop()
{
SPI.transfer(0x02); // shut down
SPI.transfer(0x03); // turn on
delay(100);
digitalWrite(slaveSelectPin,LOW);
byte Readspanning = SPI.transfer(0x05); // read spanning
SPI.transfer(0x01); // nop
SPI.transfer(0x01); // nop
digitalWrite(slaveSelectPin,HIGH);
Serial.print(" spanning = ");
Serial.print(Readspanning);
}
Moderator edit: [code] ... [/code] tags added. (Nick Gammon)