// I have RP2040 klipper printer microcontroller // this device sends screendata over…
- User
// I have RP2040 klipper printer microcontroller // this device sends screendata over i2c to I2C address: 0x3C
// esp32 microcontroller 1, i want to use this microcontroller to capture the screendata from the rp2040 and send this over to the second microcontroller // configure esp32 as virtual ssd1306 to receive screen data, no physical screen is installed, I2C address: 0x3C is the virtual screen adress used. // define index buffer to store the ssd1306 screendata. // store the screen data into a index buffer // send the index buffer data containing the screendata over espnow to second esp32
// esp32 microcontroller 2 // configure esp32 with ssd1306 screen to display screen data // define index buffer // read the screendata over espnow from thirst esp32 and store this into the index buffer data containing the screen data // read the screen data from index buffer and display this on the screen
// Write me the code for esp32 microcontroller 1
- Assistant
- User
Write me the code for esp32 microcontroller 2
- Assistant
Sure! Here's an example code for the second ESP32 microcontroller:
#include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <esp_now.h> #include <WiFi.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define I2C_ADDRESS 0x3C uint8_t indexBuffer[1024]; // Index buffer to store the received screen data void setup() { Serial.begin(115200); // Initialize I2C communication Wire.begin(); Wire.setClock(400000); // Initialize the screen display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS); display.clearDisplay(); // Set up ESP-NOW if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } // Register ESP-NOW receive callback function esp_now_register_recv_cb(onReceiveData); // Set the ESP-NOW peer address esp_now_peer_info_t peer; memcpy(peer.peer_addr, "{first_esp32_mac_address}", 6); peer.channel = 0; peer.encrypt = false; // Add the ESP-NOW peer if (esp_now_add_peer(&peer) != ESP_OK) { Serial.println("Failed to add peer"); return; } Serial.println("Ready"); } void loop() { // Display the received screen data displayReceivedData(); } void displayReceivedData() { // Clear the display display.clearDisplay(); // Display the received screen data from the index buffer for (uint16_t index = 0; index < sizeof(indexBuffer); index++) { display.write(indexBuffer[index]); } display.display(); } void onReceiveData(const uint8_t *mac_addr, const uint8_t *data, int data_len) { // Copy the received screen data to the index buffer memcpy(indexBuffer, data, data_len); Serial.println("Screen data received"); } - User
for the first code for microcontroller 1 i get this error: 12:43:52.538 -> Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. 12:43:52.538 -> 12:43:52.538 -> Core 1 register dump: 12:43:52.538 -> PC : 0x400e42c8 PS : 0x00060830 A0 : 0x800d157b A1 : 0x3ffc68c0
12:43:52.570 -> A2 : 0x3ffc3bd4 A3 : 0x3ffc0b08 A4 : 0x3ffc3bd4 A5 : 0x00000000
12:43:52.570 -> A6 : 0x00000010 A7 : 0x00000001 A8 : 0x800d2288 A9 : 0x3ffc68b0
12:43:52.570 -> A10 : 0x3ffbb974 A11 : 0x00000000 A12 : 0x00000400 A13 : 0x3ffbbd74
12:43:52.570 -> A14 : 0x000000ff A15 : 0x00000040 SAR : 0x00000019 EXCCAUSE: 0x0000001c - Assistant
The "LoadProhibited" error typically occurs when the microcontroller attempts to access memory that it does not have permission to access. In this case, it might be happening due to an issue with the I2C communication or the way the screen data is being stored in the index buffer.
Here are a few suggestions to troubleshoot the issue:
-
Make sure the I2C communication is properly configured. Check the connections between the RP2040 and the ESP32 and ensure that the I2C addresses match.
-
Verify that the RP2040 is correctly sending the screen data over I2C. You can use an I2C scanner sketch to check if the RP2040 is detected on the I2C bus and if it responds with the correct address.
-
Double-check the size of the index buffer. Ensure that it is large enough to store all the screen data that is being received. If the buffer is too small, it may result in a memory access error.
-
Consider using dynamic memory allocation (e.g.,
mallocandfree) instead of a fixed-size index buffer. This can help prevent memory access issues if the received screen data size varies.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.