phyphox Forums
ESP32 Dev kit --Reg - Printable Version

+- phyphox Forums (https://phyphox.org/forums)
+-- Forum: Discussion (https://phyphox.org/forums/forumdisplay.php?fid=1)
+--- Forum: Experiments and Ideas (https://phyphox.org/forums/forumdisplay.php?fid=4)
+--- Thread: ESP32 Dev kit --Reg (/showthread.php?tid=1686)



ESP32 Dev kit --Reg - pikubose - 02-02-2023

#include <phyphoxBle.h>

int analogPin = A3;
int Rawval ; // variable to store the value read
float Scaleval ;
int RELAY_pin = 10; // Relay is connected to pin D10
void setup()
{
Serial.begin(9600); // setup serial
pinMode(RELAY_pin, OUTPUT);
PhyphoxBLE:Confusedtart();
}

void loop()
{
int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");
Serial.println(Scaleval);
PhyphoxBLE::write(Scaleval);    //Send value to phyphox
    delay(100); 

if ( Rawval < 169) digitalWrite(RELAY_pin, HIGH);
else digitalWrite(RELAY_pin, LOW);
}
What will be the analog pin?


RE: ESP32 Dev kit --Reg - Jens Noriʇzsɔɥ - 02-03-2023

You must not use PIN D10 (check your board: there is none). It is used for the internal flash and we would expect that the board is nastily crashed by your code. You should check https://randomnerdtutorials.com/esp32-pinout-reference-gpios/, for instance.

If you use 32 (or some others, see link) instead, your code should run without problems.