Hello all,
I have a little problem with my ESP32 DEVKIT V1
I have a sketch which should be on the board but is not executed.
All librabrys are installed and the board is also addressed during upload. However, there is no reaction.
Sketch:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
int UVOUT = 15; //Output from the sensor
int REF_3V3 = 4; //3.3V power on the ESP32 board
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup()
{
Serial.begin(9600);
pinMode(UVOUT, INPUT);
pinMode(REF_3V3, INPUT);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
display.clearDisplay();
}
//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
byte numberOfReadings = 8;
unsigned int runningValue = 0;
for(int x = 0 ; x < numberOfReadings ; x++)
runningValue += analogRead(pinToRead);
runningValue /= numberOfReadings;
return(runningValue);
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void loop()
{
int uvLevel = averageAnalogRead(UVOUT);
int refLevel = averageAnalogRead(REF_3V3);
//Use the 3.3V power pin as a reference to get a very accurate output value from sensor
float outputVoltage = 3.3 / refLevel * uvLevel;
float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0); //Convert the voltage to a UV intensity level
Serial.print("output: ");
Serial.print(refLevel);
Serial.print("ML8511 output: ");
Serial.print(uvLevel);
Serial.print(" / ML8511 voltage: ");
Serial.print(outputVoltage);
Serial.print(" / UV Intensity (mW/cm^2): ");
Serial.print(uvIntensity);
Serial.println();
display.setCursor(20,0); //oled display
display.setTextSize(1);
display.setTextColor(WHITE);
display.println("UV Ray Intensity");
display.setCursor(20,20); //oled display
display.setTextSize(3);
display.setTextColor(WHITE);
display.println(uvIntensity);
display.setCursor(20,45); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("mW/cm^2");
display.display();
delay(300);
display.clearDisplay();
}
Log during Upload:
esptool.py v3.0-dev
Serial port COM3
Connecting.......
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: ec:94:cb:4a:58:84
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 1394.4 kbit/s)...
Hash of data verified.
Compressed 17120 bytes to 11164...
Writing at 0x00001000... (100 %)
Wrote 17120 bytes (11164 compressed) at 0x00001000 in 0.2 seconds (effective 825.1 kbit/s)...
Hash of data verified.
Compressed 242864 bytes to 125371...
Writing at 0x00010000... (12 %)
Writing at 0x00014000... (25 %)
Writing at 0x00018000... (37 %)
Writing at 0x0001c000... (50 %)
Writing at 0x00020000... (62 %)
Writing at 0x00024000... (75 %)
Writing at 0x00028000... (87 %)
Writing at 0x0002c000... (100 %)
Wrote 242864 bytes (125371 compressed) at 0x00010000 in 1.9 seconds (effective 1005.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 585.1 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
In the Serial Monitor i only get these:
Rebooting...
Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.
Core 1 register dump:
PC : 0x400d25b8 PS : 0x00060730 A0 : 0x800d12f0 A1 : 0x3ffb1f10
A2 : 0x3ffbdc60 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00000015
A6 : 0xffffffff A7 : 0x3ffbdc60 A8 : 0x800d25b8 A9 : 0x3ffb1ee0
A10 : 0x04c4b400 A11 : 0x00000014 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060720 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Backtrace: 0x400d25b8:0x3ffb1f10 0x400d12ed:0x3ffb1f30 0x400d1c1e:0x3ffb1f50 0x400d0ed1:0x3ffb1f80 0x400d3d46:0x3ffb1fb0 0x400869bd:0x3ffb1fd0
Rebooting...
Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.
Core 1 register dump:
PC : 0x400d25b8 PS : 0x00060730 A0 : 0x800d12f0 A1 : 0x3ffb1f10
A2 : 0x3ffbdc60 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x00000015
A6 : 0xffffffff A7 : 0x3ffbdc60 A8 : 0x800d25b8 A9 : 0x3ffb1ee0
A10 : 0x04c4b400 A11 : 0x00000014 A12 : 0x00000001 A13 : 0x00000001
A14 : 0x00060720 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
ELF file SHA256: 0000000000000000
Unfortunately, I do not have much experience with the arduinos which is why I do not understand where the error lies. Can anyone read something from this ?
Thanks in advance
Best regards