arduino <> esp32 test3 — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by aleenasrky.

Components

Sketch code

HardwareSerial ArduinoSerial(2);

void setup() {
  Serial.begin(115200);

  ArduinoSerial.begin(115200, SERIAL_8N1, 16, 17);

  Serial.println("ESP32 sensor processor ready");
}

void loop() {
  if (ArduinoSerial.available()) {

    String received = ArduinoSerial.readStringUntil('\n');
    received.trim();

    if (received.length() > 0) {

      int sensorValue = received.toInt();

      Serial.print("Received sensor: ");
      Serial.println(sensorValue);

      // Convert Arduino's 0–1023 range
      // to ESP32's 0.0–1.0 range.
      float normalized = sensorValue / 1023.0;

      Serial.print("Normalized: ");
      Serial.println(normalized, 4);
    }
  }
}

More projects by aleenasrky