├── .gitignore ├── D1_mini_Examples.cpp ├── D1_mini_Examples.h ├── README.md ├── examples ├── 01.Basics │ ├── BasicIO │ │ └── BasicIO.ino │ ├── Blink │ │ ├── Blink.ino │ │ └── Blink.txt │ ├── BlinkWithoutDelay │ │ └── BlinkWithoutDelay.ino │ ├── Fade │ │ └── Fade.ino │ ├── HelloWorld │ │ └── HelloWorld.ino │ ├── IOTest │ │ └── IOTest.ino │ └── ReadAnalogVoltage │ │ ├── ReadAnalogVoltage.ino │ │ └── ReadAnalogVoltage.txt ├── 02.Special │ ├── CallSDKFunctions │ │ └── CallSDKFunctions.ino │ ├── CheckFlashConfig │ │ └── CheckFlashConfig.ino │ ├── ConfigFile │ │ └── ConfigFile.ino │ ├── DeepSleep │ │ └── Blink │ │ │ └── Blink.ino │ ├── EEPROM │ │ ├── eeprom_clear │ │ │ └── eeprom_clear.ino │ │ ├── eeprom_read │ │ │ └── eeprom_read.ino │ │ └── eeprom_write │ │ │ └── eeprom_write.ino │ ├── GetChipID │ │ └── GetChipID.ino │ ├── Hash │ │ ├── md5 │ │ │ └── md5.ino │ │ └── sha1 │ │ │ └── sha1.ino │ ├── Servo │ │ └── Sweep │ │ │ └── Sweep.ino │ ├── Ticker │ │ ├── TickerBasic │ │ │ └── TickerBasic.ino │ │ └── TickerParameter │ │ │ └── TickerParameter.ino │ └── Wire │ │ ├── I2C_Scanner │ │ └── I2C_Scanner.ino │ │ └── i2cdetect │ │ └── i2cdetect.ino ├── 03.Sensors │ ├── BMP180_BMP085 │ │ └── BMP180_BMP085.ino │ └── DS18x20_Temperature │ │ └── DS18x20_Temperature.ino ├── 04.Shields │ ├── 1_Button_Shield │ │ ├── DebounceToggleLED │ │ │ └── DebounceToggleLED.ino │ │ ├── SimplePush │ │ │ └── SimplePush.ino │ │ └── SwitchLibrary │ │ │ ├── Switch.cpp │ │ │ ├── Switch.h │ │ │ └── SwitchLibrary.ino │ ├── Ambient_Light_Shield(BH1750) │ │ ├── BH1750_OLED_test │ │ │ └── BH1750_OLED_test.ino │ │ └── simple │ │ │ └── simple.ino │ ├── Barometric_Pressure_HP303B_Shield │ │ ├── HP303B_OLED_TEST │ │ │ └── HP303B_OLED_TEST.ino │ │ └── simple │ │ │ └── simple.ino │ ├── Buzzer_Shield │ │ └── Do_Re_Mi │ │ │ └── Do_Re_Mi.ino │ ├── DHT_Pro_Shield │ │ └── Simple │ │ │ └── Simple.ino │ ├── DHT_Shield │ │ ├── DeepSleep │ │ │ └── DeepSleep.ino │ │ ├── Simple │ │ │ └── Simple.ino │ │ └── SimpleServer │ │ │ └── SimpleServer.ino │ ├── IR_Controller_Shield │ │ ├── IRrecvDumpV2 │ │ │ └── IRrecvDumpV2.ino │ │ ├── IRsend │ │ │ └── IRsend.ino │ │ └── test │ │ │ └── test.ino │ ├── Micro_SD_Shield │ │ ├── CardInfo │ │ │ └── CardInfo.ino │ │ ├── Datalogger │ │ │ └── Datalogger.ino │ │ ├── DumpFile │ │ │ └── DumpFile.ino │ │ ├── Files │ │ │ └── Files.ino │ │ ├── ReadWrite │ │ │ └── ReadWrite.ino │ │ └── listfiles │ │ │ └── listfiles.ino │ ├── OLED_0.49_Shield │ │ ├── simple │ │ │ ├── images.h │ │ │ └── simple.ino │ │ └── test │ │ │ └── test.ino │ ├── OLED_0.96_Shield │ │ ├── simple │ │ │ ├── images.h │ │ │ └── simple.ino │ │ └── test │ │ │ └── test.ino │ ├── OLED_Shield │ │ └── Use_SparkFun_Library │ │ │ ├── OLED_Clock_with_SparkFun │ │ │ └── OLED_Clock_with_SparkFun.ino │ │ │ ├── OLED_Cube_with_SparkFun │ │ │ └── OLED_Cube_with_SparkFun.ino │ │ │ ├── OLED_DrawBitmap_with_SparkFun │ │ │ └── OLED_DrawBitmap_with_SparkFun.ino │ │ │ ├── OLED_Hello_with_SparkFun │ │ │ └── OLED_Hello_with_SparkFun.ino │ │ │ └── OLED_TEST │ │ │ └── OLED_TEST.ino │ ├── PIR_Shield │ │ └── pir_simple │ │ │ └── pir_simple.ino │ ├── RGB_LED_Shield │ │ └── simple │ │ │ └── simple.ino │ ├── Relay_Shield │ │ ├── Blink │ │ │ └── Blink.ino │ │ └── BlinkWithoutDelay │ │ │ └── BlinkWithoutDelay.ino │ ├── SGP30_Shield │ │ ├── SGP30_OLED_test │ │ │ └── SGP30_OLED_test.ino │ │ └── simple │ │ │ └── simple.ino │ ├── TFT_1.4_Shield │ │ ├── simple │ │ │ └── simple.ino │ │ └── test │ │ │ └── test.ino │ ├── TFT_2.4_Touch_Shield │ │ ├── GraphicsTest │ │ │ └── GraphicsTest.ino │ │ ├── TFT_TouchTest │ │ │ └── TFT_TouchTest.ino │ │ └── TouchTest │ │ │ └── TouchTest.ino │ └── WS2812B_RGB_Shield │ │ └── simple │ │ └── simple.ino └── 05.Displays │ ├── NeoPixel-Stick │ └── examples │ │ └── examples.ino │ └── PCD8544-Nokia-5110-84x48 │ ├── conways-game-of-life │ └── conways-game-of-life.ino │ ├── cube │ └── cube.ino │ ├── hello-nokia │ ├── hello-nokia.ino │ ├── nokia-hands-84x48.h │ └── nokia-home-84x48.h │ ├── hello-wemos │ ├── hello-wemos.ino │ ├── wemos-logo-84x28.h │ ├── wemos-logo-84x48.h │ ├── wemos-w-53x48.h │ └── wemos-w-84x48.h │ ├── hello-world │ └── hello-world.ino │ ├── qr-code │ ├── qr-code-25x25.h │ └── qr-code.ino │ ├── rotate │ └── rotate.ino │ ├── screen-saver │ ├── cool-smiley-15x15.h │ ├── screen-saver.ino │ └── smiley-9x9.h │ ├── spiral-animation │ ├── spiral-1-84x48.h │ ├── spiral-2-84x48.h │ ├── spiral-3-84x48.h │ ├── spiral-4-84x48.h │ ├── spiral-5-84x48.h │ ├── spiral-6-84x48.h │ ├── spiral-7-84x48.h │ ├── spiral-8-84x48.h │ └── spiral-animation.ino │ └── wifi-signal-strength │ └── wifi-signal-strength.ino └── library.properties /.gitignore: -------------------------------------------------------------------------------- 1 | .tags_sorted_by_file 2 | 3 | .tags 4 | 5 | .vscode 6 | -------------------------------------------------------------------------------- /D1_mini_Examples.cpp: -------------------------------------------------------------------------------- 1 | /*WEMOS D1 mini Examples*/ -------------------------------------------------------------------------------- /D1_mini_Examples.h: -------------------------------------------------------------------------------- 1 | /*WEMOS D1 mini Examples*/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # D1_mini_Examples 2 | WeMos D1, D1 R2 & D1 mini Arduino Examples 3 | 4 | For more information, see the [WeMos website](http://www.wemos.cc/) or visit the [forum](http://forum.wemos.cc/). 5 | 6 | You can purchase the WeMos D1, D1 R2, D1 mini and various shields from our [AliExpress store](http://www.aliexpress.com/store/1331105). 7 | -------------------------------------------------------------------------------- /examples/01.Basics/BasicIO/BasicIO.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Basic IO 3 | * Use a pushbutton to toggle the onboard LED. 4 | * 5 | * If you do not have the 1 Button Shield, add a pushbutton or switch between D3 and GND 6 | */ 7 | 8 | int inputPin = D3; // pushbutton connected to digital pin D3 9 | int val = 0; // variable to store the read value 10 | 11 | void setup() { 12 | pinMode(BUILTIN_LED, OUTPUT); // set onboard LED as output 13 | pinMode(inputPin, INPUT); // set pin as input 14 | } 15 | 16 | void loop() { 17 | val = digitalRead(inputPin); // read the input pin 18 | digitalWrite(BUILTIN_LED, val); // sets the LED to the button's value 19 | } 20 | -------------------------------------------------------------------------------- /examples/01.Basics/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Blink 3 | * Turns on the onboard LED on for one second, then off for one second, repeatedly. 4 | * This uses delay() to pause between LED toggles. 5 | */ 6 | 7 | void setup() { 8 | pinMode(BUILTIN_LED, OUTPUT); // initialize onboard LED as output 9 | } 10 | 11 | void loop() { 12 | digitalWrite(BUILTIN_LED, HIGH); // turn on LED with voltage HIGH 13 | delay(1000); // wait one second 14 | digitalWrite(BUILTIN_LED, LOW); // turn off LED with voltage LOW 15 | delay(1000); // wait one second 16 | } 17 | -------------------------------------------------------------------------------- /examples/01.Basics/Blink/Blink.txt: -------------------------------------------------------------------------------- 1 | Turn an LED on and off. -------------------------------------------------------------------------------- /examples/01.Basics/BlinkWithoutDelay/BlinkWithoutDelay.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Blink Without Delay 3 | * Turns on the onboard LED on for one second, then off for one second, repeatedly. 4 | * This uses millis() instead of delay() to avoid blocking. 5 | */ 6 | 7 | const long interval = 1000; 8 | 9 | int ledState = LOW; 10 | unsigned long previousMillis = 0; 11 | 12 | void setup() { 13 | pinMode(BUILTIN_LED, OUTPUT); // initialize onboard LED as output 14 | } 15 | 16 | void loop() { 17 | unsigned long currentMillis = millis(); 18 | 19 | // if enough millis have elapsed 20 | if (currentMillis - previousMillis >= interval) { 21 | previousMillis = currentMillis; 22 | 23 | // toggle the LED 24 | ledState = !ledState; 25 | digitalWrite(BUILTIN_LED, ledState); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/01.Basics/Fade/Fade.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Fade 3 | * Using PWM to fade the onboard LED. 4 | */ 5 | 6 | const int ledPin = BUILTIN_LED; // the onboard LED 7 | int brightness = 0; // how bright the LED is (0 = full, 512 = dim, 1023 = off) 8 | int fadeAmount = 5; // how many points to fade the LED by 9 | const int delayMillis = 10; // how long to pause between each loop 10 | 11 | void setup() { 12 | pinMode(ledPin, OUTPUT); // initialize onboard LED as output 13 | } 14 | 15 | void loop() { 16 | // set the LED brightness 17 | analogWrite(ledPin, brightness); 18 | 19 | // increment/decrement the brightness for the next loop 20 | brightness = brightness + fadeAmount; 21 | 22 | // limit to 10-bit (0-1023) 23 | if (brightness < 0) brightness = 0; 24 | if (brightness > 1023) brightness = 1023; 25 | 26 | // reverse the direction of the fading at each end 27 | if (brightness == 0 || brightness == 1023) { 28 | fadeAmount = -fadeAmount; 29 | } 30 | 31 | // pause so you can see each brightness level 32 | delay(delayMillis); 33 | } 34 | -------------------------------------------------------------------------------- /examples/01.Basics/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Hello World 3 | * Simply prints Hello World to the serial monitor. 4 | */ 5 | 6 | void setup() { 7 | // initialize serial communications at 9600 bps 8 | Serial.begin(9600); 9 | } 10 | 11 | void loop() { 12 | Serial.println("Hello World."); 13 | delay(2000); 14 | } 15 | -------------------------------------------------------------------------------- /examples/01.Basics/IOTest/IOTest.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IO test 3 | * 4 | * 5 | * 6 | */ 7 | 8 | int pins[9]={D0,D1,D2,D3,D4,D5,D6,D7,D8}; 9 | 10 | 11 | void setup() { 12 | 13 | for(int i=0;i<9;i++) 14 | { 15 | pinMode(pins[i],OUTPUT); 16 | digitalWrite(pins[i],0); 17 | } 18 | } 19 | 20 | void loop() { 21 | 22 | for(int i=0;i<9;i++) 23 | { 24 | digitalWrite(pins[i],1); 25 | delay(10); 26 | digitalWrite(pins[i],0); 27 | delay(10); 28 | } 29 | delay(1000); 30 | } 31 | -------------------------------------------------------------------------------- /examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ReadAnalogVoltage 3 | The ESP8266EX(Which IC D1 board used) integrates a generic purpose 10-bit analog ADC. The ADC range is from 0V to 1.0V 4 | And on the board, we use following circuit: 5 | 6 | -----A0 7 | | 8 | 220K 9 | |--- ADC 10 | 100K 11 | | 12 | GND 13 | 14 | so,the input voltage(A0) can be 3.2V, and the A0=3.2*ADC 15 | 16 | */ 17 | 18 | // the setup routine runs once when you press reset: 19 | void setup() { 20 | // initialize serial communication at 115200 bits per second: 21 | Serial.begin(115200); 22 | } 23 | 24 | // the loop routine runs over and over again forever: 25 | void loop() { 26 | // read the input on analog pin 0: 27 | int sensorValue = analogRead(A0); 28 | // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.2V): 29 | float voltage = sensorValue * (3.2 / 1023.0); 30 | // print out the value you read: 31 | Serial.println(voltage); 32 | } 33 | -------------------------------------------------------------------------------- /examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.txt: -------------------------------------------------------------------------------- 1 | Reads an analog input and prints the voltage to the serial monitor. -------------------------------------------------------------------------------- /examples/02.Special/CallSDKFunctions/CallSDKFunctions.ino: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * NativeSdk by Simon Peter 4 | * Access functionality from the Espressif ESP8266 SDK 5 | * This example code is in the public domain 6 | * 7 | * This is for advanced users. 8 | * Note that this makes your code dependent on the ESP8266, which is generally 9 | * a bad idea. So you should try to use esp8266/Arduino functionality 10 | * where possible instead, in order to abstract away the hardware dependency. 11 | * 12 | * https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/CallSDKFunctions/CallSDKFunctions.ino 13 | */ 14 | 15 | // Expose Espressif SDK functionality - wrapped in ifdef so that it still 16 | // compiles on other platforms 17 | #ifdef ESP8266 18 | extern "C" { 19 | #include "user_interface.h" 20 | } 21 | #endif 22 | 23 | void setup() { 24 | Serial.begin(115200); 25 | } 26 | 27 | void loop() { 28 | // Call Espressif SDK functionality - wrapped in ifdef so that it still 29 | // compiles on other platforms 30 | #ifdef ESP8266 31 | Serial.print("wifi_station_get_hostname: "); 32 | Serial.println(wifi_station_get_hostname()); 33 | #endif 34 | delay(1000); 35 | } 36 | -------------------------------------------------------------------------------- /examples/02.Special/CheckFlashConfig/CheckFlashConfig.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ESP8266 CheckFlashConfig by Markus Sattler 3 | * 4 | * This sketch tests if the EEPROM settings of the IDE match to the Hardware 5 | * 6 | * https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/CheckFlashConfig/CheckFlashConfig.ino 7 | */ 8 | 9 | void setup(void) { 10 | Serial.begin(115200); 11 | } 12 | 13 | void loop() { 14 | uint32_t realSize = ESP.getFlashChipRealSize(); 15 | uint32_t ideSize = ESP.getFlashChipSize(); 16 | FlashMode_t ideMode = ESP.getFlashChipMode(); 17 | 18 | Serial.printf("Flash real id: %08X\n", ESP.getFlashChipId()); 19 | Serial.printf("Flash real size: %u\n\n", realSize); 20 | 21 | Serial.printf("Flash ide size: %u\n", ideSize); 22 | Serial.printf("Flash ide speed: %u\n", ESP.getFlashChipSpeed()); 23 | Serial.printf("Flash ide mode: %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN")); 24 | 25 | if (ideSize != realSize) { 26 | Serial.println("Flash Chip configuration wrong!\n"); 27 | } else { 28 | Serial.println("Flash Chip configuration ok.\n"); 29 | } 30 | 31 | delay(5000); 32 | } 33 | -------------------------------------------------------------------------------- /examples/02.Special/ConfigFile/ConfigFile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Example: storing JSON configuration file in flash file system 3 | * 4 | * Uses ArduinoJson library by Benoit Blanchon. 5 | * https://github.com/bblanchon/ArduinoJson 6 | * 7 | * Created Aug 10, 2015 by Ivan Grokhotkov. 8 | * 9 | * This example code is in the public domain. 10 | * https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/ConfigFile/ConfigFile.ino 11 | */ 12 | 13 | #include 14 | #include "FS.h" 15 | 16 | bool loadConfig() { 17 | File configFile = SPIFFS.open("/config.json", "r"); 18 | if (!configFile) { 19 | Serial.println("Failed to open config file"); 20 | return false; 21 | } 22 | 23 | size_t size = configFile.size(); 24 | if (size > 1024) { 25 | Serial.println("Config file size is too large"); 26 | return false; 27 | } 28 | 29 | // Allocate a buffer to store contents of the file. 30 | std::unique_ptr buf(new char[size]); 31 | 32 | // We don't use String here because ArduinoJson library requires the input 33 | // buffer to be mutable. If you don't use ArduinoJson, you may as well 34 | // use configFile.readString instead. 35 | configFile.readBytes(buf.get(), size); 36 | 37 | StaticJsonBuffer<200> jsonBuffer; 38 | JsonObject& json = jsonBuffer.parseObject(buf.get()); 39 | 40 | if (!json.success()) { 41 | Serial.println("Failed to parse config file"); 42 | return false; 43 | } 44 | 45 | const char* serverName = json["serverName"]; 46 | const char* accessToken = json["accessToken"]; 47 | 48 | // Real world application would store these values in some variables for 49 | // later use. 50 | 51 | Serial.print("Loaded serverName: "); 52 | Serial.println(serverName); 53 | Serial.print("Loaded accessToken: "); 54 | Serial.println(accessToken); 55 | return true; 56 | } 57 | 58 | bool saveConfig() { 59 | StaticJsonBuffer<200> jsonBuffer; 60 | JsonObject& json = jsonBuffer.createObject(); 61 | json["serverName"] = "api.example.com"; 62 | json["accessToken"] = "128du9as8du12eoue8da98h123ueh9h98"; 63 | 64 | File configFile = SPIFFS.open("/config.json", "w"); 65 | if (!configFile) { 66 | Serial.println("Failed to open config file for writing"); 67 | return false; 68 | } 69 | 70 | json.printTo(configFile); 71 | return true; 72 | } 73 | 74 | void setup() { 75 | Serial.begin(115200); 76 | Serial.println(""); 77 | delay(1000); 78 | Serial.println("Mounting FS..."); 79 | 80 | if (!SPIFFS.begin()) { 81 | Serial.println("Failed to mount file system"); 82 | return; 83 | } 84 | 85 | if (!saveConfig()) { 86 | Serial.println("Failed to save config"); 87 | } else { 88 | Serial.println("Config saved"); 89 | } 90 | 91 | if (!loadConfig()) { 92 | Serial.println("Failed to load config"); 93 | } else { 94 | Serial.println("Config loaded"); 95 | } 96 | } 97 | 98 | void loop() { 99 | } 100 | -------------------------------------------------------------------------------- /examples/02.Special/DeepSleep/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* Deep Sleep - Blink 2 | * 3 | * Blinks the onboard LED, sleeps for 10 seconds and repeats 4 | * 5 | * Connections: 6 | * D0 -- RST 7 | * 8 | * If you cant reprogram as the ESP is sleeping, disconnect D0 - RST and try again 9 | */ 10 | 11 | // sleep for this many seconds 12 | const int sleepSeconds = 5; 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | Serial.println("\n\nWake up"); 17 | 18 | pinMode(BUILTIN_LED, OUTPUT); 19 | 20 | // Connect D0 to RST to wake up 21 | pinMode(D0, WAKEUP_PULLUP); 22 | 23 | // LED: LOW = on, HIGH = off 24 | Serial.println("Start blinking"); 25 | for (int i = 0; i < 20; i++) 26 | { 27 | digitalWrite(BUILTIN_LED, LOW); 28 | delay(100); 29 | digitalWrite(BUILTIN_LED, HIGH); 30 | delay(100); 31 | } 32 | Serial.println("Stop blinking"); 33 | 34 | Serial.printf("Sleep for %d seconds\n\n", sleepSeconds); 35 | 36 | // convert to microseconds 37 | ESP.deepSleep(sleepSeconds * 1000000); 38 | } 39 | 40 | void loop() { 41 | } 42 | -------------------------------------------------------------------------------- /examples/02.Special/EEPROM/eeprom_clear/eeprom_clear.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Clear 3 | * 4 | * Sets all of the bytes of the EEPROM to 0. 5 | * 6 | * This example code is in the public domain. 7 | * https://github.com/esp8266/Arduino/blob/master/libraries/EEPROM/examples/eeprom_clear/eeprom_clear.ino 8 | */ 9 | 10 | #include 11 | 12 | void setup() 13 | { 14 | EEPROM.begin(512); 15 | // write a 0 to all 512 bytes of the EEPROM 16 | for (int i = 0; i < 512; i++) 17 | EEPROM.write(i, 0); 18 | 19 | // turn the LED on when we're done 20 | pinMode(13, OUTPUT); 21 | digitalWrite(13, HIGH); 22 | EEPROM.end(); 23 | } 24 | 25 | void loop() 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /examples/02.Special/EEPROM/eeprom_read/eeprom_read.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Read 3 | * 4 | * Reads the value of each byte of the EEPROM and prints it 5 | * to the computer. 6 | * 7 | * This example code is in the public domain. 8 | * https://github.com/esp8266/Arduino/blob/master/libraries/EEPROM/examples/eeprom_read/eeprom_read.ino 9 | */ 10 | 11 | #include 12 | 13 | // start reading from the first byte (address 0) of the EEPROM 14 | int address = 0; 15 | byte value; 16 | 17 | void setup() 18 | { 19 | // initialize serial and wait for port to open: 20 | Serial.begin(9600); 21 | while (!Serial) { 22 | ; // wait for serial port to connect. Needed for Leonardo only 23 | } 24 | EEPROM.begin(512); 25 | } 26 | 27 | void loop() 28 | { 29 | // read a byte from the current address of the EEPROM 30 | value = EEPROM.read(address); 31 | 32 | Serial.print(address); 33 | Serial.print("\t"); 34 | Serial.print(value, DEC); 35 | Serial.println(); 36 | 37 | // advance to the next address of the EEPROM 38 | address = address + 1; 39 | 40 | // there are only 512 bytes of EEPROM, from 0 to 511, so if we're 41 | // on address 512, wrap around to address 0 42 | if (address == 512) 43 | address = 0; 44 | 45 | delay(500); 46 | } 47 | -------------------------------------------------------------------------------- /examples/02.Special/EEPROM/eeprom_write/eeprom_write.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * EEPROM Write 3 | * 4 | * Stores values read from analog input 0 into the EEPROM. 5 | * These values will stay in the EEPROM when the board is 6 | * turned off and may be retrieved later by another sketch. 7 | * 8 | * This example code is in the public domain. 9 | * https://github.com/esp8266/Arduino/blob/master/libraries/EEPROM/examples/eeprom_write/eeprom_write.ino 10 | */ 11 | 12 | #include 13 | 14 | // the current address in the EEPROM (i.e. which byte 15 | // we're going to write to next) 16 | int address = 0; 17 | 18 | void setup() 19 | { 20 | EEPROM.begin(512); 21 | } 22 | 23 | void loop() 24 | { 25 | // need to divide by 4 because analog inputs range from 26 | // 0 to 1023 and each byte of the EEPROM can only hold a 27 | // value from 0 to 255. 28 | int val = analogRead(A0) / 4; 29 | 30 | // write the value to the appropriate byte of the EEPROM. 31 | // these values will remain there when the board is 32 | // turned off. 33 | EEPROM.write(address, val); 34 | 35 | // advance to the next address. there are 512 bytes in 36 | // the EEPROM, so go back to 0 when we hit 512. 37 | // save all changes to the flash. 38 | address = address + 1; 39 | if (address == 512) 40 | { 41 | address = 0; 42 | EEPROM.commit(); 43 | } 44 | 45 | delay(100); 46 | } 47 | -------------------------------------------------------------------------------- /examples/02.Special/GetChipID/GetChipID.ino: -------------------------------------------------------------------------------- 1 | /* Get Chip ID 2 | * wemos.cc 3 | * 4 | * 5 | */ 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | } 10 | 11 | void loop() { 12 | Serial.println(""); 13 | Serial.println(""); 14 | Serial.println("Check ID in:"); 15 | Serial.println("https://www.wemos.cc/verify_products"); 16 | Serial.printf("Chip ID = %08X\n", ESP.getChipId()); 17 | Serial.println(""); 18 | Serial.println(""); 19 | delay(5000); 20 | } 21 | -------------------------------------------------------------------------------- /examples/02.Special/Hash/md5/md5.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple demo to show md5 calculation 3 | * 4 | * https://github.com/esp8266/Arduino/blob/master/cores/esp8266/md5.h 5 | */ 6 | 7 | #include 8 | 9 | MD5Builder _md5; 10 | 11 | String md5(String str) { 12 | _md5.begin(); 13 | _md5.add(String(str)); 14 | _md5.calculate(); 15 | return _md5.toString(); 16 | } 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | 21 | Serial.println("MD5 example\n"); 22 | 23 | Serial.println("MD5 (\"foo\") = acbd18db4cc2f85cedef654fccc4a4d8 (known)"); 24 | Serial.print("MD5 (\"foo\") = "); 25 | Serial.print(md5("foo")); 26 | Serial.println(" (calculated)\n"); 27 | 28 | Serial.println("MD5 (\"bar\") = 37b51d194a7513e45b56f6524f2d51f2 (known)"); 29 | Serial.print("MD5 (\"bar\") = "); 30 | Serial.print(md5("bar")); 31 | Serial.println(" (calculated)\n"); 32 | 33 | Serial.println("MD5 (\"wemos d1 mini\") = c4594198428b13c196b05161d3e9c86e (known)"); 34 | Serial.print("MD5 (\"wemos d1 mini\") = "); 35 | Serial.print(md5("wemos d1 mini")); 36 | Serial.println(" (calculated)\n"); 37 | } 38 | 39 | void loop() { 40 | } 41 | -------------------------------------------------------------------------------- /examples/02.Special/Hash/sha1/sha1.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple demo to show sha1 calculation 3 | * 4 | * https://github.com/esp8266/Arduino/blob/master/libraries/Hash/examples/sha1/sha1.ino 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | void setup() { 11 | Serial.begin(9600); 12 | } 13 | 14 | void loop() { 15 | 16 | // usage as String 17 | // SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 18 | 19 | Serial.print("SHA1:"); 20 | Serial.println(sha1("abc")); 21 | 22 | // usage as ptr 23 | // SHA1:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 24 | uint8_t hash[20]; 25 | sha1("abc", &hash[0]); 26 | 27 | Serial.print("SHA1:"); 28 | for (uint16_t i = 0; i < 20; i++) { 29 | Serial.printf("%02x", hash[i]); 30 | } 31 | Serial.println(); 32 | 33 | delay(1000); 34 | } 35 | -------------------------------------------------------------------------------- /examples/02.Special/Servo/Sweep/Sweep.ino: -------------------------------------------------------------------------------- 1 | /* Servo - Sweep 2 | * by BARRAGAN 3 | * This example code is in the public domain. 4 | * 5 | * modified 28 May 2015 by Michael C. Miller 6 | * modified 8 Nov 2013 by Scott Fitzgerald 7 | * 8 | * http://arduino.cc/en/Tutorial/Sweep 9 | * https://github.com/esp8266/Arduino/blob/master/libraries/Servo/examples/Sweep/Sweep.ino 10 | */ 11 | 12 | #include 13 | 14 | Servo myservo; // create servo object to control a servo 15 | // twelve servo objects can be created on most boards 16 | 17 | void setup() 18 | { 19 | myservo.attach(2); // attaches the servo on GPIO2 to the servo object 20 | } 21 | 22 | void loop() 23 | { 24 | int pos; 25 | 26 | for (pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees 27 | { // in steps of 1 degree 28 | myservo.write(pos); // tell servo to go to position in variable 'pos' 29 | delay(15); // waits 15ms for the servo to reach the position 30 | } 31 | for (pos = 180; pos >= 0; pos -= 1) // goes from 180 degrees to 0 degrees 32 | { 33 | myservo.write(pos); // tell servo to go to position in variable 'pos' 34 | delay(15); // waits 15ms for the servo to reach the position 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/02.Special/Ticker/TickerBasic/TickerBasic.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic Ticker usage 3 | 4 | Ticker is an object that will call a given function with a certain period. 5 | Each Ticker calls one function. You can have as many Tickers as you like, 6 | memory being the only limitation. 7 | 8 | A function may be attached to a ticker and detached from the ticker. 9 | There are two variants of the attach function: attach and attach_ms. 10 | The first one takes period in seconds, the second one in milliseconds. 11 | 12 | An LED connected to D13 will be blinking. 13 | */ 14 | 15 | #include 16 | 17 | Ticker flipper; 18 | 19 | int count = 0; 20 | 21 | void flip() 22 | { 23 | int state = digitalRead(D13); // get the current state of GPIO1 pin 24 | digitalWrite(D13, !state); // set pin to the opposite state 25 | 26 | ++count; 27 | // when the counter reaches a certain value, start blinking like crazy 28 | if (count == 20) 29 | { 30 | flipper.attach(0.1, flip); 31 | } 32 | // when the counter reaches yet another value, stop blinking 33 | else if (count == 120) 34 | { 35 | flipper.detach(); 36 | } 37 | } 38 | 39 | void setup() { 40 | pinMode(D13, OUTPUT); 41 | digitalWrite(D13, LOW); 42 | 43 | // flip the pin every 0.3s 44 | flipper.attach(0.3, flip); 45 | } 46 | 47 | void loop() { 48 | } 49 | -------------------------------------------------------------------------------- /examples/02.Special/Ticker/TickerParameter/TickerParameter.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Passing paramters to Ticker callbacks 3 | 4 | Apart from void(void) functions, the Ticker library supports 5 | functions taking one argument. This argument's size has to be less or 6 | equal to 4 bytes (so char, short, int, float, void*, char* types will do). 7 | 8 | This sample runs two tickers that both call one callback function, 9 | but with different arguments. 10 | 11 | An LED connected to D13 will be pulsing. 12 | */ 13 | 14 | #include 15 | 16 | Ticker tickerSetHigh; 17 | Ticker tickerSetLow; 18 | 19 | void setPin(int state) { 20 | digitalWrite(D13, state); 21 | } 22 | 23 | void setup() { 24 | pinMode(D13, OUTPUT); 25 | digitalWrite(D13, LOW); 26 | 27 | // every 25 ms, call setPin(0) 28 | tickerSetLow.attach_ms(25, setPin, 0); 29 | 30 | // every 26 ms, call setPin(D13) 31 | tickerSetHigh.attach_ms(26, setPin, 1); 32 | } 33 | 34 | void loop() { 35 | } 36 | -------------------------------------------------------------------------------- /examples/02.Special/Wire/I2C_Scanner/I2C_Scanner.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Wire - I2C Scanner 3 | * 4 | * The WeMos D1 Mini I2C bus uses pins: 5 | * D1 = SCL 6 | * D2 = SDA 7 | */ 8 | 9 | #include 10 | 11 | const int sclPin = D1; 12 | const int sdaPin = D2; 13 | 14 | void setup() 15 | { 16 | Wire.begin(sdaPin, sclPin); 17 | 18 | Serial.begin(9600); 19 | Serial.println("I2C Scanner"); 20 | } 21 | 22 | void loop() 23 | { 24 | byte error, address; 25 | int nDevices; 26 | 27 | Serial.println("Scanning..."); 28 | 29 | nDevices = 0; 30 | for (address = 1; address < 127; address++) 31 | { 32 | // The i2c scanner uses the return value of 33 | // the Write.endTransmisstion to see if 34 | // a device did acknowledge to the address. 35 | Wire.beginTransmission(address); 36 | error = Wire.endTransmission(); 37 | 38 | if (error == 0) 39 | { 40 | Serial.print("I2C device found at address 0x"); 41 | if (address < 16) { 42 | Serial.print("0"); 43 | } 44 | Serial.print(address, HEX); 45 | Serial.println(" !"); 46 | 47 | nDevices++; 48 | } 49 | else if (error == 4) 50 | { 51 | Serial.print("Unknown error at address 0x"); 52 | if (address < 16) { 53 | Serial.print("0"); 54 | } 55 | Serial.println(address, HEX); 56 | } 57 | } 58 | if (nDevices == 0) { 59 | Serial.println("No I2C devices found\n"); 60 | } 61 | else { 62 | Serial.println("Done.\n"); 63 | } 64 | 65 | delay(2000); 66 | } 67 | -------------------------------------------------------------------------------- /examples/02.Special/Wire/i2cdetect/i2cdetect.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Scan I2C bus for devices. 3 | * Outputs a table similar to the i2cdetect linux program. 4 | * 5 | * Connect a device to the I2C bus and it will appear in the table. 6 | * D1 = SCL 7 | * D2 = SDA 8 | * 9 | * Dependencies: 10 | * https://github.com/mcauser/i2cdetect 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | void setup() { 17 | Wire.begin(); 18 | Serial.begin(9600); 19 | Serial.println("i2cdetect\n"); 20 | Serial.print("Scanning...\n\n"); 21 | } 22 | 23 | void loop() { 24 | //eg. i2cdetect(from=0x03, to=0x77); 25 | i2cdetect(); // default range from 0x03 to 0x77 26 | delay(2000); 27 | } 28 | -------------------------------------------------------------------------------- /examples/03.Sensors/BMP180_BMP085/BMP180_BMP085.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Digital barometric pressure and temperature sensor with I2C interface. 3 | * The Adafruit_BMP085 library supports both the Bosch BMP085 and BMP180 sensors. 4 | * The BMP085 has been discontinued and replaced with the BMP180 which is smaller and less expensive but is identical in terms of wiring and software. 5 | * 6 | * Features: 7 | * Pressure range: 300-1100 hPa (-500m to +9000m above sea level) 8 | * Supply voltage: 1.8-3.6V 9 | * Low power: 5µa at 1 sample / sec in standard mode, 0.1µa in stand by 10 | * Up to 0.03hPa / 0.25m resolution 11 | * -40 to +85°C operational range, ±2°C temperature accuracy 12 | * 13 | * Uses I2C address 0x77 14 | * 15 | * Connections: 16 | * D1 Mini BMP180 / BMP085 17 | * D1 (SCL) -- SCL 18 | * D2 (SDA) -- SDA 19 | * 3V3 ------- VCC 20 | * G --------- GND 21 | * 22 | * Dependencies: 23 | * https://github.com/adafruit/Adafruit-BMP085-Library 24 | */ 25 | 26 | /*************************************************** 27 | This is an example for the BMP085 Barometric Pressure & Temp Sensor 28 | 29 | Designed specifically to work with the Adafruit BMP085 Breakout 30 | ----> https://www.adafruit.com/products/391 31 | ----> http://www.adafruit.com/products/1603 32 | 33 | These displays use I2C to communicate, 2 pins are required to interface 34 | Adafruit invests time and resources providing this open source code, 35 | please support Adafruit and open-source hardware by purchasing 36 | products from Adafruit! 37 | 38 | Written by Limor Fried/Ladyada for Adafruit Industries. 39 | BSD license, all text above must be included in any redistribution 40 | ****************************************************/ 41 | 42 | #include 43 | #include 44 | 45 | Adafruit_BMP085 bmp; 46 | 47 | void setup() { 48 | Serial.begin(9600); 49 | if (!bmp.begin()) { 50 | Serial.println("Could not find BMP180 or BMP085 sensor at 0x77"); 51 | while (1) {} 52 | } 53 | } 54 | 55 | void loop() { 56 | Serial.print("Temperature = "); 57 | Serial.print(bmp.readTemperature()); 58 | Serial.println(" °C"); 59 | 60 | Serial.print("Pressure = "); 61 | Serial.print(bmp.readPressure()); 62 | Serial.println(" Pa"); 63 | 64 | // Calculate altitude assuming 'standard' barometric 65 | // pressure of 1013.25 millibar = 101325 Pascal 66 | Serial.print("Altitude = "); 67 | Serial.print(bmp.readAltitude()); 68 | Serial.println(" meters"); 69 | 70 | Serial.print("Pressure at sea level (calculated) = "); 71 | Serial.print(bmp.readSealevelPressure()); 72 | Serial.println(" Pa"); 73 | 74 | // you can get a more precise measurement of altitude 75 | // if you know the current sea level pressure which will 76 | // vary with weather and such. If it is 1015 millibars 77 | // that is equal to 101500 Pascals. 78 | Serial.print("Real altitude = "); 79 | Serial.print(bmp.readAltitude(101500)); 80 | Serial.println(" meters"); 81 | 82 | Serial.println(); 83 | delay(500); 84 | } 85 | -------------------------------------------------------------------------------- /examples/03.Sensors/DS18x20_Temperature/DS18x20_Temperature.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // OneWire DS18S20, DS18B20, DS1822 Temperature Example 4 | // 5 | // http://www.pjrc.com/teensy/td_libs_OneWire.html 6 | // 7 | // The DallasTemperature library can do all this work for you! 8 | // http://milesburton.com/Dallas_Temperature_Control_Library 9 | 10 | OneWire ds(D2); // on pin D2 (a 4.7K resistor is necessary) 11 | 12 | void setup(void) { 13 | Serial.begin(9600); 14 | } 15 | 16 | void loop(void) { 17 | byte i; 18 | byte present = 0; 19 | byte type_s; 20 | byte data[12]; 21 | byte addr[8]; 22 | float celsius, fahrenheit; 23 | 24 | if ( !ds.search(addr)) { 25 | Serial.println("No more addresses."); 26 | Serial.println(); 27 | ds.reset_search(); 28 | delay(250); 29 | return; 30 | } 31 | 32 | Serial.print("ROM ="); 33 | for( i = 0; i < 8; i++) { 34 | Serial.write(' '); 35 | Serial.print(addr[i], HEX); 36 | } 37 | 38 | if (OneWire::crc8(addr, 7) != addr[7]) { 39 | Serial.println("CRC is not valid!"); 40 | return; 41 | } 42 | Serial.println(); 43 | 44 | // the first ROM byte indicates which chip 45 | switch (addr[0]) { 46 | case 0x10: 47 | Serial.println(" Chip = DS18S20"); // or old DS1820 48 | type_s = 1; 49 | break; 50 | case 0x28: 51 | Serial.println(" Chip = DS18B20"); 52 | type_s = 0; 53 | break; 54 | case 0x22: 55 | Serial.println(" Chip = DS1822"); 56 | type_s = 0; 57 | break; 58 | default: 59 | Serial.println("Device is not a DS18x20 family device."); 60 | return; 61 | } 62 | 63 | ds.reset(); 64 | ds.select(addr); 65 | ds.write(0x44, 1); // start conversion, with parasite power on at the end 66 | 67 | delay(1000); // maybe 750ms is enough, maybe not 68 | // we might do a ds.depower() here, but the reset will take care of it. 69 | 70 | present = ds.reset(); 71 | ds.select(addr); 72 | ds.write(0xBE); // Read Scratchpad 73 | 74 | Serial.print(" Data = "); 75 | Serial.print(present, HEX); 76 | Serial.print(" "); 77 | for ( i = 0; i < 9; i++) { // we need 9 bytes 78 | data[i] = ds.read(); 79 | Serial.print(data[i], HEX); 80 | Serial.print(" "); 81 | } 82 | Serial.print(" CRC="); 83 | Serial.print(OneWire::crc8(data, 8), HEX); 84 | Serial.println(); 85 | 86 | // Convert the data to actual temperature 87 | // because the result is a 16 bit signed integer, it should 88 | // be stored to an "int16_t" type, which is always 16 bits 89 | // even when compiled on a 32 bit processor. 90 | int16_t raw = (data[1] << 8) | data[0]; 91 | if (type_s) { 92 | raw = raw << 3; // 9 bit resolution default 93 | if (data[7] == 0x10) { 94 | // "count remain" gives full 12 bit resolution 95 | raw = (raw & 0xFFF0) + 12 - data[6]; 96 | } 97 | } else { 98 | byte cfg = (data[4] & 0x60); 99 | // at lower res, the low bits are undefined, so let's zero them 100 | if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms 101 | else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms 102 | else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms 103 | //// default is 12 bit resolution, 750 ms conversion time 104 | } 105 | celsius = (float)raw / 16.0; 106 | fahrenheit = celsius * 1.8 + 32.0; 107 | Serial.print(" Temperature = "); 108 | Serial.print(celsius); 109 | Serial.print(" Celsius, "); 110 | Serial.print(fahrenheit); 111 | Serial.println(" Fahrenheit"); 112 | } 113 | -------------------------------------------------------------------------------- /examples/04.Shields/1_Button_Shield/DebounceToggleLED/DebounceToggleLED.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 1 Button Shield - Debounce Toggle LED 3 | * Press the pushbutton to toggle the LED 4 | * 5 | * Pushbuttons often generate spurious open/close transitions when pressed, due to mechanical and physical issues. 6 | * This example demonstrates how to debounce an input, which means checking twice in a short period of time to make sure the pushbutton is definitely pressed. 7 | * 8 | * 1 Button Shield pushbutton connects pin D3 to GND 9 | */ 10 | 11 | const int buttonPin = D3; 12 | const int ledPin = BUILTIN_LED; 13 | 14 | // the current state of the LED and button 15 | int ledState = LOW; 16 | int buttonState = LOW; 17 | 18 | // the current and previous readings from the input pin 19 | int thisButtonState = LOW; 20 | int lastButtonState = LOW; 21 | 22 | // time is measured in milliseconds and will quickly exceed limitations of an integer, so we use a long for these two 23 | unsigned long lastDebounceTime = 0; // the time the button state last switched 24 | unsigned long debounceDelay = 50; // the state must remain the same for this many millis to register the button press 25 | 26 | void setup() { 27 | pinMode(buttonPin, INPUT); 28 | pinMode(ledPin, OUTPUT); 29 | 30 | // set initial LED state 31 | digitalWrite(ledPin, ledState); 32 | } 33 | 34 | void loop() { 35 | // the buttonPin is read multiple times and the value must remain the same for debounceDelay millis to toggle the LED 36 | 37 | // read button state, HIGH when pressed, LOW when not 38 | thisButtonState = digitalRead(buttonPin); 39 | 40 | // if the current state does not match the previous state 41 | // the button was just pressed/released, or is transition noise 42 | if (thisButtonState != lastButtonState) { 43 | // reset the timer 44 | lastDebounceTime = millis(); 45 | } 46 | 47 | // once delay millis have elapsed, if the state remains the same, register the press 48 | if ((millis() - lastDebounceTime) > debounceDelay) { 49 | 50 | // if the button state has changed 51 | if (thisButtonState != buttonState) { 52 | buttonState = thisButtonState; 53 | 54 | // only toggle the LED if the buttonState has switched from LOW to HIGH 55 | if (buttonState == HIGH) { 56 | ledState = !ledState; 57 | // toggle the LED 58 | digitalWrite(ledPin, ledState); 59 | } 60 | } 61 | } 62 | 63 | // persist for next loop iteration 64 | lastButtonState = thisButtonState; 65 | } 66 | -------------------------------------------------------------------------------- /examples/04.Shields/1_Button_Shield/SimplePush/SimplePush.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 1 Button Shield - Simple Push 3 | * Press the pushbutton to switch on the LED 4 | * 5 | * 1 Button Shield pushbutton connects pin D3 to GND 6 | */ 7 | 8 | const int buttonPin = D3; 9 | const int ledPin = BUILTIN_LED; 10 | 11 | int buttonState = 0; 12 | 13 | void setup() { 14 | pinMode(buttonPin, INPUT); 15 | pinMode(ledPin, OUTPUT); 16 | 17 | // set initial state, LED off 18 | digitalWrite(ledPin, buttonState); 19 | } 20 | 21 | void loop() { 22 | // read button state, HIGH when pressed, LOW when not 23 | buttonState = digitalRead(buttonPin); 24 | 25 | // if the push button pressed, switch on the LED 26 | if (buttonState == HIGH) { 27 | digitalWrite(ledPin, HIGH); // LED on 28 | } else { 29 | digitalWrite(ledPin, LOW); // LED off 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/04.Shields/1_Button_Shield/SwitchLibrary/Switch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Switch 3 | Copyright (C) 2012 Albert van Dalen http://www.avdweb.nl 4 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 5 | as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 7 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses . 8 | 9 | Version 20-4-2013 10 | _debounceDelay=50 11 | Version 22-5-2013 12 | Added longPress, doubleClick 13 | 14 | _______________________ _false 15 | | | || | 16 | input | || ||| | 17 | _____| ||_||| ||____________ 18 | 19 | poll ^ ^ ^ ^ 20 | switchedTime ^ ^ 21 | <---------100ms--------><---> 22 | debounceDelay <----50ms----> <----50ms----> 23 | switched 1 1 0 0 24 | newlevel 1 0 1 0 25 | ________________________ 26 | level _____| |___________________ 27 | 28 | ....................................................................... 29 | _______________________ _______ 30 | | | | 31 | input | | | 32 | ________| |___________| 33 | 34 | longPressDelay <-----------> 35 | 36 | doubleClickDelay <--------------------------------------> 37 | _________ 38 | longPressLatch ______________________| |_________________ 39 | _ 40 | _longPress ______________________| |__________________________ 41 | _ 42 | _doubleClick ____________________________________________| |____ 43 | 44 | */ 45 | 46 | #if ARDUINO >= 100 47 | #include "Arduino.h" 48 | #else 49 | #include "WProgram.h" 50 | #endif 51 | #include "Switch.h" 52 | 53 | // level(0) 54 | Switch::Switch(byte _pin, byte PinMode, bool polarity, int debounceDelay, int longPressDelay, int doubleClickDelay): 55 | pin(_pin), polarity(polarity), debounceDelay(debounceDelay), longPressDelay(longPressDelay), doubleClickDelay(doubleClickDelay) 56 | { pinMode(pin, PinMode); 57 | _switchedTime = millis(); 58 | level = digitalRead(pin); 59 | } 60 | 61 | bool Switch::poll() 62 | { _longPress = _doubleClick = false; 63 | bool newlevel = digitalRead(pin); 64 | 65 | if(!longPressLatch) 66 | { _longPress = on() && ((long)(millis() - pushedTime) > longPressDelay); // true just one time between polls 67 | longPressLatch = _longPress; // will be reset at next switch 68 | } 69 | 70 | if((newlevel != level) & (millis() - _switchedTime >= debounceDelay)) 71 | { _switchedTime = millis(); 72 | level = newlevel; 73 | _switched = 1; 74 | longPressLatch = false; 75 | 76 | if(pushed()) 77 | { _doubleClick = (long)(millis() - pushedTime) < doubleClickDelay; 78 | pushedTime = millis(); 79 | } 80 | return _switched; 81 | } 82 | return _switched = 0; 83 | } 84 | 85 | bool Switch::switched() 86 | { return _switched; 87 | } 88 | 89 | bool Switch::on() 90 | { return !(level^polarity); 91 | } 92 | 93 | bool Switch::pushed() 94 | { return _switched && !(level^polarity); 95 | } 96 | 97 | bool Switch::released() 98 | { return _switched && (level^polarity); 99 | } 100 | 101 | bool Switch::longPress() 102 | { return _longPress; 103 | } 104 | 105 | bool Switch::doubleClick() 106 | { return _doubleClick; 107 | } 108 | -------------------------------------------------------------------------------- /examples/04.Shields/1_Button_Shield/SwitchLibrary/Switch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Switch 3 | Copyright (C) 2012 Albert van Dalen http://www.avdweb.nl 4 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 5 | as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 6 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 7 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at http://www.gnu.org/licenses . 8 | */ 9 | 10 | #ifndef SWITCH_H 11 | #define SWITCH_H 12 | 13 | class Switch 14 | { 15 | public: 16 | Switch(byte _pin, byte PinMode=INPUT_PULLUP, bool polarity=LOW, int debounceDelay=50, int longPressDelay=400, int doubleClickDelay=250); 17 | bool poll(); // Returns 1 if switched 18 | bool switched(); // will be refreshed by poll() 19 | bool on(); 20 | bool pushed(); // will be refreshed by poll() 21 | bool released(); // will be refreshed by poll() 22 | bool longPress(); // will be refreshed by poll() 23 | bool doubleClick(); // will be refreshed by poll() 24 | 25 | unsigned long _switchedTime, pushedTime; 26 | 27 | protected: 28 | const byte pin; 29 | const int debounceDelay, longPressDelay, doubleClickDelay; 30 | const bool polarity; 31 | bool level, _switched, _longPress, longPressLatch, _doubleClick; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /examples/04.Shields/1_Button_Shield/SwitchLibrary/SwitchLibrary.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 1 Button Shield - Switch Library 3 | * Examples using Albert van Dalen's Switch Library 4 | * http://www.avdweb.nl/arduino/hardware-interfacing/simple-switch-debouncer.html 5 | * 6 | * External pull-up resistors are not required. 7 | * Supports also long press and double clicks. 8 | * Performs not just de-bouncing, but also de-glitching against EMC pulses. 9 | * 10 | * Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 11 | * 12 | * 1 Button Shield pushbutton connects pin D3 to GND 13 | */ 14 | 15 | #include "Switch.h" 16 | 17 | const byte buttonPin = D3; 18 | 19 | int i; 20 | 21 | Switch button = Switch(buttonPin); // Switch between a digital pin and GND 22 | 23 | void setup() { 24 | Serial.begin(9600); 25 | Serial.println("Examples using Switch library"); 26 | } 27 | 28 | void loop() { 29 | button.poll(); 30 | 31 | if (button.switched()) { 32 | Serial.print("switched "); 33 | } 34 | 35 | if (button.pushed()) { 36 | Serial.print("pushed "); 37 | Serial.print(++i); 38 | Serial.print(" "); 39 | } 40 | 41 | if (button.longPress()) { 42 | Serial.print("longPress "); 43 | } 44 | 45 | if (button.doubleClick()) { 46 | Serial.print("doubleClick "); 47 | } 48 | 49 | if (button.released()) { 50 | Serial.print("released\n"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/04.Shields/Ambient_Light_Shield(BH1750)/BH1750_OLED_test/BH1750_OLED_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SSD1306Wire.h" 3 | #include 4 | 5 | SSD1306Wire display(0x3C, SDA, SCL,GEOMETRY_64_48); 6 | 7 | BH1750 light(0x23); 8 | 9 | void setup() { 10 | 11 | Serial.begin(115200); 12 | 13 | display.init(); 14 | display.flipScreenVertically(); 15 | display.setFont(ArialMT_Plain_16); 16 | display.setTextAlignment(TEXT_ALIGN_LEFT); 17 | 18 | } 19 | 20 | void loop() { 21 | 22 | display.clear(); 23 | 24 | 25 | if (light.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) { 26 | 27 | display.drawString(0, 0,"L:"+String(light.readLightLevel())); 28 | 29 | } 30 | else 31 | { 32 | display.drawString(0, 0,"Error!"); 33 | } 34 | display.display(); 35 | delay(1000); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /examples/04.Shields/Ambient_Light_Shield(BH1750)/simple/simple.ino: -------------------------------------------------------------------------------- 1 | //Install [claws/BH1750 Library](https://github.com/claws/BH1750) first. 2 | 3 | 4 | #include 5 | #include 6 | 7 | /* 8 | 9 | BH1750 can be physically configured to use two I2C addresses: 10 | - 0x23 (most common) (if ADD pin had < 0.7VCC voltage) 11 | - 0x5C (if ADD pin had > 0.7VCC voltage) 12 | 13 | Library uses 0x23 address as default, but you can define any other address. 14 | If you had troubles with default value - try to change it to 0x5C. 15 | 16 | */ 17 | BH1750 lightMeter(0x23); 18 | 19 | void setup(){ 20 | 21 | Serial.begin(9600); 22 | 23 | // Initialize the I2C bus (BH1750 library doesn't do this automatically) 24 | Wire.begin(); 25 | // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3); 26 | 27 | /* 28 | 29 | BH1750 has six different measurement modes. They are divided in two groups; 30 | continuous and one-time measurements. In continuous mode, sensor continuously 31 | measures lightness value. In one-time mode the sensor makes only one 32 | measurement and then goes into Power Down mode. 33 | 34 | Each mode, has three different precisions: 35 | 36 | - Low Resolution Mode - (4 lx precision, 16ms measurement time) 37 | - High Resolution Mode - (1 lx precision, 120ms measurement time) 38 | - High Resolution Mode 2 - (0.5 lx precision, 120ms measurement time) 39 | 40 | By default, the library uses Continuous High Resolution Mode, but you can 41 | set any other mode, by passing it to BH1750.begin() or BH1750.configure() 42 | functions. 43 | 44 | [!] Remember, if you use One-Time mode, your sensor will go to Power Down 45 | mode each time, when it completes a measurement and you've read it. 46 | 47 | Full mode list: 48 | 49 | BH1750_CONTINUOUS_LOW_RES_MODE 50 | BH1750_CONTINUOUS_HIGH_RES_MODE (default) 51 | BH1750_CONTINUOUS_HIGH_RES_MODE_2 52 | 53 | BH1750_ONE_TIME_LOW_RES_MODE 54 | BH1750_ONE_TIME_HIGH_RES_MODE 55 | BH1750_ONE_TIME_HIGH_RES_MODE_2 56 | 57 | */ 58 | 59 | // begin returns a boolean that can be used to detect setup problems. 60 | if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) { 61 | Serial.println(F("BH1750 Advanced begin")); 62 | } 63 | else { 64 | Serial.println(F("Error initialising BH1750")); 65 | } 66 | 67 | } 68 | 69 | 70 | void loop() { 71 | 72 | uint16_t lux = lightMeter.readLightLevel(); 73 | Serial.print("Light: "); 74 | Serial.print(lux); 75 | Serial.println(" lx"); 76 | delay(1000); 77 | 78 | } 79 | -------------------------------------------------------------------------------- /examples/04.Shields/Barometric_Pressure_HP303B_Shield/HP303B_OLED_TEST/HP303B_OLED_TEST.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | LOLIN_HP303B HP303B; 7 | 8 | #define OLED_RESET -1 9 | Adafruit_SSD1306 display(OLED_RESET); 10 | 11 | void setup() 12 | { 13 | 14 | display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 15 | display.setTextColor(WHITE); 16 | 17 | //Address of the HP303B (0x77 or 0x76) 18 | HP303B.begin(); // I2C address = 0x77 19 | // HP303B.begin(0x76); //I2C address = 0x76 20 | } 21 | 22 | void loop() 23 | { 24 | 25 | HP303B.begin(); 26 | // Clear the buffer. 27 | display.clearDisplay(); 28 | display.setCursor(0, 0); 29 | 30 | 31 | int32_t temperature; 32 | int32_t pressure; 33 | int16_t oversampling = 7; 34 | int16_t ret; 35 | 36 | ret = HP303B.measureTempOnce(temperature, oversampling); 37 | 38 | if (ret != 0) 39 | { 40 | display.setTextSize(1); 41 | display.println("T: error"); 42 | } 43 | else 44 | { 45 | display.setTextSize(1); 46 | display.println("T: "); 47 | display.setTextSize(2); 48 | display.println(temperature); 49 | } 50 | 51 | ret = HP303B.measurePressureOnce(pressure, oversampling); 52 | 53 | if (ret != 0) 54 | { 55 | display.setTextSize(1); 56 | display.println("P: error"); 57 | } 58 | else 59 | { 60 | display.setTextSize(1); 61 | display.println("P: "); 62 | display.setTextSize(2); 63 | display.println(pressure); 64 | } 65 | 66 | display.display(); 67 | delay(1000); 68 | } -------------------------------------------------------------------------------- /examples/04.Shields/Barometric_Pressure_HP303B_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | LOLIN_HP303B HP303B; 4 | 5 | void setup() 6 | { 7 | Serial.begin(115200); 8 | while (!Serial) 9 | ; 10 | 11 | //Address of the HP303B (0x77 or 0x76) 12 | HP303B.begin(); // I2C address = 0x77 13 | 14 | // HP303B.begin(0x76); //I2C address = 0x76 15 | 16 | } 17 | 18 | void loop() 19 | { 20 | int32_t temperature; 21 | int32_t pressure; 22 | int16_t oversampling = 7; 23 | int16_t ret; 24 | Serial.println(); 25 | 26 | //lets the HP303B perform a Single temperature measurement with the last (or standard) configuration 27 | //The result will be written to the paramerter temperature 28 | //ret = HP303B.measureTempOnce(temperature); 29 | //the commented line below does exactly the same as the one above, but you can also config the precision 30 | //oversampling can be a value from 0 to 7 31 | //the HP303B will perform 2^oversampling internal temperature measurements and combine them to one result with higher precision 32 | //measurements with higher precision take more time, consult datasheet for more information 33 | ret = HP303B.measureTempOnce(temperature, oversampling); 34 | 35 | if (ret != 0) 36 | { 37 | //Something went wrong. 38 | //Look at the library code for more information about return codes 39 | Serial.print("FAIL! ret = "); 40 | Serial.println(ret); 41 | } 42 | else 43 | { 44 | Serial.print("Temperature: "); 45 | Serial.print(temperature); 46 | Serial.println(" degrees of Celsius"); 47 | } 48 | 49 | //Pressure measurement behaves like temperature measurement 50 | //ret = HP303B.measurePressureOnce(pressure); 51 | ret = HP303B.measurePressureOnce(pressure, oversampling); 52 | if (ret != 0) 53 | { 54 | //Something went wrong. 55 | //Look at the library code for more information about return codes 56 | Serial.print("FAIL! ret = "); 57 | Serial.println(ret); 58 | } 59 | else 60 | { 61 | Serial.print("Pressure: "); 62 | Serial.print(pressure); 63 | Serial.println(" Pascal"); 64 | } 65 | 66 | //Wait some time 67 | delay(500); 68 | } 69 | -------------------------------------------------------------------------------- /examples/04.Shields/Buzzer_Shield/Do_Re_Mi/Do_Re_Mi.ino: -------------------------------------------------------------------------------- 1 | 2 | int buzzer=D5; //Buzzer control port, default D5 3 | 4 | int freq[]={1047,1175,1319,1397,1568,1760,1976,2093};//Note name: C6 D6 E6 F6 G6 A6 B6 C7 http://newt.phys.unsw.edu.au/jw/notes.html 5 | String note[]={"C6", "D6", "E6", "F6", "G6", "A6", "B6", "C7"}; 6 | 7 | void setup() { 8 | pinMode(buzzer, OUTPUT); 9 | digitalWrite(buzzer, LOW); 10 | Serial.begin(115200); 11 | Serial.println("Buzzer Test..."); 12 | } 13 | 14 | void loop() { 15 | for(int i=0; i<8; i++){ 16 | analogWriteRange(freq[i]); 17 | Serial.print("Note name: "); 18 | Serial.print(note[i]); 19 | Serial.print(", Freq: "); 20 | Serial.print(freq[i]); 21 | Serial.println("Hz"); 22 | 23 | analogWrite(buzzer, 512); 24 | delay(1000); 25 | analogWrite(buzzer, 0); 26 | pinMode(buzzer, OUTPUT); 27 | digitalWrite(buzzer, LOW); 28 | delay(1000); 29 | } 30 | Serial.println("STOP"); 31 | delay(5000); 32 | 33 | } -------------------------------------------------------------------------------- /examples/04.Shields/DHT_Pro_Shield/Simple/Simple.ino: -------------------------------------------------------------------------------- 1 | /* DHT Pro Shield - Simple 2 | * 3 | * Example testing sketch for various DHT humidity/temperature sensors 4 | * Written by ladyada, public domain 5 | * 6 | * Depends on Adafruit DHT Arduino library 7 | * https://github.com/adafruit/DHT-sensor-library 8 | */ 9 | 10 | #include "DHT.h" 11 | 12 | #define DHTPIN D4 // what pin we're connected to 13 | 14 | // Uncomment whatever type you're using! 15 | //#define DHTTYPE DHT11 // DHT 11 16 | #define DHTTYPE DHT22 // DHT 22 (AM2302) 17 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 18 | 19 | // Connect pin 1 (on the left) of the sensor to +5V 20 | // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 21 | // to 3.3V instead of 5V! 22 | // Connect pin 2 of the sensor to whatever your DHTPIN is 23 | // Connect pin 4 (on the right) of the sensor to GROUND 24 | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 25 | 26 | // Initialize DHT sensor. 27 | // Note that older versions of this library took an optional third parameter to 28 | // tweak the timings for faster processors. This parameter is no longer needed 29 | // as the current DHT reading algorithm adjusts itself to work on faster procs. 30 | DHT dht(DHTPIN, DHTTYPE); 31 | 32 | void setup() { 33 | Serial.begin(9600); 34 | Serial.println("DHTxx test!"); 35 | 36 | dht.begin(); 37 | } 38 | 39 | void loop() { 40 | // Wait a few seconds between measurements. 41 | delay(2000); 42 | 43 | // Reading temperature or humidity takes about 250 milliseconds! 44 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 45 | float h = dht.readHumidity(); 46 | // Read temperature as Celsius (the default) 47 | float t = dht.readTemperature(); 48 | // Read temperature as Fahrenheit (isFahrenheit = true) 49 | float f = dht.readTemperature(true); 50 | 51 | // Check if any reads failed and exit early (to try again). 52 | if (isnan(h) || isnan(t) || isnan(f)) { 53 | Serial.println("Failed to read from DHT sensor!"); 54 | return; 55 | } 56 | 57 | // Compute heat index in Fahrenheit (the default) 58 | float hif = dht.computeHeatIndex(f, h); 59 | // Compute heat index in Celsius (isFahreheit = false) 60 | float hic = dht.computeHeatIndex(t, h, false); 61 | 62 | Serial.print("Humidity: "); 63 | Serial.print(h); 64 | Serial.print(" %\t"); 65 | Serial.print("Temperature: "); 66 | Serial.print(t); 67 | Serial.print(" *C "); 68 | Serial.print(f); 69 | Serial.print(" *F\t"); 70 | Serial.print("Heat index: "); 71 | Serial.print(hic); 72 | Serial.print(" *C "); 73 | Serial.print(hif); 74 | Serial.println(" *F"); 75 | } 76 | -------------------------------------------------------------------------------- /examples/04.Shields/DHT_Shield/DeepSleep/DeepSleep.ino: -------------------------------------------------------------------------------- 1 | /* DHT Shield - Deep Sleep 2 | * 3 | * Displays humidity, temperature and heat index, sleeps for 10 seconds and repeats 4 | * 5 | * Connections: 6 | * D0 -- RST 7 | * 8 | * If you cant reprogram as the ESP is sleeping, disconnect D0 - RST and try again 9 | * 10 | * Depends on Adafruit DHT Arduino library 11 | * https://github.com/adafruit/DHT-sensor-library 12 | */ 13 | 14 | #include "DHT.h" 15 | #define DHTPIN D4 16 | #define DHTTYPE DHT11 17 | DHT dht(DHTPIN, DHTTYPE); 18 | 19 | // sleep for this many seconds 20 | const int sleepSeconds = 10; 21 | 22 | float humidity, temperature, heatIndex; 23 | char str_humidity[10], str_temperature[10], str_heatIndex[10]; 24 | 25 | void setup() { 26 | Serial.begin(9600); 27 | Serial.println("\n\nWake up"); 28 | 29 | // Connect D0 to RST to wake up 30 | pinMode(D0, WAKEUP_PULLUP); 31 | 32 | Serial.println("Initialize DHT sensor"); 33 | dht.begin(); 34 | delay(2000); 35 | 36 | Serial.println("Read DHT sensor"); 37 | float humidity = dht.readHumidity(); 38 | float temperature = dht.readTemperature(); 39 | if (isnan(humidity) || isnan(temperature)) { 40 | Serial.println("Failed to read from DHT sensor!"); 41 | } 42 | float heatIndex = dht.computeHeatIndex(temperature, humidity, false); 43 | 44 | // Convert the floats to strings and round to 2 decimal places 45 | dtostrf(humidity, 1, 2, str_humidity); 46 | dtostrf(temperature, 1, 2, str_temperature); 47 | dtostrf(heatIndex, 1, 2, str_heatIndex); 48 | 49 | Serial.printf("Humidity: %s %%\nTemperature: %s *C\nHeat index: %s *C\n", str_humidity, str_temperature, str_heatIndex); 50 | Serial.printf("Sleep for %d seconds\n\n", sleepSeconds); 51 | 52 | // convert to microseconds 53 | ESP.deepSleep(sleepSeconds * 1000000); 54 | } 55 | 56 | void loop() { 57 | } 58 | -------------------------------------------------------------------------------- /examples/04.Shields/DHT_Shield/Simple/Simple.ino: -------------------------------------------------------------------------------- 1 | /* DHT Shield - Simple 2 | * 3 | * Example testing sketch for various DHT humidity/temperature sensors 4 | * Written by ladyada, public domain 5 | * 6 | * Depends on Adafruit DHT Arduino library 7 | * https://github.com/adafruit/DHT-sensor-library 8 | */ 9 | 10 | #include "DHT.h" 11 | 12 | #define DHTPIN D4 // what pin we're connected to 13 | 14 | // Uncomment whatever type you're using! 15 | #define DHTTYPE DHT11 // DHT 11 16 | //#define DHTTYPE DHT22 // DHT 22 (AM2302) 17 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 18 | 19 | // Connect pin 1 (on the left) of the sensor to +5V 20 | // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 21 | // to 3.3V instead of 5V! 22 | // Connect pin 2 of the sensor to whatever your DHTPIN is 23 | // Connect pin 4 (on the right) of the sensor to GROUND 24 | // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor 25 | 26 | // Initialize DHT sensor. 27 | // Note that older versions of this library took an optional third parameter to 28 | // tweak the timings for faster processors. This parameter is no longer needed 29 | // as the current DHT reading algorithm adjusts itself to work on faster procs. 30 | DHT dht(DHTPIN, DHTTYPE); 31 | 32 | void setup() { 33 | Serial.begin(9600); 34 | Serial.println("DHTxx test!"); 35 | 36 | dht.begin(); 37 | } 38 | 39 | void loop() { 40 | // Wait a few seconds between measurements. 41 | delay(2000); 42 | 43 | // Reading temperature or humidity takes about 250 milliseconds! 44 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 45 | float h = dht.readHumidity(); 46 | // Read temperature as Celsius (the default) 47 | float t = dht.readTemperature(); 48 | // Read temperature as Fahrenheit (isFahrenheit = true) 49 | float f = dht.readTemperature(true); 50 | 51 | // Check if any reads failed and exit early (to try again). 52 | if (isnan(h) || isnan(t) || isnan(f)) { 53 | Serial.println("Failed to read from DHT sensor!"); 54 | return; 55 | } 56 | 57 | // Compute heat index in Fahrenheit (the default) 58 | float hif = dht.computeHeatIndex(f, h); 59 | // Compute heat index in Celsius (isFahreheit = false) 60 | float hic = dht.computeHeatIndex(t, h, false); 61 | 62 | Serial.print("Humidity: "); 63 | Serial.print(h); 64 | Serial.print(" %\t"); 65 | Serial.print("Temperature: "); 66 | Serial.print(t); 67 | Serial.print(" *C "); 68 | Serial.print(f); 69 | Serial.print(" *F\t"); 70 | Serial.print("Heat index: "); 71 | Serial.print(hic); 72 | Serial.print(" *C "); 73 | Serial.print(hif); 74 | Serial.println(" *F"); 75 | } 76 | -------------------------------------------------------------------------------- /examples/04.Shields/DHT_Shield/SimpleServer/SimpleServer.ino: -------------------------------------------------------------------------------- 1 | /* WeMos DHT Server 2 | * 3 | * Connect to WiFi and respond to http requests with temperature and humidity 4 | * 5 | * Based on Adafruit ESP8266 Temperature / Humidity Webserver 6 | * https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver 7 | * 8 | * Depends on Adafruit DHT Arduino library 9 | * https://github.com/adafruit/DHT-sensor-library 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define DHTTYPE DHT11 // DHT Shield uses DHT 11 18 | #define DHTPIN D4 // DHT Shield uses pin D4 19 | 20 | // Existing WiFi network 21 | const char* ssid = "YourRouterSSID"; 22 | const char* password = "YourRouterPassword"; 23 | 24 | // Listen for HTTP requests on standard port 80 25 | ESP8266WebServer server(80); 26 | 27 | // Initialize DHT sensor 28 | // Note that older versions of this library took an optional third parameter to 29 | // tweak the timings for faster processors. This parameter is no longer needed 30 | // as the current DHT reading algorithm adjusts itself to work on faster procs. 31 | DHT dht(DHTPIN, DHTTYPE); 32 | 33 | float humidity, temperature; // Raw float values from the sensor 34 | char str_humidity[10], str_temperature[10]; // Rounded sensor values and as strings 35 | // Generally, you should use "unsigned long" for variables that hold time 36 | unsigned long previousMillis = 0; // When the sensor was last read 37 | const long interval = 2000; // Wait this long until reading again 38 | 39 | void handle_root() { 40 | server.send(200, "text/plain", "WeMos DHT Server. Get /temp or /humidity"); 41 | delay(100); 42 | } 43 | 44 | void read_sensor() { 45 | // Wait at least 2 seconds seconds between measurements. 46 | // If the difference between the current time and last time you read 47 | // the sensor is bigger than the interval you set, read the sensor. 48 | // Works better than delay for things happening elsewhere also. 49 | unsigned long currentMillis = millis(); 50 | 51 | if (currentMillis - previousMillis >= interval) { 52 | // Save the last time you read the sensor 53 | previousMillis = currentMillis; 54 | 55 | // Reading temperature and humidity takes about 250 milliseconds! 56 | // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor) 57 | humidity = dht.readHumidity(); // Read humidity as a percent 58 | temperature = dht.readTemperature(); // Read temperature as Celsius 59 | 60 | // Check if any reads failed and exit early (to try again). 61 | if (isnan(humidity) || isnan(temperature)) { 62 | Serial.println("Failed to read from DHT sensor!"); 63 | return; 64 | } 65 | 66 | // Convert the floats to strings and round to 2 decimal places 67 | dtostrf(humidity, 1, 2, str_humidity); 68 | dtostrf(temperature, 1, 2, str_temperature); 69 | 70 | Serial.print("Humidity: "); 71 | Serial.print(str_humidity); 72 | Serial.print(" %\t"); 73 | Serial.print("Temperature: "); 74 | Serial.print(str_temperature); 75 | Serial.println(" °C"); 76 | } 77 | } 78 | 79 | void setup(void) 80 | { 81 | // Open the Arduino IDE Serial Monitor to see what the code is doing 82 | Serial.begin(9600); 83 | dht.begin(); 84 | 85 | Serial.println("WeMos DHT Server"); 86 | Serial.println(""); 87 | 88 | // Connect to your WiFi network 89 | WiFi.begin(ssid, password); 90 | Serial.print("Connecting"); 91 | 92 | // Wait for successful connection 93 | while (WiFi.status() != WL_CONNECTED) { 94 | delay(500); 95 | Serial.print("."); 96 | } 97 | Serial.println(""); 98 | Serial.print("Connected to: "); 99 | Serial.println(ssid); 100 | Serial.print("IP address: "); 101 | Serial.println(WiFi.localIP()); 102 | Serial.println(""); 103 | 104 | // Initial read 105 | read_sensor(); 106 | 107 | // Handle http requests 108 | server.on("/", handle_root); 109 | 110 | server.on("/temp", [](){ 111 | read_sensor(); 112 | char response[50]; 113 | snprintf(response, 50, "Temperature: %s °C", str_temperature); 114 | server.send(200, "text/plain", response); 115 | }); 116 | 117 | server.on("/humidity", [](){ 118 | read_sensor(); 119 | char response[50]; 120 | snprintf(response, 50, "Humidity: %s %", str_humidity); 121 | server.send(200, "text/plain", response); 122 | }); 123 | 124 | // Start the web server 125 | server.begin(); 126 | Serial.println("HTTP server started"); 127 | } 128 | 129 | void loop(void) 130 | { 131 | // Listen for http requests 132 | server.handleClient(); 133 | } 134 | -------------------------------------------------------------------------------- /examples/04.Shields/IR_Controller_Shield/IRsend/IRsend.ino: -------------------------------------------------------------------------------- 1 | /* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend. 2 | * 3 | * Version 1.0 April, 2017 4 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, 5 | * Copyright 2009 Ken Shirriff, http://arcfn.com 6 | * 7 | * An IR LED circuit *MUST* be connected to the ESP8266 on a pin 8 | * as specified by IR_LED below. 9 | * 10 | * TL;DR: The IR LED needs to be driven by a transistor for a good result. 11 | * 12 | * Suggested circuit: 13 | * https://github.com/markszabo/IRremoteESP8266/wiki#ir-sending 14 | * 15 | * Common mistakes & tips: 16 | * * Don't just connect the IR LED directly to the pin, it won't 17 | * have enough current to drive the IR LED effectively. 18 | * * Make sure you have the IR LED polarity correct. 19 | * See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity 20 | * * Typical digital camera/phones can be used to see if the IR LED is flashed. 21 | * Replace the IR LED with a normal LED if you don't have a digital camera 22 | * when debugging. 23 | * * Avoid using the following pins unless you really know what you are doing: 24 | * * Pin 0/D3: Can interfere with the boot/program mode & support circuits. 25 | * * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere. 26 | * * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere. 27 | * * ESP-01 modules are tricky. We suggest you use a module with more GPIOs 28 | * for your first time. e.g. ESP-12 etc. 29 | */ 30 | 31 | #ifndef UNIT_TEST 32 | #include 33 | #endif 34 | #include 35 | #include 36 | 37 | #define IR_LED D3 38 | 39 | IRsend irsend(IR_LED); // Set the GPIO to be used to sending the message. 40 | 41 | // Example of data captured by IRrecvDumpV2.ino 42 | uint16_t rawData[67] = {9000, 4500, 650, 550, 650, 1650, 600, 550, 650, 550, 43 | 600, 1650, 650, 550, 600, 1650, 650, 1650, 650, 1650, 44 | 600, 550, 650, 1650, 650, 1650, 650, 550, 600, 1650, 45 | 650, 1650, 650, 550, 650, 550, 650, 1650, 650, 550, 46 | 650, 550, 650, 550, 600, 550, 650, 550, 650, 550, 47 | 650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650, 48 | 650, 1650, 650, 1650, 650, 1650, 600}; 49 | 50 | void setup() { 51 | irsend.begin(); 52 | Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY); 53 | } 54 | 55 | void loop() { 56 | #if SEND_NEC 57 | Serial.println("NEC"); 58 | irsend.sendNEC(0x00FFE01FUL, 32); 59 | #endif // SEND_NEC 60 | delay(2000); 61 | #if SEND_SONY 62 | Serial.println("Sony"); 63 | irsend.sendSony(0xa90, 12, 2); 64 | #endif // SEND_SONY 65 | delay(2000); 66 | #if SEND_RAW 67 | Serial.println("a rawData capture from IRrecvDumpV2"); 68 | irsend.sendRaw(rawData, 67, 38); // Send a raw data capture at 38kHz. 69 | #endif // SEND_RAW 70 | delay(2000); 71 | } 72 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/CardInfo/CardInfo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - Card info 3 | * 4 | * This example shows how use the utility libraries on which the' 5 | * SD library is based in order to get info about your SD card. 6 | * Very useful for testing a card when you're not sure whether its working or not. 7 | * 8 | * 9 | * The SD card library uses 8.3 format filenames and is case-insensitive. 10 | * eg. IMAGE.JPG is the same as image.jpg 11 | * 12 | * created 28 Mar 2011 by Limor Fried 13 | * modified 9 Apr 2012 by Tom Igoe 14 | * 15 | * This example code is in the public domain. 16 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/CardInfo/CardInfo.ino 17 | */ 18 | 19 | // include the SD library: 20 | #include 21 | #include 22 | 23 | // set up variables using the SD utility library functions: 24 | Sd2Card card; 25 | SdVolume volume; 26 | SdFile root; 27 | 28 | // change this to match your SD shield or module; 29 | // WeMos Micro SD Shield V1.0.0: D8 30 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 31 | const int chipSelect = D4; 32 | 33 | void setup() 34 | { 35 | // Open serial communications and wait for port to open: 36 | Serial.begin(9600); 37 | while (!Serial) { 38 | ; // wait for serial port to connect. Needed for Leonardo only 39 | } 40 | 41 | Serial.print("\nInitializing SD card..."); 42 | 43 | // we'll use the initialization code from the utility libraries 44 | // since we're just testing if the card is working! 45 | if (!card.init(SPI_HALF_SPEED, chipSelect)) { 46 | Serial.println("initialization failed. Things to check:"); 47 | Serial.println("* is a card inserted?"); 48 | Serial.println("* is your wiring correct?"); 49 | Serial.println("* did you change the chipSelect pin to match your shield or module?"); 50 | return; 51 | } else { 52 | Serial.println("Wiring is correct and a card is present."); 53 | } 54 | 55 | // print the type of card 56 | Serial.print("\nCard type: "); 57 | switch (card.type()) { 58 | case SD_CARD_TYPE_SD1: 59 | Serial.println("SD1"); 60 | break; 61 | case SD_CARD_TYPE_SD2: 62 | Serial.println("SD2"); 63 | break; 64 | case SD_CARD_TYPE_SDHC: 65 | Serial.println("SDHC"); 66 | break; 67 | default: 68 | Serial.println("Unknown"); 69 | } 70 | 71 | // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32 72 | if (!volume.init(card)) { 73 | Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card"); 74 | return; 75 | } 76 | 77 | // print the type and size of the first FAT-type volume 78 | uint32_t volumesize; 79 | Serial.print("\nVolume type is FAT"); 80 | Serial.println(volume.fatType(), DEC); 81 | Serial.println(); 82 | 83 | volumesize = volume.blocksPerCluster(); // clusters are collections of blocks 84 | volumesize *= volume.clusterCount(); // we'll have a lot of clusters 85 | volumesize *= 512; // SD card blocks are always 512 bytes 86 | Serial.print("Volume size (bytes): "); 87 | Serial.println(volumesize); 88 | Serial.print("Volume size (Kbytes): "); 89 | volumesize /= 1024; 90 | Serial.println(volumesize); 91 | Serial.print("Volume size (Mbytes): "); 92 | volumesize /= 1024; 93 | Serial.println(volumesize); 94 | 95 | Serial.println("\nFiles found on the card (name, date and size in bytes): "); 96 | root.openRoot(volume); 97 | 98 | // list all files in the card with date and size 99 | root.ls(LS_R | LS_DATE | LS_SIZE); 100 | } 101 | 102 | void loop() 103 | { 104 | // nothing happens after setup 105 | } 106 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/Datalogger/Datalogger.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - Datalogger 3 | * 4 | * This example shows how to log data from an analog sensor 5 | * to an SD card using the SD library. 6 | * 7 | * The WeMos Micro SD Shield uses: 8 | * D5, D6, D7, D8, 3V3 and G 9 | * 10 | * The shield uses SPI bus pins: 11 | * D5 = CLK 12 | * D6 = MISO 13 | * D7 = MOSI 14 | * D8 = CS 15 | * 16 | * The WeMos D1 Mini has one analog pin A0. 17 | * 18 | * The SD card library uses 8.3 format filenames and is case-insensitive. 19 | * eg. IMAGE.JPG is the same as image.jpg 20 | * 21 | * created 24 Nov 2010 22 | * modified 9 Apr 2012 by Tom Igoe 23 | * 24 | * This example code is in the public domain. 25 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/Datalogger/Datalogger.ino 26 | */ 27 | 28 | #include 29 | #include 30 | 31 | // change this to match your SD shield or module; 32 | // WeMos Micro SD Shield V1.0.0: D8 33 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 34 | const int chipSelect = D4; 35 | 36 | void setup() 37 | { 38 | // Open serial communications and wait for port to open: 39 | Serial.begin(9600); 40 | while (!Serial) { 41 | ; // wait for serial port to connect. Needed for Leonardo only 42 | } 43 | 44 | Serial.print("Initializing SD card..."); 45 | 46 | // see if the card is present and can be initialized: 47 | if (!SD.begin(chipSelect)) { 48 | Serial.println("Card failed, or not present"); 49 | // don't do anything more: 50 | return; 51 | } 52 | Serial.println("card initialized."); 53 | } 54 | 55 | void loop() 56 | { 57 | // make a string for assembling the data to log: 58 | String dataString = ""; 59 | 60 | // read three sensors and append to the string: 61 | //for (int analogPin = 0; analogPin < 3; analogPin++) { 62 | // int sensor = analogRead(analogPin); 63 | // dataString += String(sensor); 64 | // if (analogPin < 2) { 65 | // dataString += ","; 66 | // } 67 | //} 68 | // The WeMos D1 Mini only has one analog pin A0. 69 | int sensor = analogRead(A0); 70 | dataString += String(sensor); 71 | 72 | // open the file. note that only one file can be open at a time, 73 | // so you have to close this one before opening another. 74 | File dataFile = SD.open("datalog.txt", FILE_WRITE); 75 | 76 | // if the file is available, write to it: 77 | if (dataFile) { 78 | dataFile.println(dataString); 79 | dataFile.close(); 80 | // print to the serial port too: 81 | Serial.println(dataString); 82 | } 83 | // if the file isn't open, pop up an error: 84 | else { 85 | Serial.println("error opening datalog.txt"); 86 | } 87 | 88 | delay(1000); 89 | } 90 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/DumpFile/DumpFile.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - File dump 3 | * 4 | * This example shows how to read a file from the SD card using the 5 | * SD library and send it over the serial port. 6 | * 7 | * The WeMos Micro SD Shield uses: 8 | * D5, D6, D7, D8, 3V3 and G 9 | * 10 | * The shield uses SPI bus pins: 11 | * D5 = CLK 12 | * D6 = MISO 13 | * D7 = MOSI 14 | * D8 = CS 15 | * 16 | * The SD card library uses 8.3 format filenames and is case-insensitive. 17 | * eg. IMAGE.JPG is the same as image.jpg 18 | * 19 | * created 22 December 2010 by Limor Fried 20 | * modified 9 Apr 2012 by Tom Igoe 21 | * 22 | * This example code is in the public domain. 23 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/DumpFile/DumpFile.ino 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | // change this to match your SD shield or module; 30 | // WeMos Micro SD Shield V1.0.0: D8 31 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 32 | const int chipSelect = D4; 33 | 34 | void setup() 35 | { 36 | // Open serial communications and wait for port to open: 37 | Serial.begin(9600); 38 | while (!Serial) { 39 | ; // wait for serial port to connect. Needed for Leonardo only 40 | } 41 | 42 | Serial.print("Initializing SD card..."); 43 | 44 | // see if the card is present and can be initialized: 45 | if (!SD.begin(chipSelect)) { 46 | Serial.println("Card failed, or not present"); 47 | // don't do anything more: 48 | return; 49 | } 50 | Serial.println("card initialized."); 51 | 52 | // open the file. note that only one file can be open at a time, 53 | // so you have to close this one before opening another. 54 | File dataFile = SD.open("datalog.txt"); 55 | 56 | // if the file is available, write to it: 57 | if (dataFile) { 58 | while (dataFile.available()) { 59 | Serial.write(dataFile.read()); 60 | } 61 | dataFile.close(); 62 | } 63 | // if the file isn't open, pop up an error: 64 | else { 65 | Serial.println("error opening datalog.txt"); 66 | } 67 | } 68 | 69 | void loop() 70 | { 71 | // nothing happens after setup 72 | } 73 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/Files/Files.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - Basic file example 3 | * 4 | * This example shows how to create and destroy an SD card file 5 | * 6 | * The WeMos Micro SD Shield uses: 7 | * D5, D6, D7, D8, 3V3 and G 8 | * 9 | * The shield uses SPI bus pins: 10 | * D5 = CLK 11 | * D6 = MISO 12 | * D7 = MOSI 13 | * D8 = CS 14 | * 15 | * The SD card library uses 8.3 format filenames and is case-insensitive. 16 | * eg. IMAGE.JPG is the same as image.jpg 17 | * 18 | * created Nov 2010 by David A. Mellis 19 | * modified 9 Apr 2012 by Tom Igoe 20 | * 21 | * This example code is in the public domain. 22 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/Files/Files.ino 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | 29 | // change this to match your SD shield or module; 30 | // WeMos Micro SD Shield V1.0.0: D8 31 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 32 | const int chipSelect = D4; 33 | 34 | File myFile; 35 | 36 | void setup() 37 | { 38 | // Open serial communications and wait for port to open: 39 | Serial.begin(9600); 40 | while (!Serial) { 41 | ; // wait for serial port to connect. Needed for Leonardo only 42 | } 43 | 44 | Serial.print("Initializing SD card..."); 45 | 46 | if (!SD.begin(chipSelect)) { 47 | Serial.println("initialization failed!"); 48 | return; 49 | } 50 | Serial.println("initialization done."); 51 | 52 | if (SD.exists("example.txt")) { 53 | Serial.println("example.txt exists."); 54 | } 55 | else { 56 | Serial.println("example.txt doesn't exist."); 57 | } 58 | 59 | // open a new file and immediately close it: 60 | Serial.println("Creating example.txt..."); 61 | myFile = SD.open("example.txt", FILE_WRITE); 62 | myFile.close(); 63 | 64 | // Check to see if the file exists: 65 | if (SD.exists("example.txt")) { 66 | Serial.println("example.txt exists."); 67 | } 68 | else { 69 | Serial.println("example.txt doesn't exist."); 70 | } 71 | 72 | // delete the file: 73 | Serial.println("Removing example.txt..."); 74 | SD.remove("example.txt"); 75 | 76 | if (SD.exists("example.txt")) { 77 | Serial.println("example.txt exists."); 78 | } 79 | else { 80 | Serial.println("example.txt doesn't exist."); 81 | } 82 | } 83 | 84 | void loop() 85 | { 86 | // nothing happens after setup 87 | } 88 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/ReadWrite/ReadWrite.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - Read/Write 3 | * 4 | * This example shows how to read and write data to and from an SD card file 5 | * 6 | * The WeMos Micro SD Shield uses: 7 | * D5, D6, D7, D8, 3V3 and G 8 | * 9 | * The shield uses SPI bus pins: 10 | * D5 = CLK 11 | * D6 = MISO 12 | * D7 = MOSI 13 | * D8 = CS 14 | * 15 | * The SD card library uses 8.3 format filenames and is case-insensitive. 16 | * eg. IMAGE.JPG is the same as image.jpg 17 | * 18 | * created Nov 2010 by David A. Mellis 19 | * modified 9 Apr 2012 by Tom Igoe 20 | * 21 | * This example code is in the public domain. 22 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/ReadWrite/ReadWrite.ino 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | // change this to match your SD shield or module; 29 | // WeMos Micro SD Shield V1.0.0: D8 30 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 31 | const int chipSelect = D4; 32 | 33 | File myFile; 34 | 35 | void setup() 36 | { 37 | // Open serial communications and wait for port to open: 38 | Serial.begin(9600); 39 | while (!Serial) { 40 | ; // wait for serial port to connect. Needed for Leonardo only 41 | } 42 | 43 | Serial.print("Initializing SD card..."); 44 | 45 | if (!SD.begin(chipSelect)) { 46 | Serial.println("initialization failed!"); 47 | return; 48 | } 49 | Serial.println("initialization done."); 50 | 51 | // open the file. note that only one file can be open at a time, 52 | // so you have to close this one before opening another. 53 | myFile = SD.open("test.txt", FILE_WRITE); 54 | 55 | // if the file opened okay, write to it: 56 | if (myFile) { 57 | Serial.print("Writing to test.txt..."); 58 | myFile.println("testing 1, 2, 3."); 59 | // close the file: 60 | myFile.close(); 61 | Serial.println("done."); 62 | } else { 63 | // if the file didn't open, print an error: 64 | Serial.println("error opening test.txt"); 65 | } 66 | 67 | // re-open the file for reading: 68 | myFile = SD.open("test.txt"); 69 | if (myFile) { 70 | Serial.println("test.txt:"); 71 | 72 | // read from the file until there's nothing else in it: 73 | while (myFile.available()) { 74 | Serial.write(myFile.read()); 75 | } 76 | // close the file: 77 | myFile.close(); 78 | } else { 79 | // if the file didn't open, print an error: 80 | Serial.println("error opening test.txt"); 81 | } 82 | } 83 | 84 | void loop() 85 | { 86 | // nothing happens after setup 87 | } 88 | -------------------------------------------------------------------------------- /examples/04.Shields/Micro_SD_Shield/listfiles/listfiles.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Micro SD Shield - List files 3 | * 4 | * This example shows how print out the files in a directory on a SD card 5 | * 6 | * The WeMos Micro SD Shield uses: 7 | * D5, D6, D7, D8, 3V3 and G 8 | * 9 | * The shield uses SPI bus pins: 10 | * D5 = CLK 11 | * D6 = MISO 12 | * D7 = MOSI 13 | * D8 = CS 14 | * 15 | * The SD card library uses 8.3 format filenames and is case-insensitive. 16 | * eg. IMAGE.JPG is the same as image.jpg 17 | * 18 | * created Nov 2010 by David A. Mellis 19 | * modified 9 Apr 2012 by Tom Igoe 20 | * modified 2 Feb 2014 by Scott Fitzgerald 21 | * 22 | * This example code is in the public domain. 23 | * https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/listfiles/listfiles.ino 24 | */ 25 | 26 | #include 27 | #include 28 | 29 | // change this to match your SD shield or module; 30 | // WeMos Micro SD Shield V1.0.0: D8 31 | // LOLIN Micro SD Shield V1.2.0: D4 (Default) 32 | const int chipSelect = D4; 33 | 34 | File root; 35 | 36 | void setup() 37 | { 38 | // Open serial communications and wait for port to open: 39 | Serial.begin(9600); 40 | while (!Serial) { 41 | ; // wait for serial port to connect. Needed for Leonardo only 42 | } 43 | 44 | Serial.print("Initializing SD card..."); 45 | 46 | if (!SD.begin(chipSelect)) { 47 | Serial.println("initialization failed!"); 48 | return; 49 | } 50 | Serial.println("initialization done."); 51 | 52 | root = SD.open("/"); 53 | 54 | printDirectory(root, 0); 55 | 56 | Serial.println("done!"); 57 | } 58 | 59 | void loop() 60 | { 61 | // nothing happens after setup 62 | } 63 | 64 | void printDirectory(File dir, int numTabs) { 65 | while(true) { 66 | File entry = dir.openNextFile(); 67 | if (! entry) { 68 | // no more files 69 | break; 70 | } 71 | for (uint8_t i=0; i // Only needed for Arduino 1.6.5 and earlier 5 | #include "SSD1306Wire.h" // legacy: #include "SSD1306.h" 6 | 7 | 8 | #include "images.h" 9 | 10 | 11 | 12 | SSD1306Wire display(0x3C, SDA, SCL, GEOMETRY_64_32); 13 | 14 | 15 | #define DEMO_DURATION 3000 16 | typedef void (*Demo)(void); 17 | 18 | int demoMode = 0; 19 | int counter = 1; 20 | 21 | void setup() { 22 | 23 | 24 | 25 | // Initialising the UI will init the display too. 26 | display.init(); 27 | 28 | display.flipScreenVertically(); 29 | display.setFont(ArialMT_Plain_10); 30 | 31 | } 32 | 33 | void drawFontFaceDemo() { 34 | // Font Demo1 35 | // create more fonts at http://oleddisplay.squix.ch/ 36 | display.setTextAlignment(TEXT_ALIGN_LEFT); 37 | display.setFont(ArialMT_Plain_10); 38 | display.drawString(0, 0, "Hello world"); 39 | display.setFont(ArialMT_Plain_16); 40 | display.drawString(0, 10, "Hello world"); 41 | 42 | } 43 | 44 | void drawTextFlowDemo() { 45 | display.setFont(ArialMT_Plain_10); 46 | display.setTextAlignment(TEXT_ALIGN_LEFT); 47 | display.drawStringMaxWidth(0, 0, 64, 48 | "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." ); 49 | } 50 | 51 | void drawTextAlignmentDemo() { 52 | // Text alignment demo 53 | display.setFont(ArialMT_Plain_10); 54 | 55 | // The coordinates define the left starting point of the text 56 | display.setTextAlignment(TEXT_ALIGN_LEFT); 57 | display.drawString(0, 10, "Left aligned (0,10)"); 58 | 59 | // The coordinates define the center of the text 60 | display.setTextAlignment(TEXT_ALIGN_CENTER); 61 | display.drawString(64, 22, "Center aligned (64,22)"); 62 | 63 | // The coordinates define the right end of the text 64 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 65 | display.drawString(128, 33, "Right aligned (128,33)"); 66 | } 67 | 68 | void drawRectDemo() { 69 | // Draw a pixel at given position 70 | for (int i = 0; i < 10; i++) { 71 | display.setPixel(i, i); 72 | display.setPixel(10 - i, i); 73 | } 74 | display.drawRect(12, 12, 20, 20); 75 | 76 | // Fill the rectangle 77 | display.fillRect(14, 14, 17, 17); 78 | 79 | // Draw a line horizontally 80 | display.drawHorizontalLine(0, 40, 20); 81 | 82 | // Draw a line horizontally 83 | display.drawVerticalLine(40, 0, 20); 84 | } 85 | 86 | void drawCircleDemo() { 87 | for (int i=1; i < 8; i++) { 88 | display.setColor(WHITE); 89 | display.drawCircle(32, 32, i*3); 90 | if (i % 2 == 0) { 91 | display.setColor(BLACK); 92 | } 93 | display.fillCircle(96, 32, 32 - i* 3); 94 | } 95 | } 96 | 97 | void drawProgressBarDemo() { 98 | int progress = (counter / 5) % 100; 99 | // draw the progress bar 100 | display.drawProgressBar(0, 16, 63, 10, progress); 101 | 102 | // draw the percentage as String 103 | display.setTextAlignment(TEXT_ALIGN_CENTER); 104 | display.drawString(32, 0, String(progress) + "%"); 105 | } 106 | 107 | void drawImageDemo() { 108 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 109 | // on how to create xbm files 110 | display.drawXbm(0, 0, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 111 | } 112 | 113 | Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo}; 114 | int demoLength = (sizeof(demos) / sizeof(Demo)); 115 | long timeSinceLastModeSwitch = 0; 116 | 117 | void loop() { 118 | // clear the display 119 | display.clear(); 120 | // draw the current demo method 121 | demos[demoMode](); 122 | 123 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 124 | display.drawString(10, 128, String(millis())); 125 | // write the buffer to the display 126 | display.display(); 127 | 128 | if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) { 129 | demoMode = (demoMode + 1) % demoLength; 130 | timeSinceLastModeSwitch = millis(); 131 | } 132 | counter++; 133 | delay(10); 134 | } -------------------------------------------------------------------------------- /examples/04.Shields/OLED_0.49_Shield/test/test.ino: -------------------------------------------------------------------------------- 1 | #include // Only needed for Arduino 1.6.5 and earlier 2 | #include "SSD1306Wire.h" // legacy: #include "SSD1306.h" 3 | 4 | SSD1306Wire display(0x3C, SDA, SCL,GEOMETRY_64_32); 5 | 6 | void setup() { 7 | // put your setup code here, to run once: 8 | 9 | } 10 | 11 | void loop() { 12 | 13 | display.init(); 14 | 15 | display.flipScreenVertically(); 16 | display.setFont(ArialMT_Plain_10); 17 | 18 | display.clear(); 19 | 20 | // Font Demo1 21 | // create more fonts at http://oleddisplay.squix.ch/ 22 | display.setTextAlignment(TEXT_ALIGN_LEFT); 23 | display.setFont(ArialMT_Plain_16); 24 | display.drawString(0,0, "1234567"); 25 | display.setFont(ArialMT_Plain_16); 26 | display.drawString(0, 16, "ABCDEF"); 27 | 28 | 29 | display.display(); 30 | 31 | delay(1000); 32 | 33 | display.clear(); 34 | display.display(); 35 | 36 | delay(1000); 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_0.96_Shield/simple/images.h: -------------------------------------------------------------------------------- 1 | #define WiFi_Logo_width 60 2 | #define WiFi_Logo_height 36 3 | const uint8_t WiFi_Logo_bits[] PROGMEM = { 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 7 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 9 | 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 10 | 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, 11 | 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, 12 | 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, 13 | 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, 14 | 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, 15 | 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, 16 | 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 17 | 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 18 | 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, 19 | 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, 20 | 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, 21 | 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, 22 | 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 23 | 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 24 | 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 25 | 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 27 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 28 | }; 29 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_0.96_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | // For a connection via I2C using the Arduino Wire include: 4 | #include // Only needed for Arduino 1.6.5 and earlier 5 | #include "SSD1306Wire.h" // legacy: #include "SSD1306.h" 6 | 7 | 8 | #include "images.h" 9 | 10 | 11 | 12 | SSD1306Wire display(0x3D, SDA, SCL); // ADDRESS(0x3D or 0x3C), SDA, SCL 13 | 14 | 15 | #define DEMO_DURATION 3000 16 | typedef void (*Demo)(void); 17 | 18 | int demoMode = 0; 19 | int counter = 1; 20 | 21 | void setup() { 22 | 23 | 24 | 25 | // Initialising the UI will init the display too. 26 | display.init(); 27 | 28 | display.flipScreenVertically(); 29 | display.setFont(ArialMT_Plain_10); 30 | 31 | } 32 | 33 | void drawFontFaceDemo() { 34 | // Font Demo1 35 | // create more fonts at http://oleddisplay.squix.ch/ 36 | display.setTextAlignment(TEXT_ALIGN_LEFT); 37 | display.setFont(ArialMT_Plain_10); 38 | display.drawString(0, 0, "Hello world"); 39 | display.setFont(ArialMT_Plain_16); 40 | display.drawString(0, 10, "Hello world"); 41 | display.setFont(ArialMT_Plain_24); 42 | display.drawString(0, 26, "Hello world"); 43 | } 44 | 45 | void drawTextFlowDemo() { 46 | display.setFont(ArialMT_Plain_10); 47 | display.setTextAlignment(TEXT_ALIGN_LEFT); 48 | display.drawStringMaxWidth(0, 0, 128, 49 | "Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." ); 50 | } 51 | 52 | void drawTextAlignmentDemo() { 53 | // Text alignment demo 54 | display.setFont(ArialMT_Plain_10); 55 | 56 | // The coordinates define the left starting point of the text 57 | display.setTextAlignment(TEXT_ALIGN_LEFT); 58 | display.drawString(0, 10, "Left aligned (0,10)"); 59 | 60 | // The coordinates define the center of the text 61 | display.setTextAlignment(TEXT_ALIGN_CENTER); 62 | display.drawString(64, 22, "Center aligned (64,22)"); 63 | 64 | // The coordinates define the right end of the text 65 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 66 | display.drawString(128, 33, "Right aligned (128,33)"); 67 | } 68 | 69 | void drawRectDemo() { 70 | // Draw a pixel at given position 71 | for (int i = 0; i < 10; i++) { 72 | display.setPixel(i, i); 73 | display.setPixel(10 - i, i); 74 | } 75 | display.drawRect(12, 12, 20, 20); 76 | 77 | // Fill the rectangle 78 | display.fillRect(14, 14, 17, 17); 79 | 80 | // Draw a line horizontally 81 | display.drawHorizontalLine(0, 40, 20); 82 | 83 | // Draw a line horizontally 84 | display.drawVerticalLine(40, 0, 20); 85 | } 86 | 87 | void drawCircleDemo() { 88 | for (int i=1; i < 8; i++) { 89 | display.setColor(WHITE); 90 | display.drawCircle(32, 32, i*3); 91 | if (i % 2 == 0) { 92 | display.setColor(BLACK); 93 | } 94 | display.fillCircle(96, 32, 32 - i* 3); 95 | } 96 | } 97 | 98 | void drawProgressBarDemo() { 99 | int progress = (counter / 5) % 100; 100 | // draw the progress bar 101 | display.drawProgressBar(0, 32, 120, 10, progress); 102 | 103 | // draw the percentage as String 104 | display.setTextAlignment(TEXT_ALIGN_CENTER); 105 | display.drawString(64, 15, String(progress) + "%"); 106 | } 107 | 108 | void drawImageDemo() { 109 | // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html 110 | // on how to create xbm files 111 | display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); 112 | } 113 | 114 | Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo}; 115 | int demoLength = (sizeof(demos) / sizeof(Demo)); 116 | long timeSinceLastModeSwitch = 0; 117 | 118 | void loop() { 119 | // clear the display 120 | display.clear(); 121 | // draw the current demo method 122 | demos[demoMode](); 123 | 124 | display.setTextAlignment(TEXT_ALIGN_RIGHT); 125 | display.drawString(10, 128, String(millis())); 126 | // write the buffer to the display 127 | display.display(); 128 | 129 | if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) { 130 | demoMode = (demoMode + 1) % demoLength; 131 | timeSinceLastModeSwitch = millis(); 132 | } 133 | counter++; 134 | delay(10); 135 | } -------------------------------------------------------------------------------- /examples/04.Shields/OLED_0.96_Shield/test/test.ino: -------------------------------------------------------------------------------- 1 | #include // Only needed for Arduino 1.6.5 and earlier 2 | #include "SSD1306Wire.h" // legacy: #include "SSD1306.h" 3 | 4 | SSD1306Wire display(0x3D, SDA, SCL); 5 | 6 | void setup() { 7 | // put your setup code here, to run once: 8 | 9 | } 10 | 11 | void loop() { 12 | 13 | display.init(); 14 | 15 | display.flipScreenVertically(); 16 | display.setFont(ArialMT_Plain_10); 17 | 18 | display.clear(); 19 | 20 | // Font Demo1 21 | // create more fonts at http://oleddisplay.squix.ch/ 22 | display.setTextAlignment(TEXT_ALIGN_LEFT); 23 | display.setFont(ArialMT_Plain_10); 24 | display.drawString(0, 0, "Hello world"); 25 | display.setFont(ArialMT_Plain_16); 26 | display.drawString(0, 10, "Hello world"); 27 | display.setFont(ArialMT_Plain_24); 28 | display.drawString(0, 26, "Hello world"); 29 | 30 | display.display(); 31 | 32 | delay(1000); 33 | 34 | display.clear(); 35 | display.display(); 36 | 37 | delay(1000); 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_Shield/Use_SparkFun_Library/OLED_Clock_with_SparkFun/OLED_Clock_with_SparkFun.ino: -------------------------------------------------------------------------------- 1 | #include // Include Wire if you're using I2C 2 | #include // Include the SFE_MicroOLED library 3 | 4 | 5 | #define PIN_RESET 255 // 6 | #define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D 7 | 8 | ////////////////////////////////// 9 | // MicroOLED Object Declaration // 10 | ////////////////////////////////// 11 | 12 | MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example 13 | 14 | // Use these variables to set the initial time 15 | int hours = 11; 16 | int minutes = 50; 17 | int seconds = 30; 18 | 19 | // How fast do you want the clock to spin? Set this to 1 for fun. 20 | // Set this to 1000 to get _about_ 1 second timing. 21 | const int CLOCK_SPEED = 1000; 22 | 23 | // Global variables to help draw the clock face: 24 | const int MIDDLE_Y = oled.getLCDHeight() / 2; 25 | const int MIDDLE_X = oled.getLCDWidth() / 2; 26 | 27 | int CLOCK_RADIUS; 28 | int POS_12_X, POS_12_Y; 29 | int POS_3_X, POS_3_Y; 30 | int POS_6_X, POS_6_Y; 31 | int POS_9_X, POS_9_Y; 32 | int S_LENGTH; 33 | int M_LENGTH; 34 | int H_LENGTH; 35 | 36 | unsigned long lastDraw = 0; 37 | 38 | void initClockVariables() 39 | { 40 | // Calculate constants for clock face component positions: 41 | oled.setFontType(0); 42 | CLOCK_RADIUS = min(MIDDLE_X, MIDDLE_Y) - 1; 43 | POS_12_X = MIDDLE_X - oled.getFontWidth(); 44 | POS_12_Y = MIDDLE_Y - CLOCK_RADIUS + 2; 45 | POS_3_X = MIDDLE_X + CLOCK_RADIUS - oled.getFontWidth() - 1; 46 | POS_3_Y = MIDDLE_Y - oled.getFontHeight()/2; 47 | POS_6_X = MIDDLE_X - oled.getFontWidth()/2; 48 | POS_6_Y = MIDDLE_Y + CLOCK_RADIUS - oled.getFontHeight() - 1; 49 | POS_9_X = MIDDLE_X - CLOCK_RADIUS + oled.getFontWidth() - 2; 50 | POS_9_Y = MIDDLE_Y - oled.getFontHeight()/2; 51 | 52 | // Calculate clock arm lengths 53 | S_LENGTH = CLOCK_RADIUS - 2; 54 | M_LENGTH = S_LENGTH * 0.7; 55 | H_LENGTH = S_LENGTH * 0.5; 56 | } 57 | 58 | void setup() 59 | { 60 | oled.begin(); // Initialize the OLED 61 | oled.clear(PAGE); // Clear the display's internal memory 62 | oled.clear(ALL); // Clear the library's display buffer 63 | oled.display(); // Display what's in the buffer (splashscreen) 64 | 65 | initClockVariables(); 66 | 67 | oled.clear(ALL); 68 | drawFace(); 69 | drawArms(hours, minutes, seconds); 70 | oled.display(); // display the memory buffer drawn 71 | } 72 | 73 | void loop() 74 | { 75 | 76 | // Check if we need to update seconds, minutes, hours: 77 | if (lastDraw + CLOCK_SPEED < millis()) 78 | { 79 | lastDraw = millis(); 80 | // Add a second, update minutes/hours if necessary: 81 | updateTime(); 82 | 83 | // Draw the clock: 84 | oled.clear(PAGE); // Clear the buffer 85 | drawFace(); // Draw the face to the buffer 86 | drawArms(hours, minutes, seconds); // Draw arms to the buffer 87 | oled.display(); // Draw the memory buffer 88 | } 89 | } 90 | 91 | // Simple function to increment seconds and then increment minutes 92 | // and hours if necessary. 93 | void updateTime() 94 | { 95 | seconds++; // Increment seconds 96 | if (seconds >= 60) // If seconds overflows (>=60) 97 | { 98 | seconds = 0; // Set seconds back to 0 99 | minutes++; // Increment minutes 100 | if (minutes >= 60) // If minutes overflows (>=60) 101 | { 102 | minutes = 0; // Set minutes back to 0 103 | hours++; // Increment hours 104 | if (hours >= 12) // If hours overflows (>=12) 105 | { 106 | hours = 0; // Set hours back to 0 107 | } 108 | } 109 | } 110 | } 111 | 112 | // Draw the clock's three arms: seconds, minutes, hours. 113 | void drawArms(int h, int m, int s) 114 | { 115 | double midHours; // this will be used to slightly adjust the hour hand 116 | static int hx, hy, mx, my, sx, sy; 117 | 118 | // Adjust time to shift display 90 degrees ccw 119 | // this will turn the clock the same direction as text: 120 | h -= 3; 121 | m -= 15; 122 | s -= 15; 123 | if (h <= 0) 124 | h += 12; 125 | if (m < 0) 126 | m += 60; 127 | if (s < 0) 128 | s += 60; 129 | 130 | // Calculate and draw new lines: 131 | s = map(s, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 132 | sx = S_LENGTH * cos(PI * ((float)s) / 180); // woo trig! 133 | sy = S_LENGTH * sin(PI * ((float)s) / 180); // woo trig! 134 | // draw the second hand: 135 | oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + sx, MIDDLE_Y + sy); 136 | 137 | m = map(m, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 138 | mx = M_LENGTH * cos(PI * ((float)m) / 180); // woo trig! 139 | my = M_LENGTH * sin(PI * ((float)m) / 180); // woo trig! 140 | // draw the minute hand 141 | oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + mx, MIDDLE_Y + my); 142 | 143 | midHours = minutes/12; // midHours is used to set the hours hand to middling levels between whole hours 144 | h *= 5; // Get hours and midhours to the same scale 145 | h += midHours; // add hours and midhours 146 | h = map(h, 0, 60, 0, 360); // map the 0-60, to "360 degrees" 147 | hx = H_LENGTH * cos(PI * ((float)h) / 180); // woo trig! 148 | hy = H_LENGTH * sin(PI * ((float)h) / 180); // woo trig! 149 | // draw the hour hand: 150 | oled.line(MIDDLE_X, MIDDLE_Y, MIDDLE_X + hx, MIDDLE_Y + hy); 151 | } 152 | 153 | // Draw an analog clock face 154 | void drawFace() 155 | { 156 | // Draw the clock border 157 | oled.circle(MIDDLE_X, MIDDLE_Y, CLOCK_RADIUS); 158 | 159 | // Draw the clock numbers 160 | oled.setFontType(0); // set font type 0, please see declaration in SFE_MicroOLED.cpp 161 | oled.setCursor(POS_12_X, POS_12_Y); // points cursor to x=27 y=0 162 | oled.print(12); 163 | oled.setCursor(POS_6_X, POS_6_Y); 164 | oled.print(6); 165 | oled.setCursor(POS_9_X, POS_9_Y); 166 | oled.print(9); 167 | oled.setCursor(POS_3_X, POS_3_Y); 168 | oled.print(3); 169 | } 170 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_Shield/Use_SparkFun_Library/OLED_Cube_with_SparkFun/OLED_Cube_with_SparkFun.ino: -------------------------------------------------------------------------------- 1 | #include // Include Wire if you're using I2C 2 | #include // Include the SFE_MicroOLED library 3 | 4 | 5 | #define PIN_RESET 255 // 6 | #define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D 7 | 8 | ////////////////////////////////// 9 | // MicroOLED Object Declaration // 10 | ////////////////////////////////// 11 | 12 | MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example 13 | 14 | int SCREEN_WIDTH = oled.getLCDWidth(); 15 | int SCREEN_HEIGHT = oled.getLCDHeight(); 16 | 17 | float d = 3; 18 | float px[] = { 19 | -d, d, d, -d, -d, d, d, -d }; 20 | float py[] = { 21 | -d, -d, d, d, -d, -d, d, d }; 22 | float pz[] = { 23 | -d, -d, -d, -d, d, d, d, d }; 24 | 25 | float p2x[] = { 26 | 0,0,0,0,0,0,0,0}; 27 | float p2y[] = { 28 | 0,0,0,0,0,0,0,0}; 29 | 30 | float r[] = { 31 | 0,0,0}; 32 | 33 | #define SHAPE_SIZE 600 34 | // Define how fast the cube rotates. Smaller numbers are faster. 35 | // This is the number of ms between draws. 36 | #define ROTATION_SPEED 0 37 | 38 | void setup() 39 | { 40 | oled.begin(); 41 | oled.clear(ALL); 42 | oled.display(); 43 | } 44 | 45 | void loop() 46 | { 47 | drawCube(); 48 | delay(ROTATION_SPEED); 49 | } 50 | 51 | void drawCube() 52 | { 53 | r[0]=r[0]+PI/180.0; // Add a degree 54 | r[1]=r[1]+PI/180.0; // Add a degree 55 | r[2]=r[2]+PI/180.0; // Add a degree 56 | if (r[0] >= 360.0*PI/180.0) r[0] = 0; 57 | if (r[1] >= 360.0*PI/180.0) r[1] = 0; 58 | if (r[2] >= 360.0*PI/180.0) r[2] = 0; 59 | 60 | for (int i=0;i<8;i++) 61 | { 62 | float px2 = px[i]; 63 | float py2 = cos(r[0])*py[i] - sin(r[0])*pz[i]; 64 | float pz2 = sin(r[0])*py[i] + cos(r[0])*pz[i]; 65 | 66 | float px3 = cos(r[1])*px2 + sin(r[1])*pz2; 67 | float py3 = py2; 68 | float pz3 = -sin(r[1])*px2 + cos(r[1])*pz2; 69 | 70 | float ax = cos(r[2])*px3 - sin(r[2])*py3; 71 | float ay = sin(r[2])*px3 + cos(r[2])*py3; 72 | float az = pz3-150; 73 | 74 | p2x[i] = SCREEN_WIDTH/2+ax*SHAPE_SIZE/az; 75 | p2y[i] = SCREEN_HEIGHT/2+ay*SHAPE_SIZE/az; 76 | } 77 | 78 | oled.clear(PAGE); 79 | for (int i=0;i<3;i++) 80 | { 81 | oled.line(p2x[i],p2y[i],p2x[i+1],p2y[i+1]); 82 | oled.line(p2x[i+4],p2y[i+4],p2x[i+5],p2y[i+5]); 83 | oled.line(p2x[i],p2y[i],p2x[i+4],p2y[i+4]); 84 | } 85 | oled.line(p2x[3],p2y[3],p2x[0],p2y[0]); 86 | oled.line(p2x[7],p2y[7],p2x[4],p2y[4]); 87 | oled.line(p2x[3],p2y[3],p2x[7],p2y[7]); 88 | oled.display(); 89 | } 90 | 91 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_Shield/Use_SparkFun_Library/OLED_DrawBitmap_with_SparkFun/OLED_DrawBitmap_with_SparkFun.ino: -------------------------------------------------------------------------------- 1 | #include // Include Wire if you're using I2C 2 | #include // Include the SFE_MicroOLED library 3 | 4 | 5 | #define PIN_RESET 255 // 6 | #define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D 7 | 8 | ////////////////////////////////// 9 | // MicroOLED Object Declaration // 10 | ////////////////////////////////// 11 | 12 | MicroOLED oled(PIN_RESET, DC_JUMPER); // I2C Example 13 | 14 | 15 | 16 | //------------------------------------------------------------------------------ 17 | // File generated by LCD Assistant 18 | // http://en.radzio.dxp.pl/bitmap_converter/ 19 | //------------------------------------------------------------------------------ 20 | //This is the array that holds the Bitmap image. The easiest way to convert a bmp 21 | //to an array is to use the LCD Assistant linked above. 22 | uint8_t bender [] = { 23 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xBF, 0xDF, 0x5F, 0x5F, 0x5F, 0x5F, 24 | 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 25 | 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 26 | 0x5F, 0xDF, 0xBF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 27 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xF9, 0xFE, 0x07, 0x01, 0x00, 0x00, 0xF8, 0xFE, 0xFF, 28 | 0xFF, 0xFF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xC0, 0xE0, 0xF0, 0xF9, 0xFF, 0xFF, 39 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 40 | 0xB7, 0x6F, 0xEE, 0x00, 0xDE, 0xDE, 0xDE, 0xDD, 0x00, 0xDD, 0xDD, 0xDD, 0xDD, 0x00, 0xDD, 0xDD, 41 | 0xDD, 0xC5, 0xC1, 0x00, 0xC9, 0xC5, 0xC1, 0x01, 0xC8, 0xC4, 0x42, 0x80, 0xC0, 0xE8, 0xE4, 0xE2, 42 | 0xE0, 0xE0, 0xEF, 0xEF, 0xE6, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 43 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 44 | 0xFF, 0xFF, 0xFE, 0xFE, 0xFD, 0xFD, 0xFD, 0xFB, 0xF8, 0xFB, 0xFB, 0xFB, 0xFB, 0xF8, 0xFB, 0xFB, 45 | 0xFB, 0xFB, 0xFB, 0xF8, 0xFB, 0xFD, 0xFD, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 46 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF 47 | }; 48 | 49 | 50 | void setup() 51 | { 52 | // These three lines of code are all you need to initialize the 53 | // OLED and print the splash screen. 54 | 55 | // Before you can start using the OLED, call begin() to init 56 | // all of the pins and configure the OLED. 57 | oled.begin(); 58 | // clear(ALL) will clear out the OLED's graphic memory. 59 | // clear(PAGE) will clear the Arduino's display buffer. 60 | oled.clear(ALL); // Clear the display's memory (gets rid of artifacts) 61 | // To actually draw anything on the display, you must call the 62 | // display() function. 63 | oled.display(); 64 | delay(1000);//pause for the splash screen 65 | //Note: You can change the spalsh screen by editing the array founf in the library source code 66 | 67 | oled.clear(PAGE);//clear the screen before we draw our image 68 | oled.drawBitmap(bender);//call the drawBitmap function and pass it the array from above 69 | oled.display();//display the imgae 70 | } 71 | 72 | void loop() 73 | { 74 | } 75 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_Shield/Use_SparkFun_Library/OLED_Hello_with_SparkFun/OLED_Hello_with_SparkFun.ino: -------------------------------------------------------------------------------- 1 | 2 | #include // Include Wire if you're using I2C 3 | #include // Include the SFE_MicroOLED library 4 | 5 | #define PIN_RESET 255 // 6 | #define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D 7 | 8 | 9 | MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration 10 | 11 | // I2C is great, but will result in a much slower update rate. The 12 | // slower framerate may be a worthwhile tradeoff, if you need more 13 | // pins, though. 14 | void setup() 15 | { 16 | // These three lines of code are all you need to initialize the 17 | // OLED and print the splash screen. 18 | 19 | // Before you can start using the OLED, call begin() to init 20 | // all of the pins and configure the OLED. 21 | oled.begin(); 22 | // clear(ALL) will clear out the OLED's graphic memory. 23 | // clear(PAGE) will clear the Arduino's display buffer. 24 | oled.clear(ALL); // Clear the display's memory (gets rid of artifacts) 25 | // To actually draw anything on the display, you must call the 26 | // display() function. 27 | oled.display(); 28 | } 29 | 30 | void loop() 31 | { 32 | } 33 | -------------------------------------------------------------------------------- /examples/04.Shields/OLED_Shield/Use_SparkFun_Library/OLED_TEST/OLED_TEST.ino: -------------------------------------------------------------------------------- 1 | 2 | #include // Include Wire if you're using I2C 3 | #include // Include the SFE_MicroOLED library 4 | 5 | #define PIN_RESET 255 // 6 | #define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D 7 | 8 | 9 | MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration 10 | 11 | // I2C is great, but will result in a much slower update rate. The 12 | // slower framerate may be a worthwhile tradeoff, if you need more 13 | // pins, though. 14 | void setup() 15 | { 16 | // These three lines of code are all you need to initialize the 17 | // OLED and print the splash screen. 18 | 19 | // Before you can start using the OLED, call begin() to init 20 | // all of the pins and configure the OLED. 21 | 22 | } 23 | 24 | void loop() 25 | { 26 | oled.begin(); 27 | // clear(ALL) will clear out the OLED's graphic memory. 28 | // clear(PAGE) will clear the Arduino's display buffer. 29 | oled.clear(ALL); // Clear the display's memory (gets rid of artifacts) 30 | // To actually draw anything on the display, you must call the 31 | // display() function. 32 | oled.display(); 33 | delay(1000); 34 | } 35 | -------------------------------------------------------------------------------- /examples/04.Shields/PIR_Shield/pir_simple/pir_simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 1 Button Shield - Simple Push 3 | * Press the pushbutton to switch on the LED 4 | * 5 | * 1 Button Shield pushbutton connects pin D3 to GND 6 | */ 7 | 8 | const int PIR = D3; 9 | 10 | 11 | int PIRState = 0; 12 | 13 | void setup() { 14 | pinMode(PIR, INPUT); 15 | pinMode(BUILTIN_LED, OUTPUT); 16 | 17 | // set initial state, LED off 18 | digitalWrite(BUILTIN_LED, HIGH); 19 | } 20 | 21 | void loop() { 22 | 23 | PIRState = digitalRead(PIR); 24 | 25 | 26 | if (PIRState == HIGH) { 27 | digitalWrite(BUILTIN_LED, LOW); // LED on 28 | } else { 29 | digitalWrite(BUILTIN_LED, HIGH); // LED off 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/04.Shields/RGB_LED_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | //Install [Adafruit_NeoPixel_Library](https://github.com/adafruit/Adafruit_NeoPixel) first. 2 | 3 | #include 4 | 5 | #define PIN D4 6 | #define LED_NUM 7 7 | 8 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 9 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 10 | // example for more information on possible values. 11 | Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_NUM, PIN, NEO_GRB + NEO_KHZ800); 12 | 13 | 14 | 15 | void setup() { 16 | leds.begin(); // This initializes the NeoPixel library. 17 | } 18 | 19 | 20 | 21 | void led_set(uint8 R, uint8 G, uint8 B) { 22 | for (int i = 0; i < LED_NUM; i++) { 23 | leds.setPixelColor(i, leds.Color(R, G, B)); 24 | leds.show(); 25 | delay(50); 26 | } 27 | } 28 | 29 | void loop() { 30 | 31 | led_set(10, 0, 0);//red 32 | led_set(0, 0, 0); 33 | 34 | led_set(0, 10, 0);//green 35 | led_set(0, 0, 0); 36 | 37 | led_set(0, 0, 10);//blue 38 | led_set(0, 0, 0); 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /examples/04.Shields/Relay_Shield/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Relay Shield - Blink 3 | * Turns on the relay for two seconds, then off for two seconds, repeatedly. 4 | * 5 | * Relay Shield transistor closes relay when D1 is HIGH 6 | */ 7 | 8 | const int relayPin = D1; 9 | const long interval = 2000; // pause for two seconds 10 | 11 | void setup() { 12 | pinMode(relayPin, OUTPUT); 13 | } 14 | 15 | void loop() { 16 | digitalWrite(relayPin, HIGH); // turn on relay with voltage HIGH 17 | delay(interval); // pause 18 | digitalWrite(relayPin, LOW); // turn off relay with voltage LOW 19 | delay(interval); // pause 20 | } 21 | -------------------------------------------------------------------------------- /examples/04.Shields/Relay_Shield/BlinkWithoutDelay/BlinkWithoutDelay.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Relay Shield - Blink Without Delay 3 | * Turns on the relay for two seconds, then off for two seconds, repeatedly. 4 | * This uses millis() instead of delay() to avoid blocking. 5 | * 6 | * Relay Shield transistor closes relay when D1 is HIGH 7 | */ 8 | 9 | const int relayPin = D1; 10 | const long interval = 2000; // pause for two seconds 11 | 12 | int relayState = LOW; 13 | unsigned long previousMillis = 0; 14 | 15 | 16 | void setup() { 17 | pinMode(relayPin, OUTPUT); 18 | } 19 | 20 | void loop() { 21 | unsigned long currentMillis = millis(); 22 | 23 | // if enough millis have elapsed 24 | if (currentMillis - previousMillis >= interval) { 25 | previousMillis = currentMillis; 26 | 27 | // toggle the relay 28 | relayState = !relayState; 29 | digitalWrite(relayPin, relayState); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/04.Shields/SGP30_Shield/SGP30_OLED_test/SGP30_OLED_test.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define OLED_RESET 0 // GPIO0 7 | Adafruit_SSD1306 display(OLED_RESET); 8 | 9 | Adafruit_SGP30 sgp30; 10 | 11 | void setup() 12 | { 13 | 14 | display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 15 | 16 | if (sgp30.begin() == false) 17 | { 18 | 19 | while (1) 20 | ; 21 | } 22 | 23 | 24 | } 25 | 26 | void loop() 27 | { 28 | 29 | delay(1000); 30 | 31 | display.clearDisplay(); 32 | display.setTextSize(1); 33 | display.setCursor(0, 0); 34 | display.setTextColor(WHITE); 35 | 36 | if (sgp30.IAQmeasure()) 37 | { 38 | 39 | display.println("CO2: "); 40 | display.setTextSize(2); 41 | 42 | display.println(sgp30.eCO2); 43 | 44 | display.setTextSize(1); 45 | display.println("TVOC: "); 46 | 47 | display.setTextSize(2); 48 | display.println(sgp30.TVOC); 49 | 50 | display.display(); 51 | } 52 | else 53 | { 54 | display.println("Error!"); 55 | display.display(); 56 | 57 | while (1) 58 | { 59 | ; 60 | } 61 | 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /examples/04.Shields/SGP30_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Install Adafruit_SGP30 First: https://github.com/adafruit/Adafruit_SGP30 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | Adafruit_SGP30 sgp30; 9 | 10 | void setup() 11 | { 12 | Serial.begin(9600); 13 | 14 | if (!sgp30.begin()) 15 | { 16 | Serial.println("\r\nSensor not found :("); 17 | while (1) 18 | ; 19 | } 20 | Serial.print("Found SGP30 serial #"); 21 | Serial.print(sgp30.serialnumber[0], HEX); 22 | Serial.print(sgp30.serialnumber[1], HEX); 23 | Serial.println(sgp30.serialnumber[2], HEX); 24 | } 25 | 26 | void loop() 27 | { 28 | 29 | //CO2: 400 ppm TVOC: 0 ppb 30 | delay(1000); //Wait 1 second 31 | if (sgp30.IAQmeasure()) 32 | { 33 | 34 | Serial.print("CO2: "); 35 | Serial.print(sgp30.eCO2); 36 | Serial.print(" ppm\tTVOC: "); 37 | Serial.print(sgp30.TVOC); 38 | Serial.println(" ppb"); 39 | } 40 | else 41 | { 42 | Serial.println("Error...\r\n"); 43 | while (1) 44 | ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/04.Shields/TFT_1.4_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | #include // Core graphics library 2 | #include // Hardware-specific library 3 | #include 4 | 5 | #define TFT_RST -1 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 6 | #define TFT_CS D4 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 7 | #define TFT_DC D3 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 8 | 9 | // #define TFT_RST -1 //for TFT I2C Connector Shield (V1.1.0 or later) 10 | // #define TFT_CS D0 //for TFT I2C Connector Shield (V1.1.0 or later) 11 | // #define TFT_DC D8 //for TFT I2C Connector Shield (V1.1.0 or later) 12 | 13 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 14 | 15 | void setup(void) 16 | { 17 | tft.initR(INITR_144GREENTAB); 18 | tft.setTextWrap(false); // Allow text to run off right edge 19 | tft.fillScreen(ST7735_BLACK); 20 | } 21 | 22 | void loop(void) 23 | { 24 | tft.fillScreen(ST7735_BLACK); 25 | tft.setCursor(0, 0); 26 | tft.setTextColor(ST7735_BLUE); 27 | tft.setTextSize(2); 28 | tft.println("WEMOS.CC"); 29 | tft.setRotation(tft.getRotation() + 1); 30 | delay(3000); 31 | } 32 | -------------------------------------------------------------------------------- /examples/04.Shields/TFT_1.4_Shield/test/test.ino: -------------------------------------------------------------------------------- 1 | #include // Core graphics library 2 | #include // Hardware-specific library 3 | #include 4 | 5 | #define TFT_RST -1 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 6 | #define TFT_CS D4 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 7 | #define TFT_DC D3 //for TFT I2C Connector Shield V1.0.0 and TFT 1.4 Shield V1.0.0 8 | 9 | // #define TFT_RST -1 //for TFT I2C Connector Shield (V1.1.0 or later) 10 | // #define TFT_CS D0 //for TFT I2C Connector Shield (V1.1.0 or later) 11 | // #define TFT_DC D8 //for TFT I2C Connector Shield (V1.1.0 or later) 12 | 13 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 14 | 15 | void setup(void) { 16 | 17 | } 18 | 19 | void loop(void) { 20 | tft.initR(INITR_144GREENTAB); 21 | tft.setTextWrap(false); // Allow text to run off right edge 22 | tft.fillScreen(ST7735_BLACK); 23 | tft.setCursor(0, 0); 24 | tft.setTextColor(ST7735_BLUE); 25 | tft.setTextSize(2); 26 | tft.println("WEMOS.CC"); 27 | delay(3000); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /examples/04.Shields/TFT_2.4_Touch_Shield/TFT_TouchTest/TFT_TouchTest.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | 3 | 1. !!!Make sure you using lastest ESP8266 core for Arduino, otherwise it may not work properly. 4 | https://github.com/esp8266/Arduino 5 | 6 | (The pin D0(GPIO16) will be not work when you use older version ESP8266 core for Arduino, 7 | because the older version ESP8266 core for Arduino's digitalPinToBitMask(), portOutputRegister(), 8 | portInputRegister() and portModeRegister() fuction have some bugs which Adafruit_ILI9341 Library will use. 9 | This bug was fixed after commit: https://github.com/esp8266/Arduino/commit/799193888a553de8876052019842538396f92194 ) 10 | 11 | 12 | 2. Setup latest Adafruit_GFX, Adafruit_ILI9341 and XPT2046_Touchscreen Library first: 13 | 14 | https://github.com/adafruit/Adafruit-GFX-Library 15 | 16 | https://github.com/adafruit/Adafruit_ILI9341 17 | 18 | https://github.com/PaulStoffregen/XPT2046_Touchscreen 19 | 20 | ****************************************************/ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define TFT_CS D0 //for D1 mini or TFT I2C Connector Shield (V1.1.0 or later) 28 | #define TFT_DC D8 //for D1 mini or TFT I2C Connector Shield (V1.1.0 or later) 29 | #define TFT_RST -1 //for D1 mini or TFT I2C Connector Shield (V1.1.0 or later) 30 | #define TS_CS D3 //for D1 mini or TFT I2C Connector Shield (V1.1.0 or later) 31 | 32 | // #define TFT_CS 14 //for D32 Pro 33 | // #define TFT_DC 27 //for D32 Pro 34 | // #define TFT_RST 33 //for D32 Pro 35 | // #define TS_CS 12 //for D32 Pro 36 | 37 | Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); 38 | XPT2046_Touchscreen ts(TS_CS); 39 | 40 | void setup() 41 | { 42 | Serial.begin(115200); 43 | ts.begin(); 44 | ts.setRotation(1); 45 | 46 | tft.begin(); 47 | tft.setRotation(3); 48 | tft.fillScreen(ILI9341_BLACK); 49 | tft.setTextColor(ILI9341_WHITE); 50 | tft.setTextSize(3); 51 | tft.println("Touch Test"); 52 | 53 | while (!Serial && (millis() <= 1000)) 54 | ; 55 | } 56 | 57 | void loop() 58 | { 59 | if (ts.touched()) 60 | { 61 | TS_Point p = ts.getPoint(); 62 | 63 | tft.fillScreen(ILI9341_BLACK); 64 | tft.setCursor(0, 0); 65 | 66 | tft.print("Pressure = "); 67 | tft.println(p.z); 68 | tft.print("X = "); 69 | tft.println(p.x); 70 | tft.print("Y = "); 71 | tft.println(p.y); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /examples/04.Shields/TFT_2.4_Touch_Shield/TouchTest/TouchTest.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | 3 | 1. !!!Make sure you using lastest ESP8266 core for Arduino, otherwise it may not work properly. 4 | https://github.com/esp8266/Arduino 5 | 6 | (The pin D0(GPIO16) will be not work when you use older version ESP8266 core for Arduino, 7 | because the older version ESP8266 core for Arduino's digitalPinToBitMask(), portOutputRegister(), 8 | portInputRegister() and portModeRegister() fuction have some bugs which Adafruit_ILI9341 Library will use. 9 | This bug was fixed after commit: https://github.com/esp8266/Arduino/commit/799193888a553de8876052019842538396f92194 ) 10 | 11 | 12 | 2. Setup latest Adafruit_GFX, Adafruit_ILI9341 and XPT2046_Touchscreen Library first: 13 | 14 | https://github.com/adafruit/Adafruit-GFX-Library 15 | 16 | https://github.com/adafruit/Adafruit_ILI9341 17 | 18 | https://github.com/PaulStoffregen/XPT2046_Touchscreen 19 | 20 | ****************************************************/ 21 | 22 | #include 23 | #include 24 | 25 | #define TS_CS D3 //for D1 mini or TFT I2C Connector Shield (V1.1.0 or later) 26 | // #define TS_CS 12 //for D32 Pro 27 | 28 | XPT2046_Touchscreen ts(TS_CS); 29 | 30 | void setup() 31 | { 32 | Serial.begin(115200); 33 | ts.begin(); 34 | ts.setRotation(1); 35 | while (!Serial && (millis() <= 1000)) 36 | ; 37 | } 38 | 39 | void loop() 40 | { 41 | if (ts.touched()) 42 | { 43 | TS_Point p = ts.getPoint(); 44 | Serial.print("Pressure = "); 45 | Serial.print(p.z); 46 | Serial.print(", x = "); 47 | Serial.print(p.x); 48 | Serial.print(", y = "); 49 | Serial.print(p.y); 50 | delay(30); 51 | Serial.println(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /examples/04.Shields/WS2812B_RGB_Shield/simple/simple.ino: -------------------------------------------------------------------------------- 1 | //Install [Adafruit_NeoPixel_Library](https://github.com/adafruit/Adafruit_NeoPixel) first. 2 | 3 | #include 4 | 5 | 6 | 7 | #define PIN D2 8 | 9 | 10 | // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 11 | // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 12 | // example for more information on possible values. 13 | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800); 14 | 15 | 16 | 17 | void setup() { 18 | pixels.begin(); // This initializes the NeoPixel library. 19 | } 20 | 21 | void loop() { 22 | 23 | // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one. 24 | 25 | 26 | 27 | // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255 28 | for (int i = 0; i < 2; i++) { 29 | for (int j = 0; j < 2; j++) { 30 | for (int k = 0; k < 2; k++) { 31 | 32 | pixels.setPixelColor(0, pixels.Color(i * 255, j * 255, k * 255)); // Moderately bright green color. 33 | 34 | pixels.show(); // This sends the updated pixel color to the hardware. 35 | 36 | delay(200); // Delay for a period of time (in milliseconds). 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/05.Displays/NeoPixel-Stick/examples/examples.ino: -------------------------------------------------------------------------------- 1 | /* NeoPixel Stick - Examples 2 | * Adafruit NeoPixel Stick consists of 8x 5050 RGB WS2812B LEDs 3 | * http://adafruit.com/products/1426 4 | * 5 | * Connections: 6 | * D2 --- DIN 7 | * 3V3 -- 5VDC 8 | * G ---- GND (either) 9 | * 10 | * Adafruit recommendations: 11 | * - add a 1000uF capacitor across the power lines 5VDC and GND. 12 | * - add a 300-500 Ohm resistor on first pixel's data input DIN. 13 | * - avoid connecting on a live circuit... if you must, connect GND first. 14 | * 15 | * Dependencies: 16 | * https://github.com/adafruit/Adafruit_NeoPixel 17 | */ 18 | 19 | #include 20 | 21 | // NeoPixel stick DIN pin 22 | #define DIN_PIN D2 23 | 24 | // How many NeoPixels on the stick? 25 | #define NUM_PIXELS 8 26 | 27 | // Third parameter: 28 | // NEO_RGB Pixels are wired for RGB bitstream 29 | // NEO_GRB Pixels are wired for GRB bitstream (NeoPixel Stick) 30 | // NEO_KHZ400 400 KHz bitstream for FLORA pixels 31 | // NEO_KHZ800 800 KHz bitstream for High Density LED strip (NeoPixel Stick) 32 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, DIN_PIN, NEO_GRB + NEO_KHZ800); 33 | 34 | int pause = 1000; 35 | 36 | void setup() { 37 | Serial.begin(9600); 38 | strip.begin(); 39 | strip.show(); // Start with all pixels off 40 | delay(pause); 41 | } 42 | 43 | void loop() { 44 | Serial.println("Color Wipe Red"); 45 | colorWipe(strip.Color(255, 0, 0), 50); 46 | delay(pause); 47 | 48 | Serial.println("Color Wipe Green"); 49 | colorWipe(strip.Color(0, 255, 0), 50); 50 | delay(pause); 51 | 52 | Serial.println("Color Wipe Blue"); 53 | colorWipe(strip.Color(0, 0, 255), 50); 54 | delay(pause); 55 | 56 | Serial.println("Color Wipe White"); 57 | colorWipe(strip.Color(255, 255, 255), 50); 58 | delay(pause); 59 | 60 | Serial.println("Color Wipe Cyan"); 61 | colorWipe(strip.Color(0, 255, 255), 50); 62 | delay(pause); 63 | 64 | Serial.println("Color Wipe Magenta"); 65 | colorWipe(strip.Color(255, 0, 255), 50); 66 | delay(pause); 67 | 68 | Serial.println("Color Wipe Yellow"); 69 | colorWipe(strip.Color(255, 255, 0), 50); 70 | delay(pause); 71 | 72 | Serial.println("Color Wipe Black"); 73 | colorWipe(strip.Color(0, 0, 0), 50); 74 | delay(pause); 75 | 76 | Serial.println("Theater Chase Red"); 77 | theaterChase(strip.Color(127, 0, 0), 50); 78 | delay(pause); 79 | 80 | Serial.println("Theater Chase Green"); 81 | theaterChase(strip.Color(0, 127, 0), 50); 82 | delay(pause); 83 | 84 | Serial.println("Theater Chase Blue"); 85 | theaterChase(strip.Color(0, 0, 127), 50); 86 | delay(pause); 87 | 88 | Serial.println("Theater Chase White"); 89 | theaterChase(strip.Color(127, 127, 127), 50); 90 | delay(pause); 91 | 92 | Serial.println("Random Colors"); 93 | randomColors(100); 94 | delay(pause); 95 | 96 | Serial.println("Rainbow"); 97 | rainbow(20); 98 | delay(pause); 99 | 100 | Serial.println("Rainbow Cycle"); 101 | rainbowCycle(20); 102 | delay(pause); 103 | 104 | Serial.println("Theater Chase Rainbow"); 105 | theaterChaseRainbow(50); 106 | delay(pause); 107 | } 108 | 109 | // Fill the dots one after the other with a color 110 | void colorWipe(uint32_t c, uint8_t wait) { 111 | uint16_t i; 112 | for(i=0; i 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | // Pins 46 | const int8_t RST_PIN = D2; 47 | const int8_t CE_PIN = D1; 48 | const int8_t DC_PIN = D6; 49 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 50 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 51 | const int8_t BL_PIN = D0; 52 | 53 | #define PIXEL_SIZE 4 // Big pixels 54 | #define SPEED 20 // Delay in ms between generations 55 | 56 | // Software SPI with explicit CE pin. 57 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 58 | 59 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 60 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 61 | 62 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 63 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 64 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 65 | 66 | void setup() { 67 | Serial.begin(9600); 68 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 69 | 70 | // Turn LCD backlight on 71 | pinMode(BL_PIN, OUTPUT); 72 | digitalWrite(BL_PIN, HIGH); 73 | 74 | display.begin(); 75 | display.setContrast(60); // Adjust for your display 76 | Serial.println("Show Adafruit logo bitmap"); 77 | 78 | // Show the Adafruit logo, which is preloaded into the buffer by their library 79 | // display.clearDisplay(); 80 | delay(2000); 81 | 82 | display.clearDisplay(); 83 | display.setTextSize(1); 84 | display.setTextColor(BLACK); 85 | display.println("Conway's"); 86 | display.println("Game of Life"); 87 | display.display(); 88 | delay(2000); 89 | } 90 | 91 | void loop() { 92 | // Random Seed 93 | display.clearDisplay(); 94 | randomise(); 95 | display.display(); 96 | delay(1000); 97 | 98 | // Begin 99 | int generations = 0; 100 | while(tick()) { 101 | generations++; 102 | display.display(); 103 | delay(SPEED); 104 | } 105 | 106 | // Finish 107 | display.setTextColor(BLACK, WHITE); 108 | display.setCursor(0,0); 109 | display.println(generations); 110 | display.display(); 111 | 112 | // Restart 113 | delay(5000); 114 | } 115 | 116 | void randomise() { 117 | for (uint8_t x = 0; x < LCDWIDTH; x = x + PIXEL_SIZE) { 118 | for (uint8_t y = 0; y < LCDHEIGHT; y = y + PIXEL_SIZE) { 119 | cell(x, y, random(0,2)); // 0 = White, 1 = Black 120 | } 121 | } 122 | } 123 | 124 | void cell(int x, int y, int color) { 125 | for (uint8_t i = 0; i < PIXEL_SIZE; i++) { 126 | for (uint8_t j = 0; j < PIXEL_SIZE; j++) { 127 | display.drawPixel(x + i, y + j, color); 128 | } 129 | } 130 | } 131 | 132 | bool tick() { 133 | bool something_happened = false; 134 | for (uint8_t x = 0; x < LCDWIDTH; x = x + PIXEL_SIZE) { 135 | for (uint8_t y = 0; y < LCDHEIGHT; y = y + PIXEL_SIZE) { 136 | 137 | // The current cell 138 | uint8_t alive = display.getPixel(x, y); 139 | 140 | // Count number of neighbours 141 | uint8_t neighbours = ( 142 | display.getPixel(x - PIXEL_SIZE, y - PIXEL_SIZE) + 143 | display.getPixel(x, y - PIXEL_SIZE) + 144 | display.getPixel(x + PIXEL_SIZE, y - PIXEL_SIZE) + 145 | display.getPixel(x - PIXEL_SIZE, y) + 146 | display.getPixel(x + PIXEL_SIZE, y) + 147 | display.getPixel(x + PIXEL_SIZE, y + PIXEL_SIZE) + 148 | display.getPixel(x, y + PIXEL_SIZE) + 149 | display.getPixel(x - PIXEL_SIZE, y + PIXEL_SIZE) 150 | ); 151 | 152 | // Apply the rules of life 153 | if (alive && (neighbours < 2 || neighbours > 3)) { 154 | cell(x, y, WHITE); // death 155 | if (!something_happened) something_happened = true; 156 | } 157 | else if (!alive && neighbours == 3) { 158 | cell(x, y, BLACK); // birth 159 | if (!something_happened) something_happened = true; 160 | } 161 | } 162 | } 163 | 164 | return something_happened; 165 | } 166 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/cube/cube.ino: -------------------------------------------------------------------------------- 1 | /* Rotating 3D cube 2 | * 3 | * Connections: 4 | * WeMos D1 Mini Nokia 5110 Description 5 | * (ESP8266) PCD8544 LCD 6 | * 7 | * D2 (GPIO4) 0 RST Output from ESP to reset display 8 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 9 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 10 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 11 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 12 | * 3V3 5 Vcc 3.3V from ESP to display 13 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 14 | * G 7 Gnd Ground 15 | * 16 | * More info: 17 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 18 | * 19 | * Dependencies: 20 | * https://github.com/adafruit/Adafruit-GFX-Library 21 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 22 | * - This pull request adds ESP8266 support: 23 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | // Pins 33 | const int8_t RST_PIN = D2; 34 | const int8_t CE_PIN = D1; 35 | const int8_t DC_PIN = D6; 36 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 37 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 38 | const int8_t BL_PIN = D0; 39 | 40 | 41 | // Software SPI with explicit CE pin. 42 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 43 | 44 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 45 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 46 | 47 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 48 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 49 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 50 | 51 | 52 | #define SHAPE_SIZE 700 53 | #define ROTATION_SPEED 25 // Delay in ms between cube redraws 54 | 55 | float d = 3; 56 | float px[] = { -d, d, d, -d, -d, d, d, -d }; 57 | float py[] = { -d, -d, d, d, -d, -d, d, d }; 58 | float pz[] = { -d, -d, -d, -d, d, d, d, d }; 59 | 60 | float p2x[] = {0,0,0,0,0,0,0,0}; 61 | float p2y[] = {0,0,0,0,0,0,0,0}; 62 | 63 | float r[] = {0,0,0}; 64 | 65 | void setup() { 66 | Serial.begin(9600); 67 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 68 | 69 | // Turn LCD backlight on 70 | pinMode(BL_PIN, OUTPUT); 71 | digitalWrite(BL_PIN, HIGH); 72 | 73 | display.begin(); 74 | display.setContrast(60); // Adjust for your display 75 | Serial.println("Show Adafruit logo bitmap"); 76 | 77 | // Show the Adafruit logo, which is preloaded into the buffer by their library 78 | // display.clearDisplay(); 79 | delay(2000); 80 | 81 | display.clearDisplay(); 82 | display.setTextSize(1); 83 | display.setTextColor(BLACK); 84 | display.display(); 85 | } 86 | 87 | void loop() { 88 | drawCube(); 89 | delay(ROTATION_SPEED); 90 | } 91 | 92 | void drawCube() { 93 | r[0] = r[0] + PI / 180.0; // Add a degree 94 | r[1] = r[1] + PI / 180.0; // Add a degree 95 | r[2] = r[2] + PI / 180.0; // Add a degree 96 | if (r[0] >= 360.0 * PI / 180.0) r[0] = 0; 97 | if (r[1] >= 360.0 * PI / 180.0) r[1] = 0; 98 | if (r[2] >= 360.0 * PI / 180.0) r[2] = 0; 99 | 100 | for (int i = 0; i < 8; i++) { 101 | float px2 = px[i]; 102 | float py2 = cos(r[0]) * py[i] - sin(r[0]) * pz[i]; 103 | float pz2 = sin(r[0]) * py[i] + cos(r[0]) * pz[i]; 104 | 105 | float px3 = cos(r[1]) * px2 + sin(r[1]) * pz2; 106 | float py3 = py2; 107 | float pz3 = -sin(r[1]) * px2 + cos(r[1]) * pz2; 108 | 109 | float ax = cos(r[2]) * px3 - sin(r[2]) * py3; 110 | float ay = sin(r[2]) * px3 + cos(r[2]) * py3; 111 | float az = pz3 - 150; 112 | 113 | p2x[i] = LCDWIDTH / 2 + ax * SHAPE_SIZE / az; 114 | p2y[i] = LCDHEIGHT / 2 + ay * SHAPE_SIZE / az; 115 | } 116 | 117 | display.clearDisplay(); 118 | 119 | for (int i = 0; i < 3; i++) { 120 | display.drawLine(p2x[i], p2y[i], p2x[i+1], p2y[i+1], BLACK); 121 | display.drawLine(p2x[i+4], p2y[i+4], p2x[i+5], p2y[i+5], BLACK); 122 | display.drawLine(p2x[i], p2y[i], p2x[i+4], p2y[i+4], BLACK); 123 | } 124 | 125 | display.drawLine(p2x[3], p2y[3], p2x[0], p2y[0], BLACK); 126 | display.drawLine(p2x[7], p2y[7], p2x[4], p2y[4], BLACK); 127 | display.drawLine(p2x[3], p2y[3], p2x[7], p2y[7], BLACK); 128 | 129 | display.display(); 130 | } 131 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-nokia/hello-nokia.ino: -------------------------------------------------------------------------------- 1 | /* Hello Nokia 2 | * Displays a few Nokia bitmaps 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Bitmaps 34 | #include "nokia-hands-84x48.h" 35 | #include "nokia-home-84x48.h" 36 | 37 | // Pins 38 | const int8_t RST_PIN = D2; 39 | const int8_t CE_PIN = D1; 40 | const int8_t DC_PIN = D6; 41 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 42 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 43 | const int8_t BL_PIN = D0; 44 | 45 | 46 | // Software SPI with explicit CE pin. 47 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 48 | 49 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 50 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 51 | 52 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 53 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 54 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 55 | 56 | void setup() { 57 | Serial.begin(9600); 58 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 59 | 60 | // Turn LCD backlight on 61 | pinMode(BL_PIN, OUTPUT); 62 | digitalWrite(BL_PIN, HIGH); 63 | 64 | display.begin(); 65 | display.setContrast(60); // Adjust for your display 66 | Serial.println("Show Adafruit logo bitmap"); 67 | 68 | // Show the Adafruit logo, which is preloaded into the buffer by their library 69 | // display.clearDisplay(); 70 | delay(2000); 71 | } 72 | 73 | void loop() { 74 | display.clearDisplay(); 75 | display.drawBitmap(0, 0, Nokia_hands_84x48, 84, 48, 1); 76 | display.display(); 77 | Serial.println("Show Nokia splash screen handshake bitmap"); 78 | delay(2000); 79 | 80 | display.clearDisplay(); 81 | display.drawBitmap(0, 0, Nokia_home_84x48, 84, 48, 1); 82 | Serial.println("Show Nokia home screen bitmap"); 83 | display.display(); 84 | delay(2000); 85 | } 86 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-nokia/nokia-hands-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/nokia-hands-84x48.bmp 2 | const uint8_t Nokia_hands_84x48[] PROGMEM = { 3 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 4 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x03, 0x80, 0x00, 0x00, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x03, 0xfe, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 6 | 0x3f, 0xdf, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x06, 0xff, 0xff, 0x00, 0x7f, 0xff, 7 | 0xff, 0xf0, 0x00, 0x00, 0x0e, 0x7b, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0xf0, 0x92, 0x49, 0x31, 8 | 0xef, 0xff, 0xfc, 0x49, 0x27, 0xff, 0xff, 0xf0, 0x00, 0x04, 0xe7, 0xdf, 0xfe, 0x00, 0x00, 0x07, 9 | 0xf7, 0xff, 0xf0, 0x24, 0x93, 0x1f, 0x3f, 0xff, 0x49, 0x24, 0x9f, 0xa3, 0xff, 0xf0, 0x00, 0x00, 10 | 0xfe, 0xff, 0xff, 0x80, 0x00, 0x2e, 0xc3, 0xff, 0xf0, 0xaa, 0x83, 0xfb, 0xff, 0xff, 0xe5, 0x41, 11 | 0xee, 0xc7, 0xfe, 0xd0, 0x00, 0x07, 0xd7, 0xff, 0xc7, 0xf0, 0x07, 0xff, 0xef, 0x80, 0x00, 0x54, 12 | 0x06, 0xaf, 0xfc, 0xeb, 0xfb, 0x3e, 0x6e, 0xff, 0xa9, 0x50, 0x00, 0x05, 0xff, 0xf8, 0x60, 0x70, 13 | 0x3f, 0xef, 0xfe, 0x12, 0x00, 0xa0, 0x0b, 0xff, 0xf1, 0x0a, 0x06, 0x9e, 0xff, 0xfd, 0x49, 0x60, 14 | 0x00, 0x03, 0xff, 0xca, 0x44, 0x21, 0x00, 0x1f, 0x78, 0x92, 0x00, 0x80, 0x07, 0x7f, 0xc5, 0x32, 15 | 0x9a, 0x6e, 0x8e, 0x72, 0x49, 0xb0, 0x00, 0x8a, 0xff, 0x92, 0x95, 0x45, 0x10, 0x51, 0x09, 0x54, 16 | 0x40, 0x00, 0x17, 0xff, 0x2c, 0xa4, 0xb2, 0xd5, 0x54, 0xd4, 0xab, 0x20, 0x02, 0x43, 0xfc, 0x52, 17 | 0x1a, 0x4c, 0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 0x43, 0x0b, 0x70, 0xf8, 0x40, 0xc3, 0x0f, 0xf0, 0xc2, 0x0f, 0xc3, 0xc3, 29 | 0x0f, 0xf0, 0x78, 0x60, 0x43, 0x0f, 0xd0, 0xc0, 0x1f, 0xc3, 0x87, 0x87, 0xf0, 0xf8, 0x70, 0x03, 30 | 0x0e, 0xf0, 0xc2, 0x0e, 0xc3, 0x80, 0x07, 0xb0, 0xe8, 0x78, 0x03, 0x0f, 0xf0, 0xc3, 0x07, 0xc3, 31 | 0x00, 0x03, 0xf0, 0xf8, 0x7c, 0x03, 0x00, 0x00, 0xc3, 0x83, 0xc3, 0x00, 0x03, 0xf0, 0xf8, 0x7e, 32 | 0x03, 0x00, 0x00, 0xc3, 0xc1, 0xc2, 0x1f, 0xe1, 0xf0, 0xf8, 0x7f, 0x03, 0x80, 0x01, 0xc3, 0xe0, 33 | 0xc2, 0x1f, 0xe1, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 34 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 35 | 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 36 | }; 37 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-nokia/nokia-home-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/nokia-home-84x48.bmp 2 | const uint8_t Nokia_home_84x48[] PROGMEM = { 3 | 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 5 | 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0xf0, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x08, 0xce, 0x66, 0xce, 0x00, 9 | 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x0c, 0xdb, 0x6c, 0xdb, 0x00, 0x00, 0x00, 0x70, 0x70, 0x00, 10 | 0x00, 0x0e, 0xdb, 0x78, 0xdb, 0x00, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x0f, 0xdb, 0x70, 0xdb, 11 | 0x00, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x0d, 0xdb, 0x78, 0xdf, 0x00, 0x00, 0x00, 0x70, 0x70, 12 | 0x00, 0x00, 0x0c, 0xdb, 0x6c, 0xdb, 0x00, 0x00, 0x00, 0x70, 0x70, 0x00, 0x00, 0x0c, 0x4e, 0x66, 13 | 0xdb, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 14 | 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 25 | 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x38, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x90, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x10, 0x00, 0x00, 0x00, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x06, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x73, 0x9e, 0x6c, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xf6, 0xdb, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x06, 0xb7, 0xdb, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x36, 0x1b, 35 | 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x33, 0xdb, 0x3c, 0x00, 0x00, 0x00, 0x00, 36 | }; 37 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-wemos/hello-wemos.ino: -------------------------------------------------------------------------------- 1 | /* Hello WeMos 2 | * Displays a few WeMos bitmaps 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Bitmaps 34 | #include "wemos-logo-84x48.h" 35 | #include "wemos-logo-84x28.h" 36 | #include "wemos-w-53x48.h" 37 | #include "wemos-w-84x48.h" 38 | 39 | // Pins 40 | const int8_t RST_PIN = D2; 41 | const int8_t CE_PIN = D1; 42 | const int8_t DC_PIN = D6; 43 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 44 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 45 | const int8_t BL_PIN = D0; 46 | 47 | 48 | // Software SPI with explicit CE pin. 49 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 50 | 51 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 52 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 53 | 54 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 55 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 56 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 57 | 58 | void setup() { 59 | Serial.begin(9600); 60 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 61 | 62 | // Turn LCD backlight on 63 | pinMode(BL_PIN, OUTPUT); 64 | digitalWrite(BL_PIN, HIGH); 65 | 66 | display.begin(); 67 | display.setContrast(60); // Adjust for your display 68 | Serial.println("Show Adafruit logo bitmap"); 69 | 70 | // Show the Adafruit logo, which is preloaded into the buffer by their library 71 | // display.clearDisplay(); 72 | delay(2000); 73 | } 74 | 75 | void loop() { 76 | display.clearDisplay(); 77 | display.drawBitmap(0, 0, WeMos_logo_84x48, 84, 48, BLACK); 78 | display.display(); 79 | Serial.println("Show WeMos logo 84x48 bitmap"); 80 | delay(2000); 81 | 82 | display.clearDisplay(); 83 | display.fillScreen(1); // Black background 84 | display.drawBitmap(0, 10, WeMos_logo_84x28, 84, 28, WHITE); // Draw white pixels 'inverted' 85 | display.display(); 86 | Serial.println("Show WeMos logo 84x28 bitmap"); 87 | delay(2000); 88 | 89 | display.clearDisplay(); 90 | display.drawBitmap(0, 0, WeMos_W_84x48, 84, 48, BLACK); 91 | Serial.println("Show WeMos W logo 84x48 bitmap"); 92 | display.display(); 93 | delay(2000); 94 | 95 | display.clearDisplay(); 96 | display.fillScreen(1); // Black background 97 | display.drawBitmap(15, 0, WeMos_W_53x48, 53, 48, WHITE); // Draw white pixels 'inverted' 98 | Serial.println("Show WeMos W logo 53x48 bitmap"); 99 | display.display(); 100 | delay(2000); 101 | } 102 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-wemos/wemos-logo-84x28.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/wemos-logo-84x28.bmp 2 | const uint8_t WeMos_logo_84x28[] PROGMEM = { 3 | 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1e, 0x00, 0x03, 0x80, 0x00, 4 | 0x00, 0x00, 0x00, 0xff, 0xe0, 0x0f, 0x1e, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8, 5 | 0x0f, 0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x0f, 0x3c, 0x00, 0x01, 0xe0, 6 | 0x00, 0x00, 0x00, 0x1f, 0x80, 0x3f, 0x0f, 0x38, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x7e, 0x00, 7 | 0x0f, 0x8f, 0x78, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x78, 0x7f, 0xc3, 0x8f, 0x78, 0x00, 0x00, 8 | 0x78, 0x00, 0x00, 0x00, 0x31, 0xff, 0xf1, 0x8f, 0x70, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x07, 9 | 0xff, 0xf8, 0x0f, 0x70, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0xfc, 0x0f, 0xf0, 0x00, 10 | 0x00, 0x3c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x3c, 0x0f, 0xf0, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 11 | 0x02, 0x1f, 0x18, 0x0f, 0xf0, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x0f, 0xe0, 12 | 0x00, 0x00, 0x1c, 0x00, 0x07, 0xc0, 0x7c, 0xff, 0xe0, 0x0f, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x07, 13 | 0xc0, 0x7c, 0x73, 0xc0, 0x0f, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x07, 0xe0, 0xfc, 0x20, 0x80, 0x0f, 14 | 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x07, 0xe0, 0xfc, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x1e, 0x0f, 15 | 0x87, 0xf0, 0xfc, 0x00, 0x03, 0xef, 0xf0, 0x00, 0x00, 0x1e, 0x3f, 0xc7, 0x71, 0xdc, 0x1f, 0x07, 16 | 0xff, 0xf0, 0x01, 0x80, 0x1e, 0x38, 0xe7, 0x71, 0x9c, 0x3f, 0x8e, 0x0f, 0xf0, 0x03, 0xc0, 0x1e, 17 | 0x70, 0xe7, 0x39, 0x9c, 0x7f, 0x8f, 0x0f, 0x78, 0x03, 0xc0, 0x1c, 0x7f, 0xe7, 0x3b, 0x9c, 0x7f, 18 | 0xcf, 0xcf, 0x78, 0x07, 0xc0, 0x3c, 0x7f, 0xe7, 0x3f, 0x1c, 0x7f, 0x87, 0xff, 0x3c, 0x0f, 0xe0, 19 | 0x78, 0x70, 0x07, 0x1f, 0x1c, 0x3f, 0x80, 0xff, 0x3f, 0x7f, 0xf8, 0xf8, 0x78, 0x07, 0x1f, 0x1c, 20 | 0x3f, 0x00, 0x7f, 0x1f, 0xfe, 0xff, 0xf0, 0x3f, 0xc7, 0x1e, 0x1c, 0x0c, 0x0f, 0xff, 0x0f, 0xfc, 21 | 0x7f, 0xe0, 0x1f, 0xc7, 0x0e, 0x1c, 0x00, 0x0f, 0xef, 0x03, 0xf0, 0x1f, 0x80, 0x00, 0x00, 0x00, 22 | 0x00, 0x00, 0x00, 0x0f 23 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-wemos/wemos-logo-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/wemos-logo-84x48.bmp 2 | // the logo is vertically centred with 10px of whitespace above and below 3 | // this is not very efficient - instead, use the next bitmap and render it 10px down 4 | const uint8_t WeMos_logo_84x48[] PROGMEM = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 12 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x1e, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 13 | 0x00, 0xff, 0xe0, 0x0f, 0x1e, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xf8, 0x0f, 0x3c, 14 | 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x0f, 0x3c, 0x00, 0x01, 0xe0, 0x00, 0x00, 15 | 0x00, 0x1f, 0x80, 0x3f, 0x0f, 0x38, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x0f, 0x8f, 16 | 0x78, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x78, 0x7f, 0xc3, 0x8f, 0x78, 0x00, 0x00, 0x78, 0x00, 17 | 0x00, 0x00, 0x31, 0xff, 0xf1, 0x8f, 0x70, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x07, 0xff, 0xf8, 18 | 0x0f, 0x70, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0xfc, 0x0f, 0xf0, 0x00, 0x00, 0x3c, 19 | 0x00, 0x00, 0x00, 0x07, 0x00, 0x3c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, 0x0f, 0xef, 0x03, 0xf0, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f 38 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-wemos/wemos-w-53x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/wemos-w-53x48.bmp 2 | const uint8_t WeMos_W_53x48[] PROGMEM = { 3 | 0x00, 0xe0, 0x00, 0x00, 0x01, 0x80, 0x07, 0x01, 0xf0, 0x00, 0x00, 0x07, 0xc0, 0x07, 0x03, 0xf8, 4 | 0x00, 0x00, 0x0f, 0xe0, 0x07, 0x07, 0xf8, 0x00, 0x00, 0x0f, 0xf0, 0x07, 0x07, 0xf0, 0x00, 0x00, 5 | 0x07, 0xf0, 0x07, 0x07, 0xf0, 0x00, 0x00, 0x07, 0xfc, 0x07, 0x0f, 0xf0, 0x00, 0x00, 0x03, 0xfc, 6 | 0x07, 0x0f, 0xe0, 0x00, 0x00, 0x01, 0xfe, 0x07, 0x1f, 0xc0, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x1f, 7 | 0xc0, 0x00, 0x00, 0x00, 0xff, 0x07, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x7f, 0x07, 0x3f, 0x80, 0x00, 8 | 0x00, 0x00, 0x3f, 0x87, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x3f, 0x87, 0x3f, 0x80, 0x00, 0x00, 0x00, 9 | 0x1f, 0xc7, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc7, 10 | 0x7e, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xe7, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe7, 0x7e, 0x00, 11 | 0x00, 0x00, 0x00, 0x07, 0xe7, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf7, 0x7e, 0x00, 0x00, 0x00, 12 | 0x00, 0x03, 0xf7, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf7, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x03, 13 | 0xf7, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf7, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 14 | 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 15 | 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 16 | 0x01, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 17 | 0x7e, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0x7e, 0x00, 0x00, 0x7c, 0x00, 0x01, 0xff, 0x7e, 0x00, 18 | 0x00, 0x7e, 0x00, 0x03, 0xff, 0x7f, 0x00, 0x00, 0xfe, 0x00, 0x03, 0xf7, 0x7f, 0x00, 0x00, 0xfe, 19 | 0x00, 0x03, 0xf7, 0x3f, 0x80, 0x00, 0xff, 0x00, 0x03, 0xf7, 0x3f, 0x80, 0x01, 0xff, 0x00, 0x07, 20 | 0xf7, 0x1f, 0xc0, 0x03, 0xff, 0x80, 0x0f, 0xe7, 0x1f, 0xe0, 0x07, 0xff, 0xc0, 0x0f, 0xe7, 0x1f, 21 | 0xf8, 0x3f, 0xff, 0xf0, 0x3f, 0xc7, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7, 0x07, 0xff, 0xff, 22 | 0xef, 0xff, 0xff, 0x87, 0x03, 0xff, 0xff, 0xcf, 0xff, 0xff, 0x07, 0x01, 0xff, 0xff, 0x03, 0xff, 23 | 0xfe, 0x07, 0x00, 0x7f, 0xfc, 0x00, 0xff, 0xfc, 0x07, 0x00, 0x0f, 0xf0, 0x00, 0x1f, 0xe0, 0x07 24 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-wemos/wemos-w-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/wemos-w-84x48.bmp 2 | // the logo is horizontally centred with 15px of whitespace left and 16px right 3 | // this is not very efficient - instead, use the next bitmap and render it 15px across 4 | const uint8_t WeMos_W_84x48[] PROGMEM = { 5 | 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x03, 0xe0, 0x00, 6 | 0x00, 0x0f, 0x80, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 7 | 0x0f, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0xe0, 8 | 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x0f, 0xf8, 0x00, 9 | 0x00, 0x0f, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x07, 0xf8, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x1f, 10 | 0xc0, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x01, 0xfc, 11 | 0x00, 0x00, 0x0f, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x0f, 0x00, 0x00, 12 | 0x3f, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 13 | 0x7f, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x0f, 0x00, 14 | 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x0f, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 15 | 0x00, 0x1f, 0x80, 0x00, 0x0f, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x0f, 16 | 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 17 | 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 18 | 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 19 | 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 20 | 0x00, 0x0f, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x01, 0xf8, 21 | 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 22 | 0xf0, 0x00, 0x0f, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x01, 23 | 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 24 | 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 25 | 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x00, 26 | 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 27 | 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 28 | 0xf8, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x07, 0xf0, 0x00, 29 | 0x0f, 0x00, 0x00, 0xfe, 0x00, 0x01, 0xfc, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x00, 0xfe, 0x00, 30 | 0x01, 0xfc, 0x00, 0x07, 0xe0, 0x00, 0x0f, 0x00, 0x00, 0x7f, 0x00, 0x01, 0xfe, 0x00, 0x07, 0xe0, 31 | 0x00, 0x0f, 0x00, 0x00, 0x7f, 0x00, 0x03, 0xfe, 0x00, 0x0f, 0xe0, 0x00, 0x0f, 0x00, 0x00, 0x3f, 32 | 0x80, 0x07, 0xff, 0x00, 0x1f, 0xc0, 0x00, 0x0f, 0x00, 0x00, 0x3f, 0xc0, 0x0f, 0xff, 0x80, 0x1f, 33 | 0xc0, 0x00, 0x0f, 0x00, 0x00, 0x3f, 0xf0, 0x7f, 0xff, 0xe0, 0x7f, 0x80, 0x00, 0x0f, 0x00, 0x00, 34 | 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x0f, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xdf, 0xff, 35 | 0xff, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, 0xff, 0xff, 0x9f, 0xff, 0xfe, 0x00, 0x00, 0x0f, 0x00, 36 | 0x00, 0x03, 0xff, 0xfe, 0x07, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x01, 37 | 0xff, 0xf8, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x0f 38 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/hello-world/hello-world.ino: -------------------------------------------------------------------------------- 1 | /* Hello World 2 | * Display a simple message on the first line of the screen 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Pins 34 | const int8_t RST_PIN = D2; 35 | const int8_t CE_PIN = D1; 36 | const int8_t DC_PIN = D6; 37 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 38 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 39 | const int8_t BL_PIN = D0; 40 | 41 | 42 | // Software SPI with explicit CE pin. 43 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 44 | 45 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 46 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 47 | 48 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 49 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 50 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 51 | 52 | void setup() { 53 | Serial.begin(9600); 54 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 55 | 56 | // Turn LCD backlight on 57 | pinMode(BL_PIN, OUTPUT); 58 | digitalWrite(BL_PIN, HIGH); 59 | 60 | display.begin(); 61 | display.setContrast(60); // Adjust for your display 62 | Serial.println("Show Adafruit logo bitmap"); 63 | 64 | // Show the Adafruit logo, which is preloaded into the buffer by their library 65 | // display.clearDisplay(); 66 | delay(2000); 67 | 68 | display.clearDisplay(); 69 | display.setTextSize(1); 70 | display.setTextColor(BLACK); 71 | display.setCursor(0,0); 72 | display.println("Hello, world!"); 73 | display.display(); 74 | Serial.println("You should now see Hello, world! on the display"); 75 | } 76 | 77 | void loop() { 78 | } 79 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/qr-code/qr-code-25x25.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/qr-code-25x25.bmp 2 | const uint8_t QR_Code_25x25[] PROGMEM = { 3 | 0xfe, 0x23, 0x3f, 0x80, 4 | 0x82, 0xe3, 0x20, 0x80, 5 | 0xba, 0x81, 0x2e, 0x80, 6 | 0xba, 0x46, 0x2e, 0x80, 7 | 0xba, 0xed, 0x2e, 0x80, 8 | 0x82, 0xaf, 0xa0, 0x80, 9 | 0xfe, 0xaa, 0xbf, 0x80, 10 | 0x00, 0xb3, 0x00, 0x00, 11 | 0xd3, 0x16, 0xbb, 0x00, 12 | 0xcc, 0x5e, 0xe0, 0x80, 13 | 0xbe, 0x00, 0x49, 0x80, 14 | 0x41, 0xf4, 0x70, 0x00, 15 | 0x1e, 0xae, 0xf5, 0x80, 16 | 0x34, 0x0a, 0x36, 0x80, 17 | 0x96, 0x1a, 0xba, 0x80, 18 | 0x7d, 0xd4, 0x89, 0x00, 19 | 0xdb, 0x51, 0xfe, 0x00, 20 | 0x00, 0xad, 0x8c, 0x80, 21 | 0xfe, 0xe5, 0xad, 0x80, 22 | 0x82, 0x4b, 0x8f, 0x00, 23 | 0xba, 0x7c, 0xfc, 0x00, 24 | 0xba, 0xca, 0x1e, 0x00, 25 | 0xba, 0x07, 0x5a, 0x80, 26 | 0x82, 0xfc, 0xc4, 0x00, 27 | 0xfe, 0x81, 0xb1, 0x80 28 | }; 29 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/qr-code/qr-code.ino: -------------------------------------------------------------------------------- 1 | /* QR Code 2 | * Displays a QR Code. 3 | * You'll have to scan it to find out what it is. 4 | * 5 | * Connections: 6 | * WeMos D1 Mini Nokia 5110 Description 7 | * (ESP8266) PCD8544 LCD 8 | * 9 | * D2 (GPIO4) 0 RST Output from ESP to reset display 10 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 11 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 12 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 13 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 14 | * 3V3 5 Vcc 3.3V from ESP to display 15 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 16 | * G 7 Gnd Ground 17 | * 18 | * More info: 19 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 20 | * 21 | * Dependencies: 22 | * https://github.com/adafruit/Adafruit-GFX-Library 23 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 24 | * - This pull request adds ESP8266 support: 25 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 26 | */ 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | // Bitmaps 35 | #include "qr-code-25x25.h" 36 | 37 | // Pins 38 | const int8_t RST_PIN = D2; 39 | const int8_t CE_PIN = D1; 40 | const int8_t DC_PIN = D6; 41 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 42 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 43 | const int8_t BL_PIN = D0; 44 | 45 | 46 | // Software SPI with explicit CE pin. 47 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 48 | 49 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 50 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 51 | 52 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 53 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 54 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 55 | 56 | void setup() { 57 | Serial.begin(9600); 58 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 59 | 60 | // Turn LCD backlight on 61 | pinMode(BL_PIN, OUTPUT); 62 | digitalWrite(BL_PIN, HIGH); 63 | 64 | display.begin(); 65 | display.setContrast(60); // Adjust for your display 66 | Serial.println("Show Adafruit logo bitmap"); 67 | 68 | // Show the Adafruit logo, which is preloaded into the buffer by their library 69 | // display.clearDisplay(); 70 | delay(2000); 71 | 72 | display.clearDisplay(); 73 | display.drawBitmap(29, 11, QR_Code_25x25, 25, 25, 1); 74 | display.display(); 75 | } 76 | 77 | void loop() { 78 | } 79 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/rotate/rotate.ino: -------------------------------------------------------------------------------- 1 | /* Text Rotation 2 | * Display some characters at 0, 90, 180 and 270 degrees 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Pins 34 | const int8_t RST_PIN = D2; 35 | const int8_t CE_PIN = D1; 36 | const int8_t DC_PIN = D6; 37 | //const int8_t DIN_PIN = D7; // uncomment for Software SPI 38 | //const int8_t CLK_PIN = D5; // uncomment for Software SPI 39 | const int8_t BL_PIN = D0; 40 | 41 | 42 | // Software SPI with explicit CE pin. 43 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 44 | 45 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 46 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 47 | 48 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 49 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 50 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 51 | 52 | void setup() { 53 | Serial.begin(9600); 54 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 55 | 56 | // Turn LCD backlight on 57 | pinMode(BL_PIN, OUTPUT); 58 | digitalWrite(BL_PIN, HIGH); 59 | 60 | display.begin(); 61 | display.setContrast(60); // Adjust for your display 62 | Serial.println("Show Adafruit logo bitmap"); 63 | 64 | // Show the Adafruit logo, which is preloaded into the buffer by their library 65 | // display.clearDisplay(); 66 | delay(2000); 67 | 68 | display.clearDisplay(); 69 | display.setTextSize(1); 70 | display.setTextColor(BLACK); 71 | display.display(); 72 | } 73 | 74 | void loop() { 75 | // setRotation(0) = 0 degrees 76 | // setRotation(1) = 90 degrees counter clockwise 77 | // setRotation(2) = 180 degrees counter clockwise 78 | // setRotation(3) = 270 degrees counter clockwise 79 | 80 | for (uint8_t i = 0; i <= 3; i++) { 81 | display.clearDisplay(); 82 | display.setRotation(i); 83 | display.setCursor(0,0); 84 | // Print some ASCII characters (A-Z, a-z, 0-9, !-/, :-@) 85 | for (char c = 'A'; c <= 'Z'; c++) { 86 | display.print(c); 87 | } 88 | for (char c = 'a'; c <= 'z'; c++) { 89 | display.print(c); 90 | } 91 | for (char c = '0'; c <= '9'; c++) { 92 | display.print(c); 93 | } 94 | for (char c = 33; c <= 47; c++) { 95 | display.print(c); 96 | } 97 | for (char c = 58; c <= 64; c++) { 98 | display.print(c); 99 | } 100 | display.display(); 101 | Serial.print(i * 90); 102 | Serial.println(" degrees"); 103 | delay(2000); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/screen-saver/cool-smiley-15x15.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/cool-smiley-15x15.bmp 2 | const uint8_t Cool_Smiley_15x15[] PROGMEM = { 3 | 0x07, 0xc1, 4 | 0x18, 0x31, 5 | 0x20, 0x09, 6 | 0x40, 0x05, 7 | 0x40, 0x05, 8 | 0xff, 0xff, 9 | 0xa7, 0x9b, 10 | 0xae, 0xbb, 11 | 0x9c, 0x73, 12 | 0x80, 0x03, 13 | 0x40, 0x25, 14 | 0x43, 0xc5, 15 | 0x20, 0x09, 16 | 0x18, 0x31, 17 | 0x07, 0xc1 18 | }; 19 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/screen-saver/screen-saver.ino: -------------------------------------------------------------------------------- 1 | /* Screen Saver 2 | * Move a bitmap around, bounce it off walls like an old screensaver 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Bitmaps 34 | #include "cool-smiley-15x15.h" 35 | 36 | // Pins 37 | const int8_t RST_PIN = D2; 38 | const int8_t CE_PIN = D1; 39 | const int8_t DC_PIN = D6; 40 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 41 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 42 | const int8_t BL_PIN = D0; 43 | 44 | // 15x15 smiley 45 | const int8_t ART_W = 15; 46 | const int8_t ART_H = 15; 47 | 48 | // Area the smiley can move in 49 | const int8_t BOUNDS_W = 69; // 84 - 15 50 | const int8_t BOUNDS_H = 33; // 48 - 15 51 | 52 | // Direction smiley is moving 53 | int8_t move_x = 1; 54 | int8_t move_y = 1; 55 | 56 | // Pause between displaying frames 57 | int pause = 500; 58 | 59 | // Start position 60 | int8_t x = 1, y = 1; 61 | 62 | 63 | // Software SPI with explicit CE pin. 64 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 65 | 66 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 67 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 68 | 69 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 70 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 71 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 72 | 73 | void setup() { 74 | Serial.begin(9600); 75 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 76 | 77 | // Turn LCD backlight on 78 | pinMode(BL_PIN, OUTPUT); 79 | digitalWrite(BL_PIN, HIGH); 80 | 81 | display.begin(); 82 | display.setContrast(60); // Adjust for your display 83 | Serial.println("Show Adafruit logo bitmap"); 84 | 85 | // Show the Adafruit logo, which is preloaded into the buffer by their library 86 | // display.clearDisplay(); 87 | delay(2000); 88 | 89 | display.clearDisplay(); 90 | display.display(); 91 | } 92 | 93 | void loop() { 94 | // Draw the bitmap 95 | display.clearDisplay(); 96 | display.drawBitmap(x, y, Cool_Smiley_15x15, 15, 15, 1); 97 | display.display(); 98 | delay(pause); 99 | 100 | // Move down right until hit bounds 101 | // Then flip increment to decrement to bounce off the wall 102 | x = x + move_x; 103 | y = y + move_y; 104 | if (x <= 0 || x >= BOUNDS_W) { 105 | move_x = -move_x; 106 | } 107 | if (y <= 0 || y >= BOUNDS_H) { 108 | move_y = -move_y; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/screen-saver/smiley-9x9.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/smiley-9x9.bmp 2 | const uint8_t Smiley_9x9[] PROGMEM = { 3 | 0x3e, 0x7f, 4 | 0x41, 0x7f, 5 | 0x94, 0xff, 6 | 0x80, 0xff, 7 | 0xbe, 0xff, 8 | 0xbe, 0xff, 9 | 0x9c, 0xff, 10 | 0x41, 0x7f, 11 | 0x3e, 0x7f 12 | }; 13 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-1-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-1-84x48.bmp 2 | const uint8_t Spiral_1_84x48[] PROGMEM = { 3 | 0xf0, 0x1f, 0x81, 0xf8, 0x00, 0x00, 0x03, 0xe0, 0x7e, 0x07, 0xff, 0xe0, 0x3f, 0x03, 0xf0, 0x0f, 4 | 0xfe, 0x01, 0xf8, 0x3e, 0x07, 0xff, 0xe0, 0x3e, 0x07, 0xc0, 0x7f, 0xff, 0xc0, 0x7c, 0x1f, 0x03, 5 | 0xff, 0xc0, 0x7c, 0x0f, 0x81, 0xff, 0xbf, 0xf0, 0x3e, 0x0f, 0x83, 0xff, 0xc0, 0xfc, 0x1f, 0x07, 6 | 0xe0, 0x00, 0xfc, 0x1f, 0x07, 0x81, 0xff, 0x80, 0xf8, 0x3c, 0x0f, 0x80, 0x00, 0x3e, 0x0f, 0x87, 7 | 0xc1, 0xff, 0x01, 0xf0, 0x7c, 0x3e, 0x00, 0xf0, 0x0f, 0x87, 0x83, 0xc0, 0xff, 0x01, 0xf0, 0xf8, 8 | 0x78, 0x0f, 0xff, 0x03, 0xc3, 0xc3, 0xe0, 0xff, 0x03, 0xe0, 0xf0, 0xf0, 0x7f, 0xff, 0xc1,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 0x07, 0xc1, 0xe1, 0xe0, 0xf8, 0x00, 0x3e, 0x0f, 31 | 0x07, 0x81, 0xff, 0x07, 0xe0, 0xf0, 0xf0, 0x7f, 0x03, 0xfc, 0x1e, 0x0f, 0x83, 0xff, 0x03, 0xe0, 32 | 0xf0, 0x78, 0x1f, 0xff, 0xf0, 0x3c, 0x1f, 0x03, 0xff, 0x03, 0xf0, 0x78, 0x3e, 0x03, 0xff, 0x80, 33 | 0xf8, 0x1e, 0x07, 0xef, 0x01, 0xf0, 0x7c, 0x1f, 0x00, 0x00, 0x01, 0xf0, 0x3e, 0x0f, 0xef, 0x01, 34 | 0xf8, 0x3e, 0x0f, 0xc0, 0x00, 0x07, 0xe0, 0x7c, 0x0f, 0xcf, 0x80, 0xfc, 0x1f, 0x03, 0xf8, 0x00, 35 | 0x3f, 0x80, 0xf8, 0x1f, 0xcf, 0x80, 0x7c, 0x0f, 0x80, 0xff, 0xff, 0xfe, 0x03, 0xf0, 0x3f, 0x8f, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-2-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-2-84x48.bmp 2 | const uint8_t Spiral_2_84x48[] PROGMEM = { 3 | 0x80, 0x7e, 0x07, 0xe0, 0x0f, 0xfe, 0x00, 0xf8, 0x1f, 0x03, 0xff, 0x80, 0xfc, 0x0f, 0x80, 0x7f, 4 | 0xff, 0xc0, 0x7c, 0x1f, 0x81, 0xff, 0x00, 0xf8, 0x1f, 0x03, 0xff, 0xff, 0xf0, 0x3e, 0x0f, 0x81, 5 | 0xff, 0x01, 0xf8, 0x3e, 0x07, 0xf0, 0x01, 0xfc, 0x1f, 0x07, 0xc0, 0xff, 0x03, 0xf0, 0x7c, 0x1f, 6 | 0x80, 0x00, 0x3e, 0x07, 0x83, 0xc0, 0xff, 0x03, 0xe0, 0xf8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 0xf0, 0xf0, 0x3f, 0x3e, 0x0f, 0x0e, 0x1e, 0x1f, 0xff, 0xe0, 0xe1, 0xe1, 29 | 0xf0, 0x7f, 0x1f, 0x07, 0x87, 0x0f, 0x07, 0xff, 0x81, 0xe1, 0xe1, 0xe0, 0x7f, 0x1f, 0x07, 0x87, 30 | 0x87, 0x80, 0x78, 0x07, 0x83, 0xc3, 0xe0, 0xff, 0x1f, 0x83, 0xc3, 0xc3, 0xe0, 0x00, 0x1f, 0x07, 31 | 0x83, 0xc0, 0xff, 0x0f, 0x83, 0xc1, 0xe0, 0xfc, 0x00, 0x7e, 0x0f, 0x07, 0xc1, 0xff, 0x0f, 0xc1, 32 | 0xe0, 0xf0, 0x3f, 0xff, 0xf8, 0x1e, 0x0f, 0x81, 0xff, 0x07, 0xc1, 0xf0, 0x78, 0x0f, 0xff, 0xe0, 33 | 0x3c, 0x0f, 0x03, 0xff, 0x07, 0xe0, 0xf8, 0x3e, 0x01, 0xfe, 0x00, 0xf8, 0x1f, 0x03, 0xff, 0x03, 34 | 0xe0, 0x7c, 0x1f, 0x00, 0x00, 0x03, 0xf0, 0x3e, 0x07, 0xff, 0x03, 0xf0, 0x3e, 0x0f, 0xe0, 0x00, 35 | 0x0f, 0xe0, 0x7c, 0x0f, 0xef, 0x01, 0xf8, 0x1f, 0x03, 0xfc, 0x00, 0x7f, 0x80, 0xf8, 0x0f, 0xef, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-3-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-3-84x48.bmp 2 | const uint8_t Spiral_3_84x48[] PROGMEM = { 3 | 0x01, 0xf8, 0x0f, 0x80, 0x7f, 0xff, 0x80, 0x7c, 0x0f, 0x80, 0xff, 0x01, 0xf8, 0x1f, 0x01, 0xff, 4 | 0xff, 0xf0, 0x3e, 0x07, 0xc0,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, 0x87, 26 | 0xff, 0x87, 0x0e, 0x1c, 0x3e, 0x0f, 0xf8, 0x3c, 0x38, 0xe1, 0xc3, 0xfe, 0x0f, 0x1c, 0x3c, 0x3c, 27 | 0x0f, 0xf8, 0x3c, 0x38, 0x71, 0xe0, 0x30, 0x1e, 0x1c, 0x38, 0x7c, 0x1f, 0xfc, 0x3c, 0x3c, 0x78, 28 | 0x78, 0x00, 0x7c, 0x38, 0x78, 0x7c, 0x1f, 0x7c, 0x1e, 0x1c, 0x38, 0x3e, 0x01, 0xf0, 0x70, 0xf0, 29 | 0x78, 0x1f, 0x7c, 0x1e, 0x1e, 0x1e, 0x0f, 0xff, 0xe0, 0xf0, 0xf0, 0xf8, 0x3f, 0x7e, 0x0f, 0x0f, 30 | 0x0f, 0x03, 0xff, 0x03, 0xe1, 0xe1, 0xf0, 0x3f, 0x7e, 0x0f, 0x07, 0x87, 0x80, 0x00, 0x07, 0x83, 31 | 0xc1, 0xf0, 0x3f, 0x3f, 0x07, 0x87, 0x83, 0xe0, 0x00, 0x1f, 0x07, 0x83, 0xe0, 0x7f, 0x3f, 0x07, 32 | 0xc3, 0xc0, 0xfc, 0x00, 0xfe, 0x0f, 0x83, 0xc0, 0xff, 0x1f, 0x03, 0xc1, 0xf0, 0x7f, 0xff, 0xf8, 33 | 0x1f, 0x07, 0xc0, 0xff, 0x1f, 0x81, 0xe0, 0xf8, 0x0f, 0xff, 0xe0, 0x3e, 0x0f, 0x81, 0xff, 0x0f, 34 | 0xc1, 0xf0, 0x7c, 0x00, 0xfe, 0x00, 0xf8, 0x1f, 0x01, 0xff, 0x0f, 0xc0, 0xf8, 0x1f, 0x00, 0x00, 35 | 0x03, 0xf0, 0x3f, 0x03, 0xff, 0x07, 0xe0, 0x7c, 0x0f, 0xe0, 0x00, 0x0f, 0xe0, 0x7e, 0x07, 0xff, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-4-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-4-84x48.bmp 2 | const uint8_t Spiral_4_84x48[] PROGMEM = { 3 | 0x03, 0xf0, 0x3f, 0x01, 0xff, 0xff, 0xe0, 0x3e, 0x07, 0xe0, 0x3f, 0x07, 0xe0, 0x7c, 0x07, 0xfc, 4 | 0x07, 0xf8, 0x0f, 0x03, 0xe0, 0x3f, 0x0f, 0xc0, 0xf8, 0x1f, 0xc0, 0x00, 0x7e, 0x07, 0x81, 0xf0, 5 | 0x1f, 0x0f, 0xc0, 0xf0, 0x3e, 0x00, 0x00, 0x1f, 0x03, 0xc0, 0xf8, 0x1f, 0x1f, 0x81, 0xe0, 0x78, 6 | 0x01, 0xf0, 0x07, 0xc1, 0xe0, 0xf8, 0x0f, 0x1f, 0x03, 0xc0, 0xf0, 0x1f, 0xff, 0x01, 0xe0, 0xf0, 7 | 0x7c, 0x0f, 0x3f, 0x07, 0xc1, 0xe0, 0xff, 0xff, 0xc0, 0xf0, 0xf0, 0x7c, 0x0f, 0x3e, 0x07, 0x83, 8 | 0xc1, 0xf0, 0x01, 0xf0, 0x78, 0x78, 0x3e, 0x0f, 0x7e, 0x0f, 0x07, 0x07, 0xc0, 0x00, 0x78, 0x38, 9 | 0x38, 0x3e, 0x0f, 0x7c, 0x0e, 0x0f, 0x0f, 0x00, 0xc0, 0x1e, 0x1c, 0x3c, 0x1e, 0x0f, 0xfc, 0x1e, 10 | 0x1e, 0x1e, 0x0f, 0xfe, 0x0f, 0x0e, 0x1c, 0x1f, 0x0f, 0xf8, 0x1c, 0x1c, 0x38, 0x3f, 0xff, 0x87, 11 | 0x0e, 0x1e, 0x1f, 0x0f, 0xf8, 0x3c, 0x3c, 0x70, 0x78, 0x03, 0xc3, 0x87, 0x0e, 0x0f, 0x0f, 0xf8, 12 | 0x3c, 0x38, 0x70, 0xe0, 0x00, 0xe1, 0xc7, 0x0f, 0x0f, 0x0f, 0x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80, 0x7e, 0x0f, 0xc0, 0x7f, 0x1f, 0x81, 0xf0, 0x3e, 0x00, 0x00, 35 | 0x00, 0xf8, 0x0f, 0x80, 0xff, 0x1f, 0xc0, 0xf8, 0x1f, 0x80, 0x00, 0x03, 0xf0, 0x3f, 0x01, 0xff, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-5-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-5-84x48.bmp 2 | const uint8_t Spiral_5_84x48[] PROGMEM = { 3 | 0x1f, 0xc0, 0x7c, 0x07, 0xfe, 0x1f, 0xf8, 0x0f, 0x81, 0xf0, 0x0f, 0x1f, 0x80, 0xf8, 0x1f, 0xc0, 4 | 0x00, 0xfe, 0x07, 0xc1, 0xf8, 0x0f, 0x3f, 0x81, 0xf0, 0x3e, 0x00, 0x00, 0x1f, 0x03, 0xc0, 0xf8, 5 | 0x0f, 0x3f, 0x03, 0xe0, 0xf8, 0x00, 0x00, 0x07, 0xc1, 0xe0, 0x7c, 0x0f, 0x7e, 0x07, 0xc1, 0xf0, 6 | 0x1f, 0xfe, 0x03, 0xe0, 0xf0, 0x7c, 0x0f, 0x7e, 0x07, 0x83, 0xc0, 0x7f, 0xff, 0xc0, 0xf0, 0x78, 7 | 0x3e, 0x0f, 0xfc, 0x0f, 0x07, 0x81, 0xf8, 0x03, 0xf0, 0x78, 0x78, 0x3e, 0x0f, 0xfc, 0x1f, 0x0f, 8 | 0x07, 0xc0, 0x00, 0xf8, 0x3c, 0x3c, 0x1f, 0x0f, 0xf8, 0x1e, 0x0e, 0x0f, 0x00, 0x00, 0x3c, 0x1c, 9 | 0x1c, 0x1f, 0x0f, 0xf8, 0x3c, 0x1c, 0x1e, 0x07, 0xfc, 0x0e, 0x0e, 0x1e, 0x0f, 0x0f, 0xf0, 0x3c, 10 | 0x3c, 0x38, 0x3f, 0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0x1e, 32 | 0x0f, 0x07, 0xc0, 0x00, 0x0f, 0x83, 0xe0, 0xf8, 0x0f, 0xfc, 0x1f, 0x07, 0x81, 0xf8, 0x00, 0x7f, 33 | 0x07, 0xc1, 0xf0, 0x1f, 0xfc, 0x0f, 0x83, 0xc0, 0xff, 0xef, 0xfc, 0x0f, 0x83, 0xf0, 0x1f, 0xfe, 34 | 0x07, 0x81, 0xf0, 0x1f, 0xff, 0xe0, 0x1f, 0x03, 0xe0, 0x3f, 0xfe, 0x07, 0xc0, 0xf8, 0x03, 0xff, 35 | 0x00, 0x7e, 0x07, 0xc0, 0x3f, 0x7f, 0x03, 0xe0, 0x7e, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x80, 0x7f, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-6-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-6-84x48.bmp 2 | const uint8_t Spiral_6_84x48[] PROGMEM = { 3 | 0x3f, 0x81, 0xf8, 0x0f, 0xe0, 0x01, 0xfe, 0x07, 0xc0, 0xfc, 0x0f, 0x7f, 0x01, 0xf0, 0x3f, 0x00, 4 | 0x00, 0x3f, 0x03, 0xe0, 0x7c, 0x0f, 0x7e, 0x03, 0xe0, 0x7c, 0x00, 0x00, 0x07, 0xc1, 0xf0, 0x3e, 5 | 0x0f, 0xfe, 0x07, 0xc1, 0xf0, 0x07, 0xfc, 0x03, 0xe0, 0xf8, 0x3f, 0x0f, 0xfc, 0x0f, 0x83, 0xe0, 6 | 0x3f, 0xff, 0x80, 0xf0, 0x78, 0x1f, 0x0f, 0xfc, 0x0f, 0x07, 0xc1, 0xff, 0x1f, 0xe0, 0x78, 0x3c, 7 | 0x1f, 0x8f, 0xf8, 0x1e, 0x0f, 0x03, 0xe0, 0x00, 0xf8, 0x3c, 0x3e, 0x0f, 0x8f, 0xf8,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, 30 | 0x78, 0x3e, 0x01, 0xf8, 0x3c, 0x3c, 0x1f, 0x0f, 0xe0, 0x78, 0x3c, 0x3c, 0x1f, 0xff, 0xe0, 0x78, 31 | 0x7c, 0x1f, 0x0f, 0xe0, 0x7c, 0x3c, 0x1e, 0x03, 0xff, 0x01, 0xf0, 0x78, 0x3e, 0x0f, 0xf0, 0x3c, 32 | 0x1e, 0x0f, 0x80, 0x00, 0x03, 0xe0, 0xf0, 0x3e, 0x0f, 0xf0, 0x3e, 0x0f, 0x07, 0xe0, 0x00, 0x0f, 33 | 0x81, 0xe0, 0x7c, 0x0f, 0xf8, 0x1f, 0x07, 0x81, 0xf8, 0x00, 0x7f, 0x03, 0xc0, 0xfc, 0x0f, 0xf8, 34 | 0x1f, 0x03, 0xc0, 0x7f, 0xff, 0xfc, 0x07, 0x81, 0xf8, 0x0f, 0xfc, 0x0f, 0x81, 0xf0, 0x1f, 0xff, 35 | 0xf0, 0x1f, 0x03, 0xf0, 0x0f, 0xfc, 0x07, 0xc0, 0xf8, 0x01, 0xff, 0x00, 0x3e, 0x03, 0xe0, 0x1f, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-7-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-7-84x48.bmp 2 | const uint8_t Spiral_7_84x48[] PROGMEM = { 3 | 0xfe, 0x03, 0xe0, 0x3f, 0x00, 0x00, 0x3f, 0x81, 0xf0, 0x3f, 0x0f, 0xfc, 0x07, 0xc0, 0xfc, 0x00, 4 | 0x00, 0x0f, 0xc0, 0xf0, 0x3f, 0x0f, 0xfc, 0x0f, 0x81, 0xf0, 0x07, 0xf8, 0x03, 0xe0, 0x78, 0x1f, 5 | 0x8f, 0xf8, 0x1f, 0x03, 0xe0, 0x3f, 0xff, 0x80, 0xf0, 0x7c, 0x0f, 0x8f, 0xf0, 0x1f, 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, 17 | 0x9c, 0x07, 0x31, 0x8c, 0x30, 0xf0, 0xff, 0x07, 0x87, 0x1c, 0x63, 0x18, 0xe3, 0x31, 0x8e, 0x38, 18 | 0xf0, 0xff, 0x0f, 0x87, 0x1c, 0x63, 0x39, 0xf3, 0x19, 0x8e, 0x38, 0xf0, 0xff, 0x0f, 0x07, 0x1c, 19 | 0x63, 0x31, 0x33, 0x19, 0x8e, 0x38, 0xf0, 0xff, 0x0f, 0x07, 0x1c, 0x63, 0x33, 0x33, 0x31, 0x8e, 20 | 0x38, 0xf0, 0xff, 0x0f, 0x07, 0x1c, 0x63, 0x33, 0x03, 0x31, 0x8c, 0x30, 0xf0, 0xff, 0x0f, 0x07, 21 | 0x1c, 0x63, 0x31, 0x8e, 0x31, 0x8c, 0x70, 0xf0, 0xff, 0x0f, 0x07, 0x1c, 0x63, 0x18, 0xfc, 0x73, 22 | 0x8c, 0x70, 0xe0, 0xff, 0x0f, 0x87, 0x1c, 0x63, 0x18, 0x78, 0x63, 0x1c, 0x70, 0xe0, 0xff, 0x07, 23 | 0x87, 0x0c, 0x71, 0x8c, 0x01, 0xc7, 0x18, 0x70, 0xe0, 0xff, 0x07, 0x87, 0x0c, 0x31, 0x87, 0x03, 24 | 0x86, 0x38, 0x61, 0xe0, 0xff, 0x07, 0x87, 0x0e, 0x30, 0xc3, 0xff, 0x0e, 0x38, 0xe1, 0xe1, 0xff, 25 | 0x07, 0x87, 0x8e, 0x38, 0xe0, 0xfc, 0x1c, 0x70, 0xe1, 0xc1, 0xff, 0x07, 0x83, 0x87, 0x1c, 0x70, 26 | 0x00, 0x38, 0x71, 0xc3, 0xc1, 0xff, 0x07, 0xc3, 0x87, 0x0c, 0x3c, 0x00, 0xf0, 0xe1, 0xc3, 0xc3, 27 | 0xff, 0x03, 0xc3, 0xc3, 0x8e, 0x0f, 0xcf, 0xc1, 0xc3, 0x83, 0x83, 0xef, 0x03, 0xc1, 0xc3, 0x87, 28 | 0x03, 0xff, 0x83, 0x87, 0x87, 0x83, 0xef, 0x03, 0xe1, 0xe1, 0xc3, 0xc0, 0x78, 0x07, 0x07, 0x0f, 29 | 0x07, 0xef, 0x81, 0xe0, 0xe1, 0xe1, 0xe0, 0x00, 0x1e, 0x0e, 0x0f, 0x07, 0xcf, 0x81, 0xf0, 0xf0, 30 | 0xf0, 0xf8, 0x00, 0x7c, 0x1e, 0x1e, 0x0f, 0xcf, 0x81, 0xf0, 0x78, 0x78, 0x3f, 0xff, 0xf0, 0x3c, 31 | 0x1e, 0x0f, 0x8f, 0xc0, 0xf8, 0x78, 0x3c, 0x0f, 0xff, 0xc0, 0xf8, 0x3c, 0x1f, 0x8f, 0xc0, 0xf8, 32 | 0x3c, 0x1e, 0x01, 0xfe, 0x01, 0xf0, 0x78, 0x1f, 0x0f, 0xc0, 0x7c, 0x1e, 0x0f, 0x80, 0x00, 0x07, 33 | 0xc0, 0xf0, 0x3f, 0x0f, 0xe0, 0x7c, 0x0f, 0x03, 0xe0, 0x00, 0x1f, 0x81, 0xf0, 0x7e, 0x0f, 0xe0, 34 | 0x3e, 0x07, 0x81, 0xfe, 0x01, 0xfe, 0x03, 0xe0, 0x7c, 0x0f, 0xf0, 0x1f, 0x03, 0xc0, 0x7f, 0xff, 35 | 0xf8, 0x0f, 0xc0, 0xfc, 0x0f, 0xf0, 0x1f, 0x81, 0xf0, 0x0f, 0xff, 0xe0, 0x1f, 0x81, 0xf8, 0x0f, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-8-84x48.h: -------------------------------------------------------------------------------- 1 | // See https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544/blob/master/bitmaps/spiral-8-84x48.bmp 2 | const uint8_t Spiral_8_84x48[] PROGMEM = { 3 | 0xf8, 0x0f, 0xc0, 0xfc, 0x00, 0x00, 0x0f, 0xc0, 0xf8, 0x1f, 0xcf, 0xf8, 0x1f, 0x81, 0xf8, 0x00, 4 | 0xc0, 0x03, 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c, 0x70, 0xe1, 0xe0, 0xff, 0x0f, 0x87, 0x0e, 0x1c, 0x78, 0x00, 0x78, 0x71, 0xe1, 0xe0, 27 | 0xff, 0x0f, 0x87, 0x87, 0x1c, 0x3e, 0x01, 0xf0, 0xe1, 0xc3, 0xc1, 0xff, 0x07, 0x83, 0x87, 0x0e, 28 | 0x0f, 0xff, 0xc1, 0xc3, 0xc3, 0xc1, 0xff, 0x07, 0xc3, 0xc3, 0x87, 0x83, 0xff, 0x03, 0x83, 0x87, 29 | 0x81, 0xff, 0x07, 0xc1, 0xc3, 0xc3, 0xc0, 0x00, 0x0f, 0x07, 0x07, 0x83, 0xff, 0x03, 0xc1, 0xe1, 30 | 0xe1, 0xf0, 0x00, 0x3e, 0x0f, 0x0f, 0x03, 0xef, 0x03, 0xe0, 0xf0, 0xf0, 0x7e, 0x00, 0xfc, 0x1e, 31 | 0x1f, 0x07, 0xef, 0x03, 0xe0, 0xf0, 0x78, 0x3f, 0xff, 0xf0, 0x3c, 0x1e, 0x07, 0xcf, 0x01, 0xf0, 32 | 0x78, 0x3c, 0x07, 0xff, 0x80, 0xf8, 0x3c, 0x0f, 0xcf, 0x81, 0xf0, 0x3c, 0x1f, 0x00, 0x78, 0x01, 33 | 0xf0, 0x7c, 0x1f, 0x8f, 0x80, 0xf8, 0x3e, 0x0f, 0xc0, 0x00, 0x07, 0xc0, 0xf8, 0x1f, 0x8f, 0xc0, 34 | 0xfc, 0x1f, 0x03, 0xf0, 0x00, 0x3f, 0x81, 0xf0, 0x3f, 0x0f, 0xc0, 0x7c, 0x0f, 0x81, 0xff, 0x87, 35 | 0xfe, 0x03, 0xe0, 0x7f, 0x0f, 0xe0, 0x3e, 0x07, 0xc0, 0x7f, 0xff, 0xf8, 0x0f, 0xc0, 0xfe, 0x0f, 36 | }; -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/spiral-animation/spiral-animation.ino: -------------------------------------------------------------------------------- 1 | /* Spiral Animation 2 | * Displays 8x bitmaps in a seemless loop 3 | * 4 | * Connections: 5 | * WeMos D1 Mini Nokia 5110 Description 6 | * (ESP8266) PCD8544 LCD 7 | * 8 | * D2 (GPIO4) 0 RST Output from ESP to reset display 9 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 10 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 11 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 12 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 13 | * 3V3 5 Vcc 3.3V from ESP to display 14 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 15 | * G 7 Gnd Ground 16 | * 17 | * More info: 18 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 19 | * 20 | * Dependencies: 21 | * https://github.com/adafruit/Adafruit-GFX-Library 22 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 23 | * - This pull request adds ESP8266 support: 24 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 25 | */ 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | // Bitmaps 34 | #include "spiral-1-84x48.h" 35 | #include "spiral-2-84x48.h" 36 | #include "spiral-3-84x48.h" 37 | #include "spiral-4-84x48.h" 38 | #include "spiral-5-84x48.h" 39 | #include "spiral-6-84x48.h" 40 | #include "spiral-7-84x48.h" 41 | #include "spiral-8-84x48.h" 42 | 43 | // Pins 44 | const int8_t RST_PIN = D2; 45 | const int8_t CE_PIN = D1; 46 | const int8_t DC_PIN = D6; 47 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 48 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 49 | const int8_t BL_PIN = D0; 50 | 51 | 52 | // Software SPI with explicit CE pin. 53 | // Adafruit_PCD8544 display = Adafruit_PCD8544(CLK_PIN, DIN_PIN, DC_PIN, CE_PIN, RST_PIN); 54 | 55 | // Software SPI with CE tied to ground. Saves a pin but other pins can't be shared with other hardware. 56 | // Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 57 | 58 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CE is still controlled by any IO pin. 59 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 60 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 61 | 62 | void setup() { 63 | Serial.begin(9600); 64 | Serial.println("\n\nWeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 65 | 66 | // Turn LCD backlight on 67 | pinMode(BL_PIN, OUTPUT); 68 | digitalWrite(BL_PIN, HIGH); 69 | 70 | display.begin(); 71 | display.setContrast(60); // Adjust for your display 72 | Serial.println("Show Adafruit logo bitmap"); 73 | 74 | // Show the Adafruit logo, which is preloaded into the buffer by their library 75 | // display.clearDisplay(); 76 | delay(2000); 77 | } 78 | 79 | void loop() { 80 | display.clearDisplay(); 81 | display.drawBitmap(0, 0, Spiral_1_84x48, 84, 48, 1); 82 | display.display(); 83 | delay(50); 84 | 85 | display.clearDisplay(); 86 | display.drawBitmap(0, 0, Spiral_2_84x48, 84, 48, 1); 87 | display.display(); 88 | delay(50); 89 | 90 | display.clearDisplay(); 91 | display.drawBitmap(0, 0, Spiral_3_84x48, 84, 48, 1); 92 | display.display(); 93 | delay(50); 94 | 95 | display.clearDisplay(); 96 | display.drawBitmap(0, 0, Spiral_4_84x48, 84, 48, 1); 97 | display.display(); 98 | delay(50); 99 | 100 | display.clearDisplay(); 101 | display.drawBitmap(0, 0, Spiral_5_84x48, 84, 48, 1); 102 | display.display(); 103 | delay(50); 104 | 105 | display.clearDisplay(); 106 | display.drawBitmap(0, 0, Spiral_6_84x48, 84, 48, 1); 107 | display.display(); 108 | delay(50); 109 | 110 | display.clearDisplay(); 111 | display.drawBitmap(0, 0, Spiral_7_84x48, 84, 48, 1); 112 | display.display(); 113 | delay(50); 114 | 115 | display.clearDisplay(); 116 | display.drawBitmap(0, 0, Spiral_8_84x48, 84, 48, 1); 117 | display.display(); 118 | delay(50); 119 | } 120 | -------------------------------------------------------------------------------- /examples/05.Displays/PCD8544-Nokia-5110-84x48/wifi-signal-strength/wifi-signal-strength.ino: -------------------------------------------------------------------------------- 1 | /* WiFi Signal Strength 2 | * Shows RSSI of a predefined network with a graph 3 | * 4 | * RSSI is a percentage in the range -120db to 0db. 5 | * The closer to 0 the better. 6 | * 7 | * Connections: 8 | * WeMos D1 Mini Nokia 5110 Description 9 | * (ESP8266) PCD8544 LCD 10 | * 11 | * D2 (GPIO4) 0 RST Output from ESP to reset display 12 | * D1 (GPIO5) 1 CE Output from ESP to chip select/enable display 13 | * D6 (GPIO12) 2 DC Output from display data/command to ESP 14 | * D7 (GPIO13) 3 Din Output from ESP SPI MOSI to display data input 15 | * D5 (GPIO14) 4 Clk Output from ESP SPI clock 16 | * 3V3 5 Vcc 3.3V from ESP to display 17 | * D0 (GPIO16) 6 BL 3.3V to turn backlight on, or PWM 18 | * G 7 Gnd Ground 19 | * 20 | * More info: 21 | * https://github.com/mcauser/WeMos-D1-mini-Nokia-5110-PCD8544 22 | * 23 | * Dependencies: 24 | * https://github.com/adafruit/Adafruit-GFX-Library 25 | * https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library 26 | * - This pull request adds ESP8266 support: 27 | * - https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library/pull/27 28 | */ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // Pins 39 | const int8_t RST_PIN = D2; 40 | const int8_t CE_PIN = D1; 41 | const int8_t DC_PIN = D6; 42 | //const int8_t DIN_PIN = D7; // Uncomment for Software SPI 43 | //const int8_t CLK_PIN = D5; // Uncomment for Software SPI 44 | const int8_t BL_PIN = D0; 45 | 46 | // Graph the RSSI of this WiFi 47 | const char* myssid = "YOUR WIFI SSID"; 48 | const char* mypass = "YOUR WIFI PASSWORD"; 49 | 50 | long rssi; 51 | int8_t graph[83]; 52 | uint8_t i, col, pos = 0; 53 | bool scroll = false; 54 | 55 | // Software SPI with explicit CS pin. 56 | //Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t CE_PIN, int8_t RST_PIN); 57 | 58 | // Software SPI with CS tied to ground. Saves a pin but other pins can't be shared with other hardware. 59 | //Adafruit_PCD8544(int8_t CLK_PIN, int8_t DIN_PIN, int8_t DC_PIN, int8_t RST_PIN); 60 | 61 | // Hardware SPI based on hardware controlled SCK (SCLK) and MOSI (DIN) pins. CS is still controlled by any IO pin. 62 | // NOTE: MISO and SS will be set as an input and output respectively, so be careful sharing those pins! 63 | Adafruit_PCD8544 display = Adafruit_PCD8544(DC_PIN, CE_PIN, RST_PIN); 64 | 65 | void setup(void) { 66 | Serial.begin(9600); 67 | Serial.println("\nESP8266 WiFi Signal Strength Graph"); 68 | Serial.println("WeMos D1 Mini + Nokia 5110 PCD8544 84x48 Monochrome LCD\nUsing Adafruit_PCD8544 and Adafruit_GFX libraries\n"); 69 | 70 | // Set WiFi to station mode and disconnect from an AP if it was previously connected 71 | WiFi.mode(WIFI_STA); 72 | WiFi.disconnect(); 73 | delay(100); 74 | 75 | // Turn LCD backlight on 76 | pinMode(BL_PIN, OUTPUT); 77 | digitalWrite(BL_PIN, HIGH); 78 | 79 | // Configure LCD 80 | display.begin(); 81 | display.setContrast(60); // Adjust for your display 82 | display.setTextSize(1); 83 | display.setTextColor(BLACK); 84 | display.setCursor(0,0); 85 | display.clearDisplay(); 86 | 87 | WiFi.begin(myssid, mypass); 88 | Serial.print("Connecting"); 89 | display.print("Connecting"); 90 | display.display(); 91 | 92 | // Wait for successful connection 93 | while (WiFi.status() != WL_CONNECTED) { 94 | delay(500); 95 | Serial.print("."); 96 | display.print("."); 97 | display.display(); 98 | } 99 | 100 | Serial.print("\nConnected to: "); 101 | Serial.println(myssid); 102 | Serial.print("IP address: "); 103 | Serial.println(WiFi.localIP()); 104 | Serial.println(""); 105 | 106 | display.clearDisplay(); 107 | display.println("Connected"); 108 | display.display(); 109 | delay(1000); 110 | } 111 | 112 | void loop(void) { 113 | rssi = WiFi.RSSI(); // eg. -63 114 | 115 | // Convert to scale -48 to 0 eg. map(rssi, -100, 0, 0, -48); 116 | // I used -100 instead of -120 because <= -95 is unusable 117 | // Negative number so we can draw n pixels from the bottom in black 118 | graph[pos] = (1.0 - (rssi / -100.0)) * -48.0; 119 | 120 | // Draw the RSSI eg. -63db 121 | display.clearDisplay(); 122 | display.printf("%ddb\n",rssi); 123 | 124 | // Draw the graph left to right until 84 columns visible 125 | // After that shuffle the graph to the left and update the right most column 126 | if (!scroll) { 127 | for (i = 0; i <= pos; i++) { 128 | display.drawFastVLine(i, LCDHEIGHT-1, graph[i], BLACK); 129 | } 130 | } 131 | else { 132 | for (i = 0; i < LCDWIDTH; i++) { 133 | col = (i + pos + 1) % LCDWIDTH; 134 | display.drawFastVLine(i, LCDHEIGHT-1, graph[col], BLACK); 135 | } 136 | } 137 | display.display(); 138 | 139 | // After the first pass, scroll the graph to the left 140 | if (pos == 83) { 141 | pos = 0; 142 | scroll = true; 143 | } 144 | else { 145 | pos++; 146 | } 147 | 148 | delay(100); // Adjust this to change graph speed 149 | } 150 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=LOLIN D1 Examples 2 | version=1.0.0 3 | author=WEMOS.CC 4 | maintainer=WEMOS.CC 5 | sentence=Examples for the WEMOS D1 & D1 mini. 6 | paragraph=Examples for the WEMOS D1 & D1 mini. 7 | category=Other 8 | url=https://github.com/wemos/D1_mini_Examples 9 | architectures=* 10 | --------------------------------------------------------------------------------