Esp32-s3, sha-256 problem

Hello,
I'm a student of robotics and I'm doing a project with ESP32-S3 (simulated on Wokwi) and I'm having a SHA-256, this project has two LEDs, an ultrasound sensor, a buzzer and a vibration motor (Wokwi doesn't have a vibration motor so I used a Servo). The problem is with the ultrasound sensor, because it's not sowing the results that it should. I did this code with Arduino and everything worked perfectly, but when I did this with ESP32-S3, this problem came:

SP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
configspi:0x000000b9
SPIWP:0x00
mode:DIO, clock div:1
load:0x3fce3808,len:0x370
load:0x403c9700,len:0x900
load:0x403cc700,len:0x2364
SHA-256 comparison failed:
Calculated: bea01f04c6f0e287a682f128805e3fce115955179100e98d8f412fe7697f8bdc
Expected: 08ea492e448f88de75319ed18ac319444e578d9c6bc7003c5c4807382bf389bd
Attempting to boot anyway...
entry 0x403c98ac

Here's the code that I'm using:

const int trigPin= 14;
const int echoPin= 13;
const int ledPinGreen= 5;
const int ledPinRed= 4;
const int buzzerPin= 6;
const int vibrationPin= 1;
//letters
const int dot= 200;
const int line= 3*dot;
const int pau= dot;
const int nextLetter= 2*dot;
const int restart= 7*dot;
const int f1= 261.63;
const int f2= 440.00;
const long silent= 30000; // silence

void setup(){
  Serial.begin(115200);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  pinMode(ledPinGreen,OUTPUT);
  pinMode(ledPinRed,OUTPUT);
  pinMode(buzzerPin,OUTPUT);
  pinMode(vibrationPin,OUTPUT);
  
}
void sensor(){ 
    int duration, distance;
    digitalWrite (trigPin, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin, LOW);
    duration = pulseIn (echoPin, HIGH);
    distance = duration * 0.034 / 2;

      Serial.print("Sensor: ");  
      Serial.print(distance); 
      Serial.print("cm    ");
  
    if (distance < 400) {
      
        digitalWrite(vibrationPin, HIGH);
    }
 else {
      digitalWrite (vibrationPin, LOW);
    }  
int vibration;
vibration= map(distance, 2, 400, 255, 0);
  analogWrite(distance, vibration);
Serial.print ("vibration: ");
Serial.print(vibration);
 Serial.println();}

void safeM(){
  int safe []= {dot, pau, dot, pau, dot, nextLetter, dot, pau,
                line, nextLetter, dot, pau, dot, pau, line, pau,
                dot, nextLetter, dot, restart};
  int fs []= {f1, silent, f1, silent, f1, silent, f1, silent, f1,
              silent, f1, silent, f1, silent, f1, silent, f1, 
              silent, f1, silent};
  for (int s=0; s<20; s++){
    tone(buzzerPin, fs[s]);
    delay(safe[s]);}
    noTone(buzzerPin);
}
void dangerM(){
  int danger []= {line, pau, dot, pau, dot, nextLetter, dot, pau,
                  line, nextLetter, line, pau, dot, nextLetter, 
                  line, pau, line, pau, dot, nextLetter, dot, 
                  nextLetter, dot, pau, line, pau, dot, restart};
  int fd []= {f2, silent, f2, silent, f2, silent, f2, silent, f2, 
             silent, f2, silent, f2, silent, f2, silent, f2, 
             silent, f2, silent, f2, silent, f2, silent, f2, 
              silent, f2, silent, f2, silent};
  for (int d=0; d<28; d++){
    tone(buzzerPin, fd[d]);
    delay(danger[d]);}
    noTone(buzzerPin);
}
  void safeL(){
    digitalWrite(ledPinGreen,HIGH);}
    void dangerL(){
    digitalWrite(ledPinRed,HIGH);}

Here you can see the simulation: projecte robòtica copy - Wokwi Arduino and ESP32 Simulator

I hope someone can help me

You have no loop function in your sketch. It also appears that you are missing a } at the end of the safeL function.

Are you trying to use the Tone library? You have to declare that in the beginning using an #include fuction. You would also want to use the ultrasonic library.

What are you driving your vibration motor with? You can't run it directly off of your ESP32. There won't be enough current from the GPIO pins. You need a driver of some kind.

I didn't include the loop because I'm just calling the functions to see if they're working. I'll try with tone and ultrasonic library

I tried and none of them are solving my problem

Can you post your full code?

I tried some libraries, but are not solving my problem

#include <AiEsp32RotaryEncoder.h>
#include <DTF_ESP32Update.h>
#include <PWMOutESP32.h>
#include <ACAN_ESP32.h>
const int trigPin= 14;
const int echoPin= 13;
const int ledPinGreen= 5;
const int ledPinRed= 4;
const int buzzerPin= 6;
const int vibrationPin= 1;
//letters
const int dot= 200;
const int line= 3*dot;
const int pau= dot;
const int nextLetter= 2*dot;
const int restart= 7*dot;
const int f1= 261.63;
const int f2= 440.00;
const long silent= 30000; // silence

void setup(){
  Serial.begin(115200);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  pinMode(ledPinGreen,OUTPUT);
  pinMode(ledPinRed,OUTPUT);
  pinMode(buzzerPin,OUTPUT);
  pinMode(vibrationPin,OUTPUT);
  
}
void sensor(){ 
    int duration, distance;
    digitalWrite (trigPin, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin, LOW);
    duration = pulseIn (echoPin, HIGH);
    distance = duration * 0.034 / 2;

      Serial.print("Sensor: ");  
      Serial.print(distance); 
      Serial.print("cm    ");
  
    if (distance < 400) {
      
        digitalWrite(vibrationPin, HIGH);
    }
 else {
      digitalWrite (vibrationPin, LOW);
    }  
int vibration;
vibration= map(distance, 2, 400, 255, 0);
  analogWrite(distance, vibration);
Serial.print ("vibration: ");
Serial.print(vibration);
 Serial.println();}

void safeM(){
  int safe []= {dot, pau, dot, pau, dot, nextLetter, dot, pau,
                line, nextLetter, dot, pau, dot, pau, line, pau,
                dot, nextLetter, dot, restart};
  int fs []= {f1, silent, f1, silent, f1, silent, f1, silent, f1,
              silent, f1, silent, f1, silent, f1, silent, f1, 
              silent, f1, silent};
  for (int s=0; s<20; s++){
    tone(buzzerPin, fs[s]);
    delay(safe[s]);}
    noTone(buzzerPin);
}
void dangerM(){
  int danger []= {line, pau, dot, pau, dot, nextLetter, dot, pau,
                  line, nextLetter, line, pau, dot, nextLetter, 
                  line, pau, line, pau, dot, nextLetter, dot, 
                  nextLetter, dot, pau, line, pau, dot, restart};
  int fd []= {f2, silent, f2, silent, f2, silent, f2, silent, f2, 
             silent, f2, silent, f2, silent, f2, silent, f2, 
             silent, f2, silent, f2, silent, f2, silent, f2, 
              silent, f2, silent, f2, silent};
  for (int d=0; d<28; d++){
    tone(buzzerPin, fd[d]);
    delay(danger[d]);}
    noTone(buzzerPin);
}
  void safeL(){
    digitalWrite(ledPinGreen,HIGH);}
    void dangerL(){
    digitalWrite(ledPinRed,HIGH);}

void loop(){
  Serial.println("\n");
  sensor();
safeL();
safeM();}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.