Page 1 of 1

ESP32 write to registers

Posted: Wed Sep 22, 2021 7:37 am
by bssmith237
Hello everyone,

I have an ESP32 board connected with an IMU. I want to make few alterations on the IMU like hardcoding the calibration offsets values in order to use them every time the board powers on. My main concern is how can I write directly to the registers from the Arduino IDE platform. I imagine that this has to do mainly with C# programming and specifically with ESP32 but any help will be useful.

Thank you

Re: ESP32 write to registers

Posted: Thu Sep 23, 2021 1:48 am
by StridingDragon
You essentially have to select the SPI device you want to address and then execute a SPI transaction using something like `spi_device_transmit()` etc. Don't forget to unselect the SPI device afterwards to make it available to other processes.

Re: ESP32 write to registers

Posted: Thu Sep 23, 2021 10:04 am
by filo_gr
bssmith237 wrote:
Wed Sep 22, 2021 7:37 am
My main concern is how can I write directly to the registers from the Arduino IDE platform.
Which protocol do you need? ESP-IDF gives you a lot of libraries you can use for communication.
If you use Arduino IDE I think you installed the esp32 pack of libraries in the IDE.

Re: ESP32 write to registers

Posted: Thu Sep 23, 2021 11:32 am
by bssmith237
filo_gr wrote:
Thu Sep 23, 2021 10:04 am
bssmith237 wrote:
Wed Sep 22, 2021 7:37 am
My main concern is how can I write directly to the registers from the Arduino IDE platform.
Which protocol do you need? ESP-IDF gives you a lot of libraries you can use for communication.
If you use Arduino IDE I think you installed the esp32 pack of libraries in the IDE.
Thank you for your answer,

Yes I have installed the esp32 pack. So I should look for ESP-IDF package. I will try and inform you upon my outcome.

Re: ESP32 write to registers

Posted: Fri Sep 24, 2021 9:44 pm
by chegewara

Code: Select all

    Wire.beginTransmission((uint8_t)ADDRESS);  	// I2C address
    Wire.write((uint8_t)0x1);					// register address
    Wire.write((uint8_t)136);					// write byte/bytes
    Wire.endTransmission();					// end