user8275: I have an MCP4151 digital potentiometer chip. I have managed to get it to work using and Arduino Uno using the code below:
#include <SPI.h>

byte address = 0x00;
int CS= 5;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
}

void loop()
{
  for (int i = 0; i <= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i >= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}

But when I try to get it to work using an ESP32 programmed using Arduino language it doesn't. I have connected like that

SCK -> 18
MOSI -> 23
SS -> 5

I also used the potentiometer inside like a voltage divider for test purposes. GND on one leg, 3.3v on the other and an LED on the wiper. Are there other settings that I have to implement in order the ESP32 SPI to work like an Arduino SPI? Did I miss something?

user8275: I managed to get it to work in a strange way. I opened the example included in the ESP32 SPI Library and copied some points from there.
I first initialise a pointer to the SPI class, then I call begin() at that pointer and inside the digitalPotWrite function I call beginTransaction(10000,MSBFIRST,SPI_MODE0) and end the transaction before digitalPotWrite finishes. Full code here:
#include <SPI.h>

static const int spiClk = 1000000;
byte address = 0x00;
SPIClass * hspi = NULL;

void setup()
{
  pinMode(15, OUTPUT);
  hspi = new SPIClass(HSPI);
  hspi->begin(); 
}

void loop()
{
  for (int i = 0; i <= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i >= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(15, LOW);
  hspi->transfer(address);
  hspi->transfer(value);
  digitalWrite(15, HIGH);
  hspi->endTransaction();
}


8275: <p>I have an <a href="https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/22060b.pdf" rel="nofollow noreferrer">MCP4151</a> digital potentiometer chip. I have managed to get it to work using and Arduino Uno using the code below:</p>

<pre><code>#include &lt;SPI.h&gt;

byte address = 0x00;
int CS= 5;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
}

void loop()
{
  for (int i = 0; i &lt;= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i &gt;= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}
</code></pre>

<p>But when I try to get it to work using an ESP32 programmed using Arduino language it doesn't. I have connected like that</p>

<ul>
<li>SCK -> 18</li>
<li>MOSI -> 23</li>
<li>SS -> 5</li>
</ul>

<p>I also used the potentiometer inside like a voltage divider for test purposes. GND on one leg, 3.3v on the other and an LED on the wiper. Are there other settings that I have to implement in order the ESP32 SPI to work like an Arduino SPI? Did I miss something?</p>
 8275: <p>I managed to get it to work in a strange way. I opened the example included in the ESP32 SPI Library and copied some points from there.</p>

<p>I first initialise a pointer to the SPI class, then I call <strong><code>begin()</code></strong> at that pointer and inside the <code>digitalPotWrite</code> function I call <strong><code>beginTransaction(10000,MSBFIRST,SPI_MODE0)</code></strong> and end the transaction before <code>digitalPotWrite</code> finishes. Full code here:</p>

<pre><code>#include &lt;SPI.h&gt;

static const int spiClk = 1000000;
byte address = 0x00;
SPIClass * hspi = NULL;

void setup()
{
  pinMode(15, OUTPUT);
  hspi = new SPIClass(HSPI);
  hspi-&gt;begin(); 
}

void loop()
{
  for (int i = 0; i &lt;= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i &gt;= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  hspi-&gt;beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(15, LOW);
  hspi-&gt;transfer(address);
  hspi-&gt;transfer(value);
  digitalWrite(15, HIGH);
  hspi-&gt;endTransaction();
}
</code></pre>
