I am trying to control a Ohbot with a ESP32, I had it working with an Arduino Mega, but now trying to expand the program and use a ESP32. I am also using the PCA9685 servo board set to I2C address 0x41.
When I upload the code I get the following error"
ELF file SHA256: 350d6a8e8f1005bd
Rebooting...
��D�
1U1��z դ!��Ohbot control
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d1bb3 PS : 0x00060830 A0 : 0x800d1c95 A1 : 0x3ffc5280
A2 : 0x00000000 A3 : 0x3ffc52cf A4 : 0x00000001 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800d18c8 A9 : 0x3ffc5280
A10 : 0x00000002 A11 : 0x00000000 A12 : 0x00000004 A13 : 0x00000000
A14 : 0x00060e20 A15 : 0x00000001 SAR : 0x0000001d EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000000c LBEG : 0x40086120 LEND : 0x40086136 LCOUNT : 0xffffffff
Backtrace: 0x400d1bb0:0x3ffc5280 0x400d1c92:0x3ffc52a0 0x400d1965:0x3ffc52c0 0x400d1a97:0x3ffc52f0 0x400d14fc:0x3ffc5320 0x400d384e:0x3ffc5350
ELF file SHA256: 350d6a8e8f1005bd
This is a new ESP32 and breakout board I just got from Amazon, not sure if I have the correct board selected, I have tried a couple, currently it is "ESP32 DEV Module" Here is a link to the boards I bought, Amazon.com: AITRIP 2 Sets ESP-WROOM-32 ESP32 ESP-32S Type-C USB Development Board Type-C USB CH340C WiFi+Bluetooth Ultra-Low Power Dual Core ESP32-DevKitC-32 ESP-WROOM-32 Expansion Board for Arduino : Electronics.
I did look up online for this error but none of the solutions I found seem to fit my system.
Here is my code,
//Ohbot control with ESP32
// to test I2C board and servo set up
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
#define USMIN 600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150
#define USMAX 2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600
#define SERVO_FREQ 60 // Analog servos run at ~50 Hz updates
// Select board address, uncomment required board
//Adafruit_PWMServoDriver Head1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver Head2 = Adafruit_PWMServoDriver(0x41);
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
//Adafruit_PWMServoDriver Head3 = Adafruit_PWMServoDriver(0x42);
//Adafruit_PWMServoDriver Head4 = Adafruit_PWMServoDriver(0x43);
//Adafruit_PWMServoDriver Head5 = Adafruit_PWMServoDriver(0x44);
// Servo min max
int Head1_Min = 40;
int Head1_Max = 140;
void setup() {
Serial.begin(9600);
Serial.println("Ohbot control");
// Start required board, uncomment selected board
//Head1.begin();
Head2.begin();
// Head3.begin();
// Head4.begin();
// Head5.begin();
pwm.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
delay(10);
}
void loop() {
//Head Turn
for( int angle =Head1_Min; angle<Head1_Max; angle +=10){
delay(50);
pwm.setPWM(0, 0, angleToPulse(angle) );
Serial.println(angle);
} // end for += loop
for( int angle =Head1_Max; angle<Head1_Min; angle -=10){
delay(50);
pwm.setPWM(0, 0, angleToPulse(angle) );
Serial.println(angle);
} // end for -= loop
delay(50);
} //end loop
int angleToPulse(int ang){
int pulse = map(ang,0, 180, SERVOMIN,SERVOMAX);// map angle of 0 to 180 to Servo min and Servo max
// Serial.print("Angle: ");Serial.print(ang);
// Serial.print(" pulse: ");Serial.println(pulse);
return pulse;
} // end angleToPulse
Thanks for any help and suggestions.
John