├── .gitattributes ├── .gitignore ├── ESP32 Pins & Boards.xlsx ├── ESP32_GPIODiscovery └── ESP32_GPIODiscovery.ino ├── ESP32_ModeTest └── ESP32_ModeTest.ino ├── ESP32_OLED_Demo ├── ESP32_OLED_Demo.ino └── images.h └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /ESP32 Pins & Boards.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SensorsIot/ESP32-Board-Test/42eae030fd1138c779e88b083d8e3f7fea8bdb63/ESP32 Pins & Boards.xlsx -------------------------------------------------------------------------------- /ESP32_GPIODiscovery/ESP32_GPIODiscovery.ino: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2017 by Andreas Spiess 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | */ 25 | 26 | int gpio[100] = {0, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33, 99}; 27 | 28 | int i = 0; 29 | 30 | void setup() { 31 | Serial.begin(115200); 32 | delay(1000); //Take some time to open up the Serial Monitor 33 | while (gpio[i] < 99) { 34 | pinMode(gpio[i], INPUT_PULLUP); 35 | i++; 36 | } 37 | i = 0; 38 | Serial.println("Setup done "); 39 | } 40 | 41 | void loop() { 42 | while (gpio[i] < 99) { 43 | int ss = digitalRead(gpio[i]); 44 | if (ss == 0) 45 | { 46 | Serial.print("GPIO "); 47 | Serial.print(gpio[i]); 48 | Serial.print(" "); 49 | Serial.println(ss); 50 | } 51 | i++; 52 | } 53 | i = 0; 54 | Serial.println(); 55 | delay(2000); 56 | } 57 | -------------------------------------------------------------------------------- /ESP32_ModeTest/ESP32_ModeTest.ino: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Sketch shows how to switch between WiFi and BlueTooth or use both 16 | // Button is attached between GPIO 0 and GND and modes are switched with each press 17 | 18 | // Adapted by Andreas Spiess 2017 19 | 20 | #include "WiFi.h" 21 | #define STA_SSID "xxx" 22 | #define STA_PASS "xxx" 23 | #define AP_SSID "esp32" 24 | 25 | #define SWITCHPIN 4 26 | 27 | enum { STEP_STA,STEP_BTON, STEP_AP, STEP_AP_STA, STEP_OFF, STEP_BT_STA, STEP_END, STEP_SLEEP }; 28 | 29 | #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ 30 | #define TIME_TO_SLEEP 15 /* Time ESP32 will go to sleep (in seconds) */ 31 | 32 | RTC_DATA_ATTR int bootCount = 0; 33 | 34 | void onButton() { 35 | static uint32_t step = STEP_BTON; 36 | switch (step) { 37 | case STEP_BTON://BT Only 38 | Serial.println("** Starting BT"); 39 | btStart(); 40 | break; 41 | case STEP_STA://STA Only 42 | Serial.println("** Stopping BT"); 43 | btStop(); 44 | Serial.println("\n** Starting STA"); 45 | WiFi.begin(STA_SSID, STA_PASS); 46 | break; 47 | case STEP_AP://AP Only 48 | Serial.println("** Stopping STA"); 49 | WiFi.mode(WIFI_AP); 50 | Serial.println("\n** Starting AP"); 51 | WiFi.softAP(AP_SSID); 52 | break; 53 | case STEP_AP_STA://AP+STA 54 | Serial.println("\n** Starting AP + STA"); 55 | WiFi.mode(WIFI_AP_STA); 56 | WiFi.softAP(AP_SSID); 57 | delay(500); 58 | WiFi.begin(STA_SSID, STA_PASS); 59 | break; 60 | case STEP_OFF://All Off 61 | Serial.println("** Stopping WiFi"); 62 | WiFi.mode(WIFI_OFF); 63 | break; 64 | case STEP_BT_STA://BT+STA 65 | Serial.println("\n** Starting STA+BT"); 66 | WiFi.begin(STA_SSID, STA_PASS); 67 | delay(500); 68 | btStart(); 69 | break; 70 | case STEP_END://All Off 71 | Serial.println("** Stopping WiFi+BT"); 72 | WiFi.mode(WIFI_OFF); 73 | btStop(); 74 | break; 75 | case STEP_SLEEP: 76 | Serial.println("\n** Going to sleep now"); 77 | esp_deep_sleep_start(); 78 | break; 79 | default: 80 | break; 81 | } 82 | if (step == STEP_SLEEP) { 83 | step = STEP_BTON; 84 | } else { 85 | step++; 86 | } 87 | //little debounce 88 | delay(100); 89 | } 90 | 91 | void WiFiEvent(WiFiEvent_t event) { 92 | switch (event) { 93 | case SYSTEM_EVENT_AP_START: 94 | Serial.println("AP Started"); 95 | WiFi.softAPsetHostname(AP_SSID); 96 | break; 97 | case SYSTEM_EVENT_AP_STOP: 98 | Serial.println("AP Stopped"); 99 | break; 100 | case SYSTEM_EVENT_STA_START: 101 | Serial.println("STA Started"); 102 | WiFi.setHostname(AP_SSID); 103 | break; 104 | case SYSTEM_EVENT_STA_CONNECTED: 105 | Serial.println("STA Connected"); 106 | WiFi.enableIpV6(); 107 | break; 108 | case SYSTEM_EVENT_AP_STA_GOT_IP6: 109 | Serial.print("STA IPv6: "); 110 | Serial.println(WiFi.localIPv6()); 111 | break; 112 | case SYSTEM_EVENT_STA_GOT_IP: 113 | Serial.print("STA IPv4: "); 114 | Serial.println(WiFi.localIP()); 115 | break; 116 | case SYSTEM_EVENT_STA_DISCONNECTED: 117 | Serial.println("STA Disconnected"); 118 | break; 119 | case SYSTEM_EVENT_STA_STOP: 120 | Serial.println("STA Stopped"); 121 | break; 122 | default: 123 | break; 124 | } 125 | } 126 | 127 | void print_wakeup_reason() { 128 | esp_deep_sleep_wakeup_cause_t wakeup_reason; 129 | 130 | wakeup_reason = esp_deep_sleep_get_wakeup_cause(); 131 | 132 | switch (wakeup_reason) 133 | { 134 | case 1 : Serial.println("Wakeup caused by external signal using RTC_IO"); break; 135 | case 2 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break; 136 | case 3 : Serial.println("Wakeup caused by timer"); break; 137 | case 4 : Serial.println("Wakeup caused by touchpad"); break; 138 | case 5 : Serial.println("Wakeup caused by ULP program"); break; 139 | default : Serial.println("Wakeup was not caused by deep sleep"); break; 140 | } 141 | } 142 | 143 | void setup() { 144 | Serial.begin(115200); 145 | delay(1000); //Take some time to open up the Serial Monitor 146 | //Increment boot number and print it every reboot 147 | ++bootCount; 148 | Serial.println("Boot number: " + String(bootCount)); 149 | //Print the wakeup reason for ESP32 150 | print_wakeup_reason(); 151 | 152 | esp_deep_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); 153 | Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds"); 154 | 155 | pinMode(SWITCHPIN, INPUT_PULLUP); 156 | WiFi.onEvent(WiFiEvent); 157 | Serial.print("ESP32 SDK: "); 158 | Serial.println(ESP.getSdkVersion()); 159 | Serial.println("Press the button to select the next mode"); 160 | } 161 | 162 | void loop() { 163 | static uint8_t lastPinState = 1; 164 | uint8_t pinState = digitalRead(SWITCHPIN); 165 | if (!pinState && lastPinState) { 166 | onButton(); 167 | } 168 | lastPinState = pinState; 169 | delay(100); 170 | } 171 | -------------------------------------------------------------------------------- /ESP32_OLED_Demo/ESP32_OLED_Demo.ino: -------------------------------------------------------------------------------- 1 | /** 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2016 by Daniel Eichhorn 5 | Copyright (c) 2016 by Fabrice Weinberg 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | */ 26 | 27 | #include 28 | 29 | // Include the correct display library 30 | // For a connection via I2C using Wire include 31 | #include // Only needed for Arduino 1.6.5 and earlier 32 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 33 | // or #include "SH1106.h" alis for `#include "SH1106Wire.h"` 34 | // For a connection via I2C using brzo_i2c (must be installed) include 35 | // #include // Only needed for Arduino 1.6.5 and earlier 36 | // #include "SSD1306Brzo.h" 37 | // #include "SH1106Brzo.h" 38 | // For a connection via SPI include 39 | // #include // Only needed for Arduino 1.6.5 and earlier 40 | // #include "SSD1306Spi.h" 41 | // #include "SH1106SPi.h" 42 | 43 | // Include the UI lib 44 | #include "OLEDDisplayUi.h" 45 | 46 | // Include custom images 47 | #include "images.h" 48 | 49 | // Use the corresponding display class: 50 | 51 | // Initialize the OLED display using SPI 52 | // D5 -> CLK 53 | // D7 -> MOSI (DOUT) 54 | // D0 -> RES 55 | // D2 -> DC 56 | // D8 -> CS 57 | // SSD1306Spi display(D0, D2, D8); 58 | // or 59 | // SH1106Spi display(D0, D2); 60 | 61 | // Initialize the OLED display using brzo_i2c 62 | // D3 -> SDA 63 | // D5 -> SCL 64 | // SSD1306Brzo display(0x3c, D3, D5); 65 | // or 66 | // SH1106Brzo display(0x3c, D3, D5); 67 | 68 | // Initialize the OLED display using Wire library 69 | SSD1306 display(0x3c, 4, 15); 70 | // SH1106 display(0x3c, D3, D5); 71 | 72 | OLEDDisplayUi ui ( &display ); 73 | 74 | int screenW = 128; 75 | int screenH = 64; 76 | int clockCenterX = screenW / 2; 77 | int clockCenterY = ((screenH - 16) / 2) + 16; // top yellow part is 16 px height 78 | int clockRadius = 23; 79 | 80 | // utility function for digital clock display: prints leading 0 81 | String twoDigits(int digits) { 82 | if (digits < 10) { 83 | String i = '0' + String(digits); 84 | return i; 85 | } 86 | else { 87 | return String(digits); 88 | } 89 | } 90 | 91 | void clockOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { 92 | 93 | } 94 | 95 | void analogClockFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { 96 | // ui.disableIndicator(); 97 | 98 | // Draw the clock face 99 | // display->drawCircle(clockCenterX + x, clockCenterY + y, clockRadius); 100 | display->drawCircle(clockCenterX + x, clockCenterY + y, 2); 101 | // 102 | //hour ticks 103 | for ( int z = 0; z < 360; z = z + 30 ) { 104 | //Begin at 0° and stop at 360° 105 | float angle = z ; 106 | angle = ( angle / 57.29577951 ) ; //Convert degrees to radians 107 | int x2 = ( clockCenterX + ( sin(angle) * clockRadius ) ); 108 | int y2 = ( clockCenterY - ( cos(angle) * clockRadius ) ); 109 | int x3 = ( clockCenterX + ( sin(angle) * ( clockRadius - ( clockRadius / 8 ) ) ) ); 110 | int y3 = ( clockCenterY - ( cos(angle) * ( clockRadius - ( clockRadius / 8 ) ) ) ); 111 | display->drawLine( x2 + x , y2 + y , x3 + x , y3 + y); 112 | } 113 | 114 | // display second hand 115 | float angle = second() * 6 ; 116 | angle = ( angle / 57.29577951 ) ; //Convert degrees to radians 117 | int x3 = ( clockCenterX + ( sin(angle) * ( clockRadius - ( clockRadius / 5 ) ) ) ); 118 | int y3 = ( clockCenterY - ( cos(angle) * ( clockRadius - ( clockRadius / 5 ) ) ) ); 119 | display->drawLine( clockCenterX + x , clockCenterY + y , x3 + x , y3 + y); 120 | // 121 | // display minute hand 122 | angle = minute() * 6 ; 123 | angle = ( angle / 57.29577951 ) ; //Convert degrees to radians 124 | x3 = ( clockCenterX + ( sin(angle) * ( clockRadius - ( clockRadius / 4 ) ) ) ); 125 | y3 = ( clockCenterY - ( cos(angle) * ( clockRadius - ( clockRadius / 4 ) ) ) ); 126 | display->drawLine( clockCenterX + x , clockCenterY + y , x3 + x , y3 + y); 127 | // 128 | // display hour hand 129 | angle = hour() * 30 + int( ( minute() / 12 ) * 6 ) ; 130 | angle = ( angle / 57.29577951 ) ; //Convert degrees to radians 131 | x3 = ( clockCenterX + ( sin(angle) * ( clockRadius - ( clockRadius / 2 ) ) ) ); 132 | y3 = ( clockCenterY - ( cos(angle) * ( clockRadius - ( clockRadius / 2 ) ) ) ); 133 | display->drawLine( clockCenterX + x , clockCenterY + y , x3 + x , y3 + y); 134 | } 135 | 136 | void digitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { 137 | String timenow = String(hour()) + ":" + twoDigits(minute()) + ":" + twoDigits(second()); 138 | display->setTextAlignment(TEXT_ALIGN_CENTER); 139 | display->setFont(ArialMT_Plain_24); 140 | display->drawString(clockCenterX + x , clockCenterY + y, timenow ); 141 | } 142 | 143 | // This array keeps function pointers to all frames 144 | // frames are the single views that slide in 145 | FrameCallback frames[] = { analogClockFrame, digitalClockFrame }; 146 | 147 | // how many frames are there? 148 | int frameCount = 2; 149 | 150 | // Overlays are statically drawn on top of a frame eg. a clock 151 | OverlayCallback overlays[] = { clockOverlay }; 152 | int overlaysCount = 1; 153 | 154 | void setup() { 155 | Serial.begin(115200); 156 | Serial.println(); 157 | 158 | pinMode(16, OUTPUT); 159 | digitalWrite(16, LOW); // set GPIO16 low to reset OLED 160 | delay(50); 161 | digitalWrite(16, HIGH); // while OLED is running, must set GPIO16 to high 162 | 163 | 164 | 165 | // The ESP is capable of rendering 60fps in 80Mhz mode 166 | // but that won't give you much time for anything else 167 | // run it in 160Mhz mode or just set it to 30 fps 168 | ui.setTargetFPS(60); 169 | 170 | // Customize the active and inactive symbol 171 | ui.setActiveSymbol(activeSymbol); 172 | ui.setInactiveSymbol(inactiveSymbol); 173 | 174 | // You can change this to 175 | // TOP, LEFT, BOTTOM, RIGHT 176 | ui.setIndicatorPosition(TOP); 177 | 178 | // Defines where the first frame is located in the bar. 179 | ui.setIndicatorDirection(LEFT_RIGHT); 180 | 181 | // You can change the transition that is used 182 | // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN 183 | ui.setFrameAnimation(SLIDE_LEFT); 184 | 185 | // Add frames 186 | ui.setFrames(frames, frameCount); 187 | 188 | // Add overlays 189 | ui.setOverlays(overlays, overlaysCount); 190 | 191 | // Initialising the UI will init the display too. 192 | ui.init(); 193 | 194 | display.flipScreenVertically(); 195 | 196 | unsigned long secsSinceStart = millis(); 197 | // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: 198 | const unsigned long seventyYears = 2208988800UL; 199 | // subtract seventy years: 200 | unsigned long epoch = secsSinceStart - seventyYears * SECS_PER_HOUR; 201 | setTime(epoch); 202 | 203 | } 204 | 205 | 206 | void loop() { 207 | int remainingTimeBudget = ui.update(); 208 | 209 | if (remainingTimeBudget > 0) { 210 | // You can do some work here 211 | // Don't do stuff if you are below your 212 | // time budget. 213 | delay(remainingTimeBudget); 214 | 215 | } 216 | 217 | 218 | } 219 | -------------------------------------------------------------------------------- /ESP32_OLED_Demo/images.h: -------------------------------------------------------------------------------- 1 | const char activeSymbol[] PROGMEM = { 2 | B00000000, 3 | B00000000, 4 | B00011000, 5 | B00100100, 6 | B01000010, 7 | B01000010, 8 | B00100100, 9 | B00011000 10 | }; 11 | 12 | const char inactiveSymbol[] PROGMEM = { 13 | B00000000, 14 | B00000000, 15 | B00000000, 16 | B00000000, 17 | B00011000, 18 | B00011000, 19 | B00000000, 20 | B00000000 21 | }; 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP32-Board-Test 2 | Supporting Material to YouTube video https://www.youtube.com/watch?v=3O_vrKAmshA 3 | --------------------------------------------------------------------------------