Good Day all.
I am starting my journey with the ESP32 on the Adruino IDE platform and i would like to know if anyone could clarify things for me.
I've purchase the book Kolban's book on ESP 32 and found it very interesting, however i would have appreciated more examples explaining code syntax.
Anyways, the questions i have are:
1) Can the SPI.h library be used with the esp32? I have tried countless times but cannot seem to get in working. I've used it with the Esp 8266 with no problems.
2) I found the esp32-hal-spi.h library and followed Kolban's book to transfer a few bytes, now i can see the HSPI bus is active with an oscilloscope ,but the actual data received is either all zeros or garbage. I'm certain i'm not understanding how the actual instruction is working.
Basically i need to implement this line of code,
uint8_t tmp = SPI.transfer(0);
which is from the SPI library
How would i do this using the esp32-hal-spi.h libray. Is there an equivalent?
How would i write this line for the ESP 32 in Arduino IDE?
I would really appreciate any assistance. Im sure by now it is evident that i am not a seasoned programmer ,but i do enjoy making things with these chips.
Thank you in advance.
using Arduino IDE SPI.h library with ESP32
-
- Posts: 1
- Joined: Fri Mar 10, 2017 10:17 pm
Re: using Arduino IDE SPI.h library with ESP32
Howdy,
I think the assumption with the Arduino library would be to use Arduino APIs. For example, the Arduino SPI library found here:
https://www.arduino.cc/en/reference/SPI
The principle should be that you take an Arduino sketch that drives SPI and it should compile cleanly and run on the ESP32. For me, I normally plug in a logic analyzer and capture a trace of the transmissions. Many of the logic analyzer software packages can then interpret the logic signals as SPI and decode them to validate that what was actually sent on the wires was what was expected.
I think the assumption with the Arduino library would be to use Arduino APIs. For example, the Arduino SPI library found here:
https://www.arduino.cc/en/reference/SPI
The principle should be that you take an Arduino sketch that drives SPI and it should compile cleanly and run on the ESP32. For me, I normally plug in a logic analyzer and capture a trace of the transmissions. Many of the logic analyzer software packages can then interpret the logic signals as SPI and decode them to validate that what was actually sent on the wires was what was expected.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: using Arduino IDE SPI.h library with ESP32
I used the SPI.h library to read SPI flash with the Arduino IDE, you can see how here:
https://github.com/kriswiner/ESP32
https://github.com/kriswiner/ESP32
Re: using Arduino IDE SPI.h library with ESP32
I am using the esp 32 to interface with the LIS2HH12(accelerameter from ST Microelectronics.). I am using 18 for clock, 23 is MOSI, 19 is MISO and 5 for chip select.
I wrote a simple code to read the WHO_AM_I register. Accelerometer generates the necessary. Expec t ed output as required for this register. I saw the waveforms on oscilloscope. However when I connect the SDO pin to MISO, the signals disappear. Esp32 also reads 0.
I am wondering if there is any changes required for the pin 19 which is the pin involves. The layout on the Geek creit board seems ok as I can blink an LED on pin 19.
Do I need to have a pull up or pull down resistor? Or any other resistor for impedance matching?
Any inputs here will be very helpful. My whole project is at halt for the past 4 days.
Thanks,
Bhaven.
I wrote a simple code to read the WHO_AM_I register. Accelerometer generates the necessary. Expec t ed output as required for this register. I saw the waveforms on oscilloscope. However when I connect the SDO pin to MISO, the signals disappear. Esp32 also reads 0.
I am wondering if there is any changes required for the pin 19 which is the pin involves. The layout on the Geek creit board seems ok as I can blink an LED on pin 19.
Do I need to have a pull up or pull down resistor? Or any other resistor for impedance matching?
Any inputs here will be very helpful. My whole project is at halt for the past 4 days.
Thanks,
Bhaven.
-
- Posts: 3
- Joined: Thu Aug 03, 2017 5:46 pm
Re: using Arduino IDE SPI.h library with ESP32
Hi !
Any news here ?
Thanks
Any news here ?
Thanks
- ESP_krzychb
- Posts: 400
- Joined: Sat Oct 01, 2016 9:05 am
- Contact:
Re: using Arduino IDE SPI.h library with ESP32
Hi Monstercrunch,
Have you tried using another pin for MISO?
On the breadboard I have, the SDO pin does not have any pullup, unlike the other SPI signal pins. I have been using exactly GPIO19 for MISO / SDO and did not see any issues.
Do you mean that the signal line goes to zero as seen on the scope after you connect the SDO pin to MISO? Or the signal is correct on the scope but you read zero in your code?onehorse wrote: I saw the waveforms on oscilloscope. However when I connect the SDO pin to MISO, the signals disappear. Esp32 also reads 0.
Have you tried using another pin for MISO?
FWIW, I have been recently writing an ESP-IDF component for LIS35DE that looks like a similar chip by ST.bhavenm wrote:Do I need to have a pull up or pull down resistor? Or any other resistor for impedance matching?
On the breadboard I have, the SDO pin does not have any pullup, unlike the other SPI signal pins. I have been using exactly GPIO19 for MISO / SDO and did not see any issues.
Re: using Arduino IDE SPI.h library with ESP32
Hi team,
Using SPI.h library in arduino IDE can you guide me on how to read data from slave devices?
Anyone has experience about it. Can someone help me?
Thanks,
Akshay Godase
Using SPI.h library in arduino IDE can you guide me on how to read data from slave devices?
Anyone has experience about it. Can someone help me?
Thanks,
Akshay Godase
Re: using Arduino IDE SPI.h library with ESP32
Hi akshu15,
I'll let here a link to a code that shows how to use SPI.h from the arduino IDE.
In this code is shown also how to remap the MISO, MOSI and SCLK buses to other pins.
One important point:
Observe that when initialing the SPI instance, only MOSI, MISO and SCLK are passed as parameters to the SPI driver.
The CS is controlled by the external peripheral driver, in this case the LoRa driver.
It's a good practice, mainly when you are developing an application that uses multiple peripherals in an SPI.
https://github.com/majuzabbal/LoRaENELT ... ender1.ino
Take a look at this example and you will be able to know how to use SPI.h from arduino IDE.
If you have doubts regarding the steps to read from slave devices, I recommend you to look inside the LoRa driver itself.
It will use the SPI API and control de CS pin to enable and disable communication to that slave device.
But if you have problems, post it here.
I'll let here a link to a code that shows how to use SPI.h from the arduino IDE.
In this code is shown also how to remap the MISO, MOSI and SCLK buses to other pins.
One important point:
Observe that when initialing the SPI instance, only MOSI, MISO and SCLK are passed as parameters to the SPI driver.
The CS is controlled by the external peripheral driver, in this case the LoRa driver.
It's a good practice, mainly when you are developing an application that uses multiple peripherals in an SPI.
https://github.com/majuzabbal/LoRaENELT ... ender1.ino
Take a look at this example and you will be able to know how to use SPI.h from arduino IDE.
If you have doubts regarding the steps to read from slave devices, I recommend you to look inside the LoRa driver itself.
It will use the SPI API and control de CS pin to enable and disable communication to that slave device.
But if you have problems, post it here.
Who is online
Users browsing this forum: No registered users and 116 guests