| ... | ... | @@ -1,0 +1,142 @@ | 
              
                    |  | 1 | +Nodemcu V3 Lua WiFi module integrated ESP8266 + additional 32Mbit FLASH, USB serial port CP2102. | 
              
                    |  | 2 | + | 
              
                    |  | 3 | +{{code language="none" title="dmesg"}} | 
              
                    |  | 4 | +[46271.336289] usb 3-7.2: new full-speed USB device number 14 using xhci_hcd | 
              
                    |  | 5 | +[46271.467461] usb 3-7.2: New USB device found, idVendor=10c4, idProduct=ea60, bcdDevice= 1.00 | 
              
                    |  | 6 | +[46271.467463] usb 3-7.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 | 
              
                    |  | 7 | +[46271.467465] usb 3-7.2: Product: CP2102 USB to UART Bridge Controller | 
              
                    |  | 8 | +[46271.467467] usb 3-7.2: Manufacturer: Silicon Labs | 
              
                    |  | 9 | +[46271.467468] usb 3-7.2: SerialNumber: 0001 | 
              
                    |  | 10 | +[46271.480537] cp210x 3-7.2:1.0: cp210x converter detected | 
              
                    |  | 11 | +[46271.482413] usb 3-7.2: cp210x converter now attached to ttyUSB0 | 
              
                    |  | 12 | +{{/code}} | 
              
                    |  | 13 | + | 
              
                    |  | 14 | +{{code language="ini" title="platformio.ini"}} | 
              
                    |  | 15 | +[env:nodemcuv2] | 
              
                    |  | 16 | +platform = espressif8266 | 
              
                    |  | 17 | +board = nodemcuv2 | 
              
                    |  | 18 | +framework = arduino | 
              
                    |  | 19 | +lib_deps = arduino-libraries/NTPClient@^3.1.0 | 
              
                    |  | 20 | + | 
              
                    |  | 21 | +{{/code}} | 
              
                    |  | 22 | + | 
              
                    |  | 23 | +Blink all GPIO pin and NTP (uses [[https:~~/~~/platformio.org/lib/show/551/NTPClient/>>https://platformio.org/lib/show/551/NTPClient/]]): | 
              
                    |  | 24 | + | 
              
                    |  | 25 | +{{code language="c++" title="main.cpp"}} | 
              
                    |  | 26 | +#include <Arduino.h> | 
              
                    |  | 27 | +#include <ESP8266WiFi.h> | 
              
                    |  | 28 | +#include <WiFiUdp.h> | 
              
                    |  | 29 | +#include <NTPClient.h> | 
              
                    |  | 30 | +const char *ssid     = "<ssid>"; | 
              
                    |  | 31 | +const char *password = "<wpa_password>"; | 
              
                    |  | 32 | + | 
              
                    |  | 33 | +WiFiUDP ntpUDP; | 
              
                    |  | 34 | + | 
              
                    |  | 35 | +NTPClient timeClient(ntpUDP, "ntp-b.nist.gov", 0, 60000); | 
              
                    |  | 36 | + | 
              
                    |  | 37 | + | 
              
                    |  | 38 | +void f2(void (*f)(uint8_t, uint8_t), uint8_t val) { | 
              
                    |  | 39 | + | 
              
                    |  | 40 | +// static const uint8_t D0   = 16; | 
              
                    |  | 41 | +// static const uint8_t D1   = 5; | 
              
                    |  | 42 | +// static const uint8_t D2   = 4; | 
              
                    |  | 43 | +// static const uint8_t D3   = 0; | 
              
                    |  | 44 | +// static const uint8_t D4   = 2; | 
              
                    |  | 45 | +// static const uint8_t D5   = 14; | 
              
                    |  | 46 | +// static const uint8_t D6   = 12; | 
              
                    |  | 47 | +// static const uint8_t D7   = 13; | 
              
                    |  | 48 | +// static const uint8_t D8   = 15; | 
              
                    |  | 49 | +// static const uint8_t D9   = 3; | 
              
                    |  | 50 | +// static const uint8_t D10  = 1; | 
              
                    |  | 51 | + | 
              
                    |  | 52 | + | 
              
                    |  | 53 | +  for (uint8_t i = 0; i <= 5; i++) | 
              
                    |  | 54 | +  (*f)(i, val); | 
              
                    |  | 55 | +  for (uint8_t i = 12; i <= 16; i++) | 
              
                    |  | 56 | +  (*f)(i, val); | 
              
                    |  | 57 | +} | 
              
                    |  | 58 | + | 
              
                    |  | 59 | +void setup() { | 
              
                    |  | 60 | +  f2(&pinMode, OUTPUT); | 
              
                    |  | 61 | + | 
              
                    |  | 62 | +  // Serial.begin(115200); | 
              
                    |  | 63 | + | 
              
                    |  | 64 | +  WiFi.begin(ssid, password); | 
              
                    |  | 65 | + | 
              
                    |  | 66 | +  while ( WiFi.status() != WL_CONNECTED ) { | 
              
                    |  | 67 | +    delay ( 500 ); | 
              
                    |  | 68 | +    // Serial.print ( "." ); | 
              
                    |  | 69 | +  } | 
              
                    |  | 70 | + | 
              
                    |  | 71 | + | 
              
                    |  | 72 | +  timeClient.begin(); | 
              
                    |  | 73 | +} | 
              
                    |  | 74 | + | 
              
                    |  | 75 | + | 
              
                    |  | 76 | +unsigned long t; | 
              
                    |  | 77 | + | 
              
                    |  | 78 | + | 
              
                    |  | 79 | +void f1(uint8_t hl) { | 
              
                    |  | 80 | +  timeClient.update(); | 
              
                    |  | 81 | +  unsigned long t1; | 
              
                    |  | 82 | +  for (; (t1 = timeClient.getEpochTime()) == t; delay(1)); | 
              
                    |  | 83 | + | 
              
                    |  | 84 | +  t = t1; | 
              
                    |  | 85 | +  // Serial.println(timeClient.getFormattedTime()); | 
              
                    |  | 86 | + | 
              
                    |  | 87 | +  f2(&digitalWrite, OUTPUT); | 
              
                    |  | 88 | + | 
              
                    |  | 89 | +} | 
              
                    |  | 90 | + | 
              
                    |  | 91 | +void loop() { | 
              
                    |  | 92 | +  f1(HIGH); | 
              
                    |  | 93 | +  f1(LOW); | 
              
                    |  | 94 | +} | 
              
                    |  | 95 | +{{/code}} | 
              
                    |  | 96 | + | 
              
                    |  | 97 | +{{code language="none" title="Upload log"}} | 
              
                    |  | 98 | +Configuring upload protocol... | 
              
                    |  | 99 | +AVAILABLE: espota, esptool | 
              
                    |  | 100 | +CURRENT: upload_protocol = esptool | 
              
                    |  | 101 | +Looking for upload port... | 
              
                    |  | 102 | +Auto-detected: /dev/ttyUSB0 | 
              
                    |  | 103 | +Uploading .pio/build/nodemcuv2/firmware.bin | 
              
                    |  | 104 | +esptool.py v2.8 | 
              
                    |  | 105 | +Serial port /dev/ttyUSB0 | 
              
                    |  | 106 | +Connecting.... | 
              
                    |  | 107 | +Chip is ESP8266EX | 
              
                    |  | 108 | +Features: WiFi | 
              
                    |  | 109 | +Crystal is 26MHz | 
              
                    |  | 110 | +MAC: AA:BB:CC:DD:EE:FF | 
              
                    |  | 111 | +Uploading stub... | 
              
                    |  | 112 | +Running stub... | 
              
                    |  | 113 | +Stub running... | 
              
                    |  | 114 | +Configuring flash size... | 
              
                    |  | 115 | +Auto-detected Flash size: 4MB | 
              
                    |  | 116 | +Compressed 269888 bytes to 199316... | 
              
                    |  | 117 | + | 
              
                    |  | 118 | +Writing at 0x00000000... (7 %) | 
              
                    |  | 119 | +Writing at 0x00004000... (15 %) | 
              
                    |  | 120 | +Writing at 0x00008000... (23 %) | 
              
                    |  | 121 | +Writing at 0x0000c000... (30 %) | 
              
                    |  | 122 | +Writing at 0x00010000... (38 %) | 
              
                    |  | 123 | +Writing at 0x00014000... (46 %) | 
              
                    |  | 124 | +Writing at 0x00018000... (53 %) | 
              
                    |  | 125 | +Writing at 0x0001c000... (61 %) | 
              
                    |  | 126 | +Writing at 0x00020000... (69 %) | 
              
                    |  | 127 | +Writing at 0x00024000... (76 %) | 
              
                    |  | 128 | +Writing at 0x00028000... (84 %) | 
              
                    |  | 129 | +Writing at 0x0002c000... (92 %) | 
              
                    |  | 130 | +Writing at 0x00030000... (100 %) | 
              
                    |  | 131 | +Wrote 269888 bytes (199316 compressed) at 0x00000000 in 17.6 seconds (effective 122.6 kbit/s)... | 
              
                    |  | 132 | +Hash of data verified. | 
              
                    |  | 133 | + | 
              
                    |  | 134 | +Leaving... | 
              
                    |  | 135 | +Hard resetting via RTS pin... | 
              
                    |  | 136 | +{{/code}} | 
              
                    |  | 137 | + | 
              
                    |  | 138 | +{{gallery}} | 
              
                    |  | 139 | +image:front.jpg | 
              
                    |  | 140 | + | 
              
                    |  | 141 | +image:back.jpg | 
              
                    |  | 142 | +{{/gallery}} |