esp-idf/examples/system/lp_core/lp_i2c
Sudeep Mohanty ec742abb25 lp-i2c: Added support for LP I2C peripheral to LP core
This commit adds support for the LP I2C peripheral driver to be used by
the LP core. An example is also added to demonstrate the usage of the LP
I2C peripheral from the LP core.
2023-05-19 07:27:51 +02:00
..
main lp-i2c: Added support for LP I2C peripheral to LP core 2023-05-19 07:27:51 +02:00
CMakeLists.txt lp-i2c: Added support for LP I2C peripheral to LP core 2023-05-19 07:27:51 +02:00
README.md lp-i2c: Added support for LP I2C peripheral to LP core 2023-05-19 07:27:51 +02:00
sdkconfig.defaults lp-i2c: Added support for LP I2C peripheral to LP core 2023-05-19 07:27:51 +02:00

Supported Targets ESP32-C6

LP I2C Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

Overview

This example demonstrates basic usage of the LP I2C driver from the LP core by reading to and writing from a sensor connected over I2C.

How to use example

Hardware Required

To run this example, you should have a ESP32-C6 based development board as well as a BH1750 sensor. BH1750 is an ambient light sensor. More information about it can be found in the BH1750 datasheet.

Pin Assignment:

Note: The following pin assignments are used by default.

SDA SCL
ESP32-C6 LP I2C Master GPIO6 GPIO7
BH1750 Sensor SDA SCL

Note: There's no need to add an external pull-up resistors for SDA/SCL pin, because the driver enables the internal pull-up resistors.

Build and Flash

Enter idf.py -p PORT flash monitor to build, flash and monitor the project.

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

The log output should indicate that the LP core and the LP I2C peripheral have been successfully initialized. The main CPU would then enter deep sleep mode. The LP Core should wakeup the main CPU if the Light Intensity Value breaches the set thresholds.

Not an LP core wakeup. Cause = 0
Initializing...
LP core loaded with firmware successfully
LP I2C initialized successfully
Entering deep sleep...

(When the BH1750 sensor is shielded from a light source, the Lux value should be smaller and the LP core should wakeup the main CPU)

LP core woke up the main CPU
Lux = 3
Entering deep sleep...

(When the BH1750 sensor is exposed to a direct light source, the Lux value should be larger and the LP core should wakup the main CPU)

LP core woke up the main CPU
Lux = 1222
Entering deep sleep...

Troubleshooting

(For any technical queries, please open an issue on GitHub. We will get back to you as soon as possible.)