Touch, Hall Effect, and Temperature Inbuilt Sensors in ESP32

// Show core temperature to serial monitor#ifdef __cplusplus
extern “C” {
#endif
uint8_t temprature_sens_read();#ifdef __cplusplus
}
#endif
#define INTERNAL_LED 2// Variable
uint8_t temprature_sens_read();
int current_temp;
// Setup
void setup() {
Serial.begin(115200);
pinMode(INTERNAL_LED, OUTPUT);
}
// Loop
void loop() {
Serial.print(“Core temp: “);

// F → C
current_temp = (temprature_sens_read() — 32) / 1.8;
Serial.print(current_temp);
Serial.println(“ C”);
// Internal LED control
if (current_temp > 50) {
digitalWrite(INTERNAL_LED, HIGH);
}
else {
digitalWrite(INTERNAL_LED, LOW);
}

delay(1000);
}
(It’s a GIF file)
// ESP32 Touch Test
// Just test touch pin — Touch0 is T0 which is on GPIO 4.
void setup() {
Serial.begin(115200);
delay(1000); // Setup time
Serial.println(“ESP32 Touch Test”);
}
void loop() {
Serial.println(touchRead(4));
delay(1000);
}
// Show core temperature to serial monitor#ifdef __cplusplus
extern “C” {
#endif
uint8_t temprature_sens_read();#ifdef __cplusplus
}
#endif
#define INTERNAL_LED 2// Variable
uint8_t temprature_sens_read();
int current_temp;
// Setup
void setup() {
Serial.begin(115200);
pinMode(INTERNAL_LED, OUTPUT);
}
// Loop
void loop() {
Serial.print(“Core temp: “);

// F → C
current_temp = (temprature_sens_read() — 32) / 1.8;
Serial.print(current_temp);
Serial.println(“ C”);
// Internal LED control
if (current_temp > 50) {
digitalWrite(INTERNAL_LED, HIGH);
}
else {
digitalWrite(INTERNAL_LED, LOW);
}

delay(1000);
}
int val = 0;

void setup() {
Serial.begin(9600);
}

// put your main code here, to run repeatedly
void loop() {
// read hall effect sensor value
val = hallRead();
// print the results to the serial monitor
Serial.println(val);
delay(1000);
}
#define RED 15
#define YELLOW 4
#define WHITE 5
#define GREY 18
#define GREEN 19
#define BLUE 21
int val = 0;void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(WHITE, OUTPUT);
pinMode(GREY, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
// put your main code here, to run repeatedly
void loop() {
// read hall effect sensor value
val = hallRead();
// print the results to the serial monitor
Serial.println(val);
// RED
if (val < -20) {
digitalWrite(RED, HIGH);
}
else {
digitalWrite(RED, LOW);
}
// YELLOW
if (val < -10) {
digitalWrite(YELLOW, HIGH);
}
else {
digitalWrite(YELLOW, LOW);
}
// WHITE
if (val < 0) {
digitalWrite(WHITE, HIGH);
}
else {
digitalWrite(WHITE, LOW);
}
// GREY
if (val > 0) {
digitalWrite(GREY, HIGH);
}
else {
digitalWrite(GREY, LOW);
}
// GREEN
if (val > 10) {
digitalWrite(GREEN, HIGH);
}
else {
digitalWrite(GREEN, LOW);
}
// BLUE
if (val > 20) {
digitalWrite(BLUE, HIGH);
}
else {
digitalWrite(BLUE, LOW);
}

delay(200);
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store