├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── examples ├── Blynk.Edgent │ ├── Edgent_ESP32 │ │ ├── BlynkEdgent.h │ │ ├── BlynkState.h │ │ ├── ConfigMode.h │ │ ├── ConfigStore.h │ │ ├── Console.h │ │ ├── Edgent_ESP32.ino │ │ ├── Indicator.h │ │ ├── OTA.h │ │ ├── ResetButton.h │ │ └── Settings.h │ ├── Edgent_ESP8266 │ │ ├── BlynkEdgent.h │ │ ├── BlynkState.h │ │ ├── ConfigMode.h │ │ ├── ConfigStore.h │ │ ├── Console.h │ │ ├── Edgent_ESP8266.ino │ │ ├── Indicator.h │ │ ├── OTA.h │ │ ├── ResetButton.h │ │ └── Settings.h │ ├── Edgent_MKR1010 │ │ └── Edgent_MKR1010.ino │ ├── Edgent_NCP │ │ └── Edgent_NCP.ino │ └── Edgent_Wio_Terminal │ │ ├── BlynkEdgent.h │ │ ├── BlynkState.h │ │ ├── ConfigMode.h │ │ ├── ConfigStore.h │ │ ├── Console.h │ │ ├── Edgent_Wio_Terminal.ino │ │ ├── Indicator.h │ │ ├── OTA.h │ │ ├── ResetButton.h │ │ └── Settings.h ├── Boards_ArduinoClient │ ├── Arduino_Ethernet │ │ └── Arduino_Ethernet.ino │ ├── Arduino_MKR1400_GSM_ETH │ │ └── Arduino_MKR1400_GSM_ETH.ino │ ├── Arduino_MKR1400_GSM_ETH_SSL │ │ └── Arduino_MKR1400_GSM_ETH_SSL.ino │ └── ESP8266_ESP32 │ │ └── ESP8266_ESP32.ino ├── Boards_Ethernet │ ├── Arduino_Ethernet │ │ └── Arduino_Ethernet.ino │ ├── Arduino_Ethernet_Manual │ │ └── Arduino_Ethernet_Manual.ino │ ├── Arduino_MKR_ETH │ │ └── Arduino_MKR_ETH.ino │ ├── Arduino_MKR_ETH_SSL │ │ └── Arduino_MKR_ETH_SSL.ino │ └── ENC28J60 │ │ └── ENC28J60.ino ├── Boards_GSM │ ├── Arduino_MKRGSM │ │ └── Arduino_MKRGSM.ino │ ├── Arduino_MKRNB │ │ └── Arduino_MKRNB.ino │ ├── TinyGSM_MKR1400 │ │ └── TinyGSM_MKR1400.ino │ └── TinyGSM_SIM800_SIM900 │ │ └── TinyGSM_SIM800_SIM900.ino ├── Boards_WiFi │ ├── Adafruit_Feather_M0_WiFi │ │ └── Adafruit_Feather_M0_WiFi.ino │ ├── Arduino_MKR1000 │ │ └── Arduino_MKR1000.ino │ ├── Arduino_MKR1010 │ │ └── Arduino_MKR1010.ino │ ├── Arduino_WiFi_Shield │ │ └── Arduino_WiFi_Shield.ino │ ├── Arduino_WiFi_Shield_101 │ │ └── Arduino_WiFi_Shield_101.ino │ ├── Arduino_Yun │ │ └── Arduino_Yun.ino │ ├── Arduino_org_UNO_WiFi │ │ └── Arduino_org_UNO_WiFi.ino │ ├── ESP32_WiFi │ │ └── ESP32_WiFi.ino │ ├── ESP32_WiFi_SSL │ │ └── ESP32_WiFi_SSL.ino │ ├── ESP8266_Shield │ │ └── ESP8266_Shield.ino │ ├── ESP8266_Standalone │ │ └── ESP8266_Standalone.ino │ ├── ESP8266_Standalone_Manual_IP │ │ └── ESP8266_Standalone_Manual_IP.ino │ ├── ESP8266_Standalone_SSL │ │ └── ESP8266_Standalone_SSL.ino │ ├── Fishino │ │ └── Fishino.ino │ ├── LinkItONE │ │ └── LinkItONE.ino │ ├── RN_XV_WiFly │ │ └── RN_XV_WiFly.ino │ ├── RedBear_Duo_WiFi │ │ └── RedBear_Duo_WiFi.ino │ ├── Sparkfun_Blynk_Board │ │ └── Sparkfun_Blynk_Board.ino │ ├── TheAirBoard_WiFly │ │ └── TheAirBoard_WiFly.ino │ ├── TinyDuino_WiFi │ │ └── TinyDuino_WiFi.ino │ ├── WildFire_V3 │ │ └── WildFire_V3.ino │ ├── WildFire_V4 │ │ └── WildFire_V4.ino │ ├── Wio_Terminal │ │ └── Wio_Terminal.ino │ ├── WizFi250 │ │ └── WizFi250.ino │ └── WizFi310 │ │ └── WizFi310.ino ├── Boards_With_HTTP_API │ ├── Arduino_Ethernet │ │ └── Arduino_Ethernet.ino │ ├── Arduino_GSM │ │ └── Arduino_GSM.ino │ ├── ESP8266_ESP32 │ │ └── ESP8266_ESP32.ino │ └── SIM800_SIM900 │ │ └── SIM800_SIM900.ino ├── GettingStarted │ ├── BlynkBlink │ │ └── BlynkBlink.ino │ ├── GetData │ │ └── GetData.ino │ ├── PushData │ │ └── PushData.ino │ ├── Servo │ │ └── Servo.ino │ ├── VirtualPinRead │ │ └── VirtualPinRead.ino │ └── VirtualPinWrite │ │ └── VirtualPinWrite.ino ├── More │ ├── DHT11 │ │ └── DHT11.ino │ ├── FormatString │ │ └── FormatString.ino │ ├── HandleDisconnect │ │ └── HandleDisconnect.ino │ ├── NeoPixel │ │ └── NeoPixel.ino │ ├── PrintAllVirtual │ │ └── PrintAllVirtual.ino │ ├── RTC │ │ └── RTC.ino │ ├── RTC_Advanced │ │ └── RTC_Advanced.ino │ ├── ServerAsDataStorage │ │ ├── ServerAsDataStorage_MultiValue │ │ │ └── ServerAsDataStorage_MultiValue.ino │ │ └── ServerAsDataStorage_SingleValue │ │ │ └── ServerAsDataStorage_SingleValue.ino │ ├── SetProperty │ │ ├── SetProperty_MultiValue │ │ │ └── SetProperty_MultiValue.ino │ │ └── SetProperty_SingleValue │ │ │ └── SetProperty_SingleValue.ino │ ├── Stroboscope │ │ └── Stroboscope.ino │ ├── Sync │ │ ├── ButtonInterrupt │ │ │ └── ButtonInterrupt.ino │ │ ├── ButtonPoll │ │ │ └── ButtonPoll.ino │ │ ├── HardwareSyncStateFromApp │ │ │ └── HardwareSyncStateFromApp.ino │ │ └── SyncPhysicalButton │ │ │ └── SyncPhysicalButton.ino │ └── TimeAndLocation │ │ └── TimeAndLocation.ino └── Widgets │ ├── Joystick │ └── Joystick.ino │ ├── LCD │ ├── LCD_AdvancedMode │ │ └── LCD_AdvancedMode.ino │ └── LCD_SimpleMode │ │ └── LCD_SimpleMode.ino │ ├── LED │ ├── LED_Blink │ │ └── LED_Blink.ino │ ├── LED_Color │ │ └── LED_Color.ino │ ├── LED_Fade │ │ └── LED_Fade.ino │ └── LED_StatusOfButton │ │ └── LED_StatusOfButton.ino │ ├── Map │ └── Map.ino │ ├── Menu │ └── Menu.ino │ ├── MusicPlayer │ └── MusicPlayer.ino │ ├── Terminal │ └── Terminal.ino │ └── TimeInput │ ├── AdvancedTimeInput │ └── AdvancedTimeInput.ino │ ├── SimpleTimeInput │ └── SimpleTimeInput.ino │ └── UpdateTimeInputState │ └── UpdateTimeInputState.ino ├── keywords.txt ├── library.json ├── library.properties ├── linux ├── BlynkApiLinux.h ├── BlynkApiWiringPi.h ├── BlynkOptionsParser.h ├── BlynkSocket.h ├── Makefile ├── README.md ├── build.sh └── main.cpp ├── scripts ├── README.md ├── blynk-ser.bat ├── blynk-ser.sh ├── blynk_ctrl.py ├── certs │ └── server.crt └── com2tcp.bin ├── src ├── Adapters │ ├── BlynkArduinoClient.h │ ├── BlynkArduinoGSM.h │ ├── BlynkArduinoNB.h │ ├── BlynkBLEPeripheralSerial.h │ ├── BlynkCC3000.h │ ├── BlynkEthernet.h │ ├── BlynkGsmClient.h │ ├── BlynkParticle.h │ ├── BlynkParticleBearSSL.h │ ├── BlynkSerial.h │ ├── BlynkWiFiCommon.h │ ├── BlynkWiFly.h │ ├── BlynkWildFire.h │ └── BlynkWizFi250.h ├── Blynk.h ├── Blynk │ ├── BlynkApi.h │ ├── BlynkApiNCP.h │ ├── BlynkConfig.h │ ├── BlynkConsole.h │ ├── BlynkDateTime.h │ ├── BlynkDebug.h │ ├── BlynkDetectDevice.h │ ├── BlynkEveryN.h │ ├── BlynkHandlers.h │ ├── BlynkHelpers.h │ ├── BlynkParam.h │ ├── BlynkProtocol.h │ ├── BlynkProtocolDefs.h │ ├── BlynkTemplates.h │ ├── BlynkTimer.h │ ├── BlynkUtility.h │ └── BlynkWidgetBase.h ├── BlynkApiArduino.h ├── BlynkApiMbed.h ├── BlynkApiParticle.h ├── BlynkEdgentNCP.h ├── BlynkMultiClient.h ├── BlynkSimpleArduinoNanoBLE.h ├── BlynkSimpleBLEPeripheral.h ├── BlynkSimpleCC3000.h ├── BlynkSimpleCurieBLE.h ├── BlynkSimpleEnergiaEthernet.h ├── BlynkSimpleEnergiaWiFi.h ├── BlynkSimpleEsp32.h ├── BlynkSimpleEsp32_BLE.h ├── BlynkSimpleEsp32_BT.h ├── BlynkSimpleEsp32_NimBLE.h ├── BlynkSimpleEsp32_SSL.h ├── BlynkSimpleEsp8266.h ├── BlynkSimpleEsp8266_SSL.h ├── BlynkSimpleEthernet.h ├── BlynkSimpleEthernetENC.h ├── BlynkSimpleEthernetSSL.h ├── BlynkSimpleFishino.h ├── BlynkSimpleIntelEdisonWiFi.h ├── BlynkSimpleLinkItONE.h ├── BlynkSimpleMKR1000.h ├── BlynkSimpleMKRGSM.h ├── BlynkSimpleMKRNB.h ├── BlynkSimpleParticle.h ├── BlynkSimpleParticleSSL.h ├── BlynkSimpleRFduinoBLE.h ├── BlynkSimpleRedBearLab_BLE_Nano.h ├── BlynkSimpleRedBear_Duo.h ├── BlynkSimpleRedBear_Duo_BLE.h ├── BlynkSimpleSerialBLE.h ├── BlynkSimpleShieldEsp8266.h ├── BlynkSimpleSimbleeBLE.h ├── BlynkSimpleStream.h ├── BlynkSimpleTinyDuino.h ├── BlynkSimpleTinyGSM.h ├── BlynkSimpleUIPEthernet.h ├── BlynkSimpleWiFiLink.h ├── BlynkSimpleWiFiNINA.h ├── BlynkSimpleWiFiShield101.h ├── BlynkSimpleWiFiShield101_SSL.h ├── BlynkSimpleWiFly.h ├── BlynkSimpleWifi.h ├── BlynkSimpleWildFire.h ├── BlynkSimpleWioTerminal.h ├── BlynkSimpleWioTerminal_BLE.h ├── BlynkSimpleWioTerminal_SSL.h ├── BlynkSimpleWizFi250.h ├── BlynkSimpleWizFi310.h ├── BlynkSimpleYun.h ├── BlynkWidgets.h ├── WidgetLCD.h ├── WidgetLED.h ├── WidgetMap.h ├── WidgetRTC.h ├── WidgetTerminal.h ├── WidgetTimeInput.h ├── certs │ └── letsencrypt_pem.h └── utility │ ├── BlynkDateTime.h │ ├── BlynkDebug.cpp │ ├── BlynkFifo.h │ ├── BlynkHandlers.cpp │ ├── BlynkHelpers.cpp │ ├── BlynkNcpOtaImpl.h │ ├── BlynkStreamMulti.h │ ├── BlynkStreamNull.h │ ├── BlynkTimeUtils.cpp │ ├── BlynkTimer.cpp │ ├── BlynkUtility.h │ └── utility.cpp └── tests ├── BlynkBuildTest └── BlynkBuildTest.ino ├── BlynkFootprintTest └── BlynkFootprintTest.ino ├── GenerateJSON └── GenerateJSON.ino ├── SerialXconnect └── SerialXconnect.ino ├── loopback.py ├── pseudo-library.py ├── pseudo-server-ar-mt.py ├── pseudo-server-ar-select.py └── pseudo-server-dw-mt.py /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | 3 | if(ESP_PLATFORM) 4 | # Build Blynk as an ESP-IDF component 5 | file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.c") 6 | 7 | idf_component_register(SRCS ${SOURCES} 8 | INCLUDE_DIRS "src" 9 | REQUIRES arduino) 10 | return() 11 | endif() 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2015 Volodymyr Shymanskyy 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: docs format-examples cloc travis-build build-examples build-boards build-tools update-travis update-ver spaces clean check 2 | 3 | export ARDUINO_IDE_PATH=/data2/arduino-1.8.5 4 | export ENERGIA_IDE_PATH=/data2/energia-1.6.10E18 5 | 6 | 7 | docs: 8 | doxygen extras/doxygen.config 9 | 10 | format-examples: 11 | find examples tests -name '*.ino' -exec astyle --options=extras/formatter.conf {} \; 12 | 13 | cloc: 14 | cloc ./ 15 | 16 | build-examples: 17 | python extras/build-examples.py 18 | 19 | build-boards: 20 | python extras/build-boards.py 21 | 22 | build-tools: 23 | cd ./extras/ide-tools/; ./build.sh BlynkUpdater 24 | cd ./extras/ide-tools/; ./build.sh BlynkUsbScript 25 | 26 | spaces: 27 | find ./src ./linux -name '*.cpp' -o -name '*.h' -exec sed -i 's/\t/ /g' {} \; 28 | find ./examples ./tests -name '*.ino' -o -name '*.h' -exec sed -i 's/\t/ /g' {} \; 29 | 30 | update-travis: 31 | python extras/travis-generate.py > .travis.yml.new 32 | meld .travis.yml .travis.yml.new 33 | 34 | update-ver: 35 | sed -i 's/"version": "[0-9\.]*"/"version": "$(VER)"/g' library.json 36 | sed -i 's/version=[0-9\.]*/version=$(VER)/g' library.properties 37 | sed -i 's/BLYNK_VERSION "[0-9\.]*"/BLYNK_VERSION "$(VER)"/g' src/Blynk/BlynkConfig.h 38 | 39 | clean: 40 | -rm .travis.yml.new 41 | -find . -type f -name "*.orig" -exec rm -f {} \; 42 | 43 | check: spaces format-examples 44 | @echo '******************************************' 45 | @echo ' Files with no "YourAuthToken":' 46 | @echo '******************************************' 47 | @find ./examples -name "*.ino" -exec grep -L "YourAuthToken" {} \; 48 | 49 | travis-build: 50 | ifdef PLATFORMIO_CI_SRC 51 | -rm -rf ./linux 52 | ifdef PLATFORMIO_CI_EXTRA_ARGS 53 | platformio ci --lib="." $(PLATFORMIO_CI_EXTRA_ARGS) 54 | else 55 | platformio ci --lib="." --board=uno 56 | endif 57 | endif 58 | ifdef LINUX_SRC 59 | make -C $(LINUX_SRC) 60 | endif 61 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP32/BlynkState.h: -------------------------------------------------------------------------------- 1 | 2 | enum State { 3 | MODE_WAIT_CONFIG, 4 | MODE_CONFIGURING, 5 | MODE_CONNECTING_NET, 6 | MODE_CONNECTING_CLOUD, 7 | MODE_RUNNING, 8 | MODE_OTA_UPGRADE, 9 | MODE_SWITCH_TO_STA, 10 | MODE_RESET_CONFIG, 11 | MODE_ERROR, 12 | 13 | MODE_MAX_VALUE 14 | }; 15 | 16 | #if defined(APP_DEBUG) 17 | const char* StateStr[MODE_MAX_VALUE+1] = { 18 | "WAIT_CONFIG", 19 | "CONFIGURING", 20 | "CONNECTING_NET", 21 | "CONNECTING_CLOUD", 22 | "RUNNING", 23 | "OTA_UPGRADE", 24 | "SWITCH_TO_STA", 25 | "RESET_CONFIG", 26 | "ERROR", 27 | 28 | "INIT" 29 | }; 30 | #endif 31 | 32 | namespace BlynkState 33 | { 34 | volatile State state = MODE_MAX_VALUE; 35 | 36 | State get() { return state; } 37 | bool is (State m) { return (state == m); } 38 | void set(State m); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP32/Edgent_ESP32.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | ************************************************************* 15 | Blynk.Edgent implements: 16 | - Blynk.Inject - Dynamic WiFi credentials provisioning 17 | - Blynk.Air - Over The Air firmware updates 18 | - Device state indication using a physical LED 19 | - Credentials reset using a physical Button 20 | *************************************************************/ 21 | 22 | /* Fill in information from your Blynk Template here */ 23 | /* Read more: https://bit.ly/BlynkInject */ 24 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 25 | //#define BLYNK_TEMPLATE_NAME "Device" 26 | 27 | #define BLYNK_FIRMWARE_VERSION "0.1.0" 28 | 29 | #define BLYNK_PRINT Serial 30 | //#define BLYNK_DEBUG 31 | 32 | #define APP_DEBUG 33 | 34 | // Uncomment your board, or configure a custom board in Settings.h 35 | //#define USE_ESP32_DEV_MODULE 36 | //#define USE_ESP32C3_DEV_MODULE 37 | //#define USE_ESP32S2_DEV_KIT 38 | //#define USE_WROVER_BOARD 39 | //#define USE_TTGO_T7 40 | //#define USE_TTGO_T_OI 41 | 42 | #include "BlynkEdgent.h" 43 | 44 | void setup() 45 | { 46 | Serial.begin(115200); 47 | delay(100); 48 | 49 | BlynkEdgent.begin(); 50 | } 51 | 52 | void loop() { 53 | BlynkEdgent.run(); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP32/OTA.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | String overTheAirURL; 7 | 8 | extern BlynkTimer edgentTimer; 9 | 10 | BLYNK_WRITE(InternalPinOTA) { 11 | overTheAirURL = param.asString(); 12 | 13 | edgentTimer.setTimeout(2000L, [](){ 14 | // Start OTA 15 | Blynk.logEvent("sys_ota", "OTA started"); 16 | 17 | // Disconnect, not to interfere with OTA process 18 | Blynk.disconnect(); 19 | 20 | BlynkState::set(MODE_OTA_UPGRADE); 21 | }); 22 | } 23 | 24 | void enterOTA() { 25 | BlynkState::set(MODE_OTA_UPGRADE); 26 | 27 | DEBUG_PRINT(String("Firmware update URL: ") + overTheAirURL); 28 | 29 | HTTPClient http; 30 | http.begin(overTheAirURL); 31 | 32 | const char* headerkeys[] = { "x-MD5" }; 33 | http.collectHeaders(headerkeys, sizeof(headerkeys)/sizeof(char*)); 34 | 35 | int httpCode = http.GET(); 36 | if (httpCode != HTTP_CODE_OK) { 37 | DEBUG_PRINT("HTTP response should be 200"); 38 | BlynkState::set(MODE_ERROR); 39 | return; 40 | } 41 | int contentLength = http.getSize(); 42 | if (contentLength <= 0) { 43 | DEBUG_PRINT("Content-Length not defined"); 44 | BlynkState::set(MODE_ERROR); 45 | return; 46 | } 47 | 48 | bool canBegin = Update.begin(contentLength); 49 | if (!canBegin) { 50 | DEBUG_PRINT("Not enough space to begin OTA"); 51 | BlynkState::set(MODE_ERROR); 52 | return; 53 | } 54 | 55 | if (http.hasHeader("x-MD5")) { 56 | String md5 = http.header("x-MD5"); 57 | if (md5.length() == 32) { 58 | md5.toLowerCase(); 59 | DEBUG_PRINT("Expected MD5: " + md5); 60 | Update.setMD5(md5.c_str()); 61 | } 62 | } 63 | 64 | #ifdef BLYNK_FS 65 | BLYNK_FS.end(); 66 | #endif 67 | 68 | Client& client = http.getStream(); 69 | int written = Update.writeStream(client); 70 | if (written != contentLength) { 71 | DEBUG_PRINT(String("OTA written ") + written + " / " + contentLength + " bytes"); 72 | BlynkState::set(MODE_ERROR); 73 | return; 74 | } 75 | 76 | if (!Update.end()) { 77 | DEBUG_PRINT("Error #" + String(Update.getError())); 78 | BlynkState::set(MODE_ERROR); 79 | return; 80 | } 81 | 82 | if (!Update.isFinished()) { 83 | DEBUG_PRINT("Update failed."); 84 | BlynkState::set(MODE_ERROR); 85 | return; 86 | } 87 | 88 | DEBUG_PRINT("=== Update successfully completed. Rebooting."); 89 | restartMCU(); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP32/ResetButton.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef BOARD_BUTTON_PIN 3 | 4 | volatile bool g_buttonPressed = false; 5 | volatile uint32_t g_buttonPressTime = -1; 6 | 7 | void button_action(void) 8 | { 9 | BlynkState::set(MODE_RESET_CONFIG); 10 | } 11 | 12 | void button_change(void) 13 | { 14 | #if BOARD_BUTTON_ACTIVE_LOW 15 | bool buttonState = !digitalRead(BOARD_BUTTON_PIN); 16 | #else 17 | bool buttonState = digitalRead(BOARD_BUTTON_PIN); 18 | #endif 19 | 20 | if (buttonState && !g_buttonPressed) { 21 | g_buttonPressTime = millis(); 22 | g_buttonPressed = true; 23 | DEBUG_PRINT("Hold the button for 10 seconds to reset configuration..."); 24 | } else if (!buttonState && g_buttonPressed) { 25 | g_buttonPressed = false; 26 | uint32_t buttonHoldTime = millis() - g_buttonPressTime; 27 | if (buttonHoldTime >= BUTTON_HOLD_TIME_ACTION) { 28 | button_action(); 29 | } else if (buttonHoldTime >= BUTTON_PRESS_TIME_ACTION) { 30 | // User action 31 | } 32 | g_buttonPressTime = -1; 33 | } 34 | } 35 | 36 | void button_init() 37 | { 38 | #if BOARD_BUTTON_ACTIVE_LOW 39 | pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP); 40 | #else 41 | pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); 42 | #endif 43 | attachInterrupt(BOARD_BUTTON_PIN, button_change, CHANGE); 44 | } 45 | 46 | #else 47 | 48 | #define g_buttonPressed false 49 | #define g_buttonPressTime 0 50 | 51 | void button_init() {} 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP8266/BlynkState.h: -------------------------------------------------------------------------------- 1 | 2 | enum State { 3 | MODE_WAIT_CONFIG, 4 | MODE_CONFIGURING, 5 | MODE_CONNECTING_NET, 6 | MODE_CONNECTING_CLOUD, 7 | MODE_RUNNING, 8 | MODE_OTA_UPGRADE, 9 | MODE_SWITCH_TO_STA, 10 | MODE_RESET_CONFIG, 11 | MODE_ERROR, 12 | 13 | MODE_MAX_VALUE 14 | }; 15 | 16 | #if defined(APP_DEBUG) 17 | const char* StateStr[MODE_MAX_VALUE+1] = { 18 | "WAIT_CONFIG", 19 | "CONFIGURING", 20 | "CONNECTING_NET", 21 | "CONNECTING_CLOUD", 22 | "RUNNING", 23 | "OTA_UPGRADE", 24 | "SWITCH_TO_STA", 25 | "RESET_CONFIG", 26 | "ERROR", 27 | 28 | "INIT" 29 | }; 30 | #endif 31 | 32 | namespace BlynkState 33 | { 34 | volatile State state = MODE_MAX_VALUE; 35 | 36 | State get() { return state; } 37 | bool is (State m) { return (state == m); } 38 | void set(State m); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP8266/Edgent_ESP8266.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | ************************************************************* 15 | Blynk.Edgent implements: 16 | - Blynk.Inject - Dynamic WiFi credentials provisioning 17 | - Blynk.Air - Over The Air firmware updates 18 | - Device state indication using a physical LED 19 | - Credentials reset using a physical Button 20 | *************************************************************/ 21 | 22 | /* Fill in information from your Blynk Template here */ 23 | /* Read more: https://bit.ly/BlynkInject */ 24 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 25 | //#define BLYNK_TEMPLATE_NAME "Device" 26 | 27 | #define BLYNK_FIRMWARE_VERSION "0.1.0" 28 | 29 | #define BLYNK_PRINT Serial 30 | //#define BLYNK_DEBUG 31 | 32 | #define APP_DEBUG 33 | 34 | // Uncomment your board, or configure a custom board in Settings.h 35 | //#define USE_SPARKFUN_BLYNK_BOARD 36 | //#define USE_NODE_MCU_BOARD 37 | //#define USE_WITTY_CLOUD_BOARD 38 | //#define USE_WEMOS_D1_MINI 39 | 40 | #include "BlynkEdgent.h" 41 | 42 | void setup() 43 | { 44 | Serial.begin(115200); 45 | delay(100); 46 | 47 | BlynkEdgent.begin(); 48 | } 49 | 50 | void loop() { 51 | BlynkEdgent.run(); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_ESP8266/ResetButton.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef BOARD_BUTTON_PIN 3 | 4 | volatile bool g_buttonPressed = false; 5 | volatile uint32_t g_buttonPressTime = -1; 6 | 7 | void button_action(void) 8 | { 9 | BlynkState::set(MODE_RESET_CONFIG); 10 | } 11 | 12 | IRAM_ATTR 13 | void button_change(void) 14 | { 15 | #if BOARD_BUTTON_ACTIVE_LOW 16 | bool buttonState = !digitalRead(BOARD_BUTTON_PIN); 17 | #else 18 | bool buttonState = digitalRead(BOARD_BUTTON_PIN); 19 | #endif 20 | 21 | if (buttonState && !g_buttonPressed) { 22 | g_buttonPressTime = millis(); 23 | g_buttonPressed = true; 24 | DEBUG_PRINT("Hold the button for 10 seconds to reset configuration..."); 25 | } else if (!buttonState && g_buttonPressed) { 26 | g_buttonPressed = false; 27 | uint32_t buttonHoldTime = millis() - g_buttonPressTime; 28 | if (buttonHoldTime >= BUTTON_HOLD_TIME_ACTION) { 29 | button_action(); 30 | } else if (buttonHoldTime >= BUTTON_PRESS_TIME_ACTION) { 31 | // User action 32 | } 33 | g_buttonPressTime = -1; 34 | } 35 | } 36 | 37 | void button_init() 38 | { 39 | #if BOARD_BUTTON_ACTIVE_LOW 40 | pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP); 41 | #else 42 | pinMode(BOARD_BUTTON_PIN, INPUT); 43 | #endif 44 | attachInterrupt(BOARD_BUTTON_PIN, button_change, CHANGE); 45 | } 46 | 47 | #else 48 | 49 | #define g_buttonPressed false 50 | #define g_buttonPressTime 0 51 | 52 | void button_init() {} 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_MKR1010/Edgent_MKR1010.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Arduino 33 IoT and Arduino MKR1010 are no longer supported by Blynk.Edgent. 3 | * Blynk now offers a better solution for Dual-MCU boards. Please use Blynk.NCP: 4 | * https://github.com/blynkkk/BlynkNcpExample 5 | * 6 | */ 7 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_Wio_Terminal/BlynkState.h: -------------------------------------------------------------------------------- 1 | 2 | enum State { 3 | MODE_WAIT_CONFIG, 4 | MODE_CONFIGURING, 5 | MODE_CONNECTING_NET, 6 | MODE_CONNECTING_CLOUD, 7 | MODE_RUNNING, 8 | MODE_OTA_UPGRADE, 9 | MODE_SWITCH_TO_STA, 10 | MODE_RESET_CONFIG, 11 | MODE_ERROR, 12 | 13 | MODE_MAX_VALUE 14 | }; 15 | 16 | #if defined(APP_DEBUG) 17 | const char* StateStr[MODE_MAX_VALUE+1] = { 18 | "WAIT_CONFIG", 19 | "CONFIGURING", 20 | "CONNECTING_NET", 21 | "CONNECTING_CLOUD", 22 | "RUNNING", 23 | "OTA_UPGRADE", 24 | "SWITCH_TO_STA", 25 | "RESET_CONFIG", 26 | "ERROR", 27 | 28 | "INIT" 29 | }; 30 | #endif 31 | 32 | namespace BlynkState 33 | { 34 | volatile State state = MODE_MAX_VALUE; 35 | 36 | State get() { return state; } 37 | bool is (State m) { return (state == m); } 38 | void set(State m); 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_Wio_Terminal/Console.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BlynkConsole edgentConsole; 5 | 6 | void console_init() 7 | { 8 | #ifdef BLYNK_PRINT 9 | edgentConsole.begin(BLYNK_PRINT); 10 | #endif 11 | 12 | edgentConsole.print("\n>"); 13 | 14 | edgentConsole.addCommand("reboot", []() { 15 | edgentConsole.print(R"json({"status":"OK","msg":"rebooting wifi module"})json" "\n"); 16 | delay(100); 17 | restartMCU(); 18 | }); 19 | 20 | edgentConsole.addCommand("config", [](int argc, const char** argv) { 21 | if (argc < 1 || 0 == strcmp(argv[0], "start")) { 22 | BlynkState::set(MODE_WAIT_CONFIG); 23 | } else if (0 == strcmp(argv[0], "erase")) { 24 | BlynkState::set(MODE_RESET_CONFIG); 25 | } 26 | }); 27 | 28 | edgentConsole.addCommand("devinfo", []() { 29 | edgentConsole.printf( 30 | R"json({"name":"%s","board":"%s","tmpl_id":"%s","fw_type":"%s","fw_ver":"%s"})json" "\n", 31 | getWiFiName().c_str(), 32 | BLYNK_TEMPLATE_NAME, 33 | BLYNK_TEMPLATE_ID, 34 | BLYNK_FIRMWARE_TYPE, 35 | BLYNK_FIRMWARE_VERSION 36 | ); 37 | }); 38 | 39 | edgentConsole.addCommand("connect", [](int argc, const char** argv) { 40 | if (argc < 2) { 41 | edgentConsole.print(R"json({"status":"error","msg":"invalid arguments. expected: "})json" "\n"); 42 | return; 43 | } 44 | String auth = argv[0]; 45 | String ssid = argv[1]; 46 | String pass = (argc >= 3) ? argv[2] : ""; 47 | 48 | if (auth.length() != 32) { 49 | edgentConsole.print(R"json({"status":"error","msg":"invalid token size"})json" "\n"); 50 | return; 51 | } 52 | 53 | edgentConsole.print(R"json({"status":"OK","msg":"trying to connect..."})json" "\n"); 54 | 55 | configStore = configDefault; 56 | CopyString(ssid, configStore.wifiSSID); 57 | CopyString(pass, configStore.wifiPass); 58 | CopyString(auth, configStore.cloudToken); 59 | 60 | BlynkState::set(MODE_SWITCH_TO_STA); 61 | }); 62 | 63 | } 64 | 65 | BLYNK_WRITE(InternalPinDBG) { 66 | String cmd = String(param.asStr()) + "\n"; 67 | edgentConsole.runCommand((char*)cmd.c_str()); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_Wio_Terminal/Edgent_Wio_Terminal.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | ************************************************************* 15 | Blynk.Edgent implements: 16 | - Blynk.Inject - Dynamic WiFi credentials provisioning 17 | - Blynk.Air - Over The Air firmware updates 18 | - Device state indication using a physical LED 19 | - Credentials reset using a physical Button 20 | 21 | Required libraries: 22 | - Seeed Arduino rpcUnified 23 | - Seeed Arduino rpcWiFi 24 | - Seeed Arduino SFUD 25 | - Seeed Arduino FS 26 | - Seeed Arduino mbedtls 27 | - Seeed Arduino FreeRTOS 28 | - ArduinoOTA 29 | - ArduinoHttpClient 30 | 31 | NOTE: Please also update the WiFi module firmware: 32 | https://wiki.seeedstudio.com/Wio-Terminal-Network-Overview 33 | *************************************************************/ 34 | 35 | /* Fill in information from your Blynk Template here */ 36 | /* Read more: https://bit.ly/BlynkInject */ 37 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 38 | //#define BLYNK_TEMPLATE_NAME "Device" 39 | 40 | #define BLYNK_FIRMWARE_VERSION "0.1.0" 41 | 42 | #define BLYNK_PRINT Serial 43 | //#define BLYNK_DEBUG 44 | 45 | #define APP_DEBUG 46 | 47 | #include "BlynkEdgent.h" 48 | 49 | void setup() 50 | { 51 | Serial.begin(115200); 52 | delay(100); 53 | 54 | BlynkEdgent.begin(); 55 | } 56 | 57 | void loop() { 58 | BlynkEdgent.run(); 59 | } 60 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_Wio_Terminal/ResetButton.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef BOARD_BUTTON_PIN 3 | 4 | volatile bool g_buttonPressed = false; 5 | volatile uint32_t g_buttonPressTime = -1; 6 | 7 | void button_action(void) 8 | { 9 | BlynkState::set(MODE_RESET_CONFIG); 10 | } 11 | 12 | void button_change(void) 13 | { 14 | #if BOARD_BUTTON_ACTIVE_LOW 15 | bool buttonState = !digitalRead(BOARD_BUTTON_PIN); 16 | #else 17 | bool buttonState = digitalRead(BOARD_BUTTON_PIN); 18 | #endif 19 | 20 | if (buttonState && !g_buttonPressed) { 21 | g_buttonPressTime = millis(); 22 | g_buttonPressed = true; 23 | DEBUG_PRINT("Hold the button for 10 seconds to reset configuration..."); 24 | } else if (!buttonState && g_buttonPressed) { 25 | g_buttonPressed = false; 26 | uint32_t buttonHoldTime = millis() - g_buttonPressTime; 27 | if (buttonHoldTime >= BUTTON_HOLD_TIME_ACTION) { 28 | button_action(); 29 | } else if (buttonHoldTime >= BUTTON_PRESS_TIME_ACTION) { 30 | // User action 31 | } 32 | g_buttonPressTime = -1; 33 | } 34 | } 35 | 36 | void button_init() 37 | { 38 | #if BOARD_BUTTON_ACTIVE_LOW 39 | pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP); 40 | #else 41 | pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); 42 | #endif 43 | attachInterrupt(BOARD_BUTTON_PIN, button_change, CHANGE); 44 | } 45 | 46 | #else 47 | 48 | #define g_buttonPressed false 49 | #define g_buttonPressTime 0 50 | 51 | void button_init() {} 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /examples/Blynk.Edgent/Edgent_Wio_Terminal/Settings.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Board configuration (see examples below). 4 | */ 5 | 6 | // Example configuration for Wio Terminal Board 7 | #define BOARD_BUTTON_PIN WIO_KEY_A // Pin where user button is attached 8 | #define BOARD_BUTTON_ACTIVE_LOW true // true if button is "active-low" 9 | 10 | #define BOARD_LED_PIN LED_BUILTIN // Set LED pin - if you have a single-color LED attached 11 | //#define BOARD_LED_PIN_R 27 // Set R,G,B pins - if your LED is PWM RGB 12 | //#define BOARD_LED_PIN_G 26 13 | //#define BOARD_LED_PIN_B 25 14 | //#define BOARD_LED_PIN_WS2812 33 // Set if your LED is WS2812 RGB 15 | #define BOARD_LED_INVERSE false // true if LED is common anode, false if common cathode 16 | #define BOARD_LED_BRIGHTNESS 255 // 0..255 brightness control 17 | 18 | 19 | /* 20 | * Advanced options 21 | */ 22 | 23 | #define BUTTON_HOLD_TIME_INDICATION 3000 24 | #define BUTTON_HOLD_TIME_ACTION 10000 25 | #define BUTTON_PRESS_TIME_ACTION 50 26 | 27 | #define BOARD_PWM_MAX 1023 28 | 29 | #if !defined(CONFIG_DEVICE_PREFIX) 30 | #define CONFIG_DEVICE_PREFIX "Blynk" 31 | #endif 32 | #if !defined(CONFIG_AP_URL) 33 | #define CONFIG_AP_URL "blynk.setup" 34 | #endif 35 | #if !defined(CONFIG_DEFAULT_SERVER) 36 | #define CONFIG_DEFAULT_SERVER "blynk.cloud" 37 | #endif 38 | #if !defined(CONFIG_DEFAULT_PORT) 39 | #define CONFIG_DEFAULT_PORT 443 40 | #endif 41 | 42 | #define WIFI_CLOUD_MAX_RETRIES 500 43 | #define WIFI_NET_CONNECT_TIMEOUT 50000 44 | #define WIFI_CLOUD_CONNECT_TIMEOUT 50000 45 | #define WIFI_AP_IP IPAddress(192, 168, 4, 1) 46 | #define WIFI_AP_Subnet IPAddress(255, 255, 255, 0) 47 | //#define WIFI_CAPTIVE_PORTAL_ENABLE 1 48 | 49 | //#define USE_TC3 50 | //#define USE_TCC0 51 | 52 | #define BLYNK_NO_DEFAULT_BANNER 53 | 54 | #if defined(APP_DEBUG) 55 | #define DEBUG_PRINT(...) BLYNK_LOG1(__VA_ARGS__) 56 | #define DEBUG_PRINTF(...) BLYNK_LOG(__VA_ARGS__) 57 | #else 58 | #define DEBUG_PRINT(...) 59 | #define DEBUG_PRINTF(...) 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /examples/Boards_Ethernet/Arduino_Ethernet/Arduino_Ethernet.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino Ethernet shield (W5100) 18 | to connect your project to Blynk. 19 | 20 | NOTE: Pins 10, 11, 12 and 13 are reserved for Ethernet module. 21 | DON'T use them in your sketch directly! 22 | 23 | WARNING: If you have an SD card, you may need to disable it 24 | by setting pin 4 to HIGH. Read more here: 25 | https://www.arduino.cc/en/Main/ArduinoEthernetShield 26 | 27 | Feel free to apply it to any other example. It's simple! 28 | *************************************************************/ 29 | 30 | /* Comment this out to disable prints and save space */ 31 | #define BLYNK_PRINT Serial 32 | 33 | /* Fill in information from Blynk Device Info here */ 34 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 35 | //#define BLYNK_TEMPLATE_NAME "Device" 36 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 37 | 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #define W5100_CS 10 44 | #define SDCARD_CS 4 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | pinMode(SDCARD_CS, OUTPUT); 52 | digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card 53 | 54 | Blynk.begin(BLYNK_AUTH_TOKEN); 55 | // You can also specify server: 56 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 57 | //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080); 58 | // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example 59 | } 60 | 61 | void loop() 62 | { 63 | Blynk.run(); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /examples/Boards_Ethernet/Arduino_MKR_ETH/Arduino_MKR_ETH.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKR ETH shield 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires the latest Ethernet library (2.0.0+) 21 | 22 | WARNING: If you have an SD card, you may need to disable it 23 | by setting pin 4 to HIGH. Read more here: 24 | https://www.arduino.cc/en/Main/ArduinoEthernetShield 25 | 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | #define MKRETH_CS 5 43 | #define SDCARD_CS 4 44 | 45 | void setup() 46 | { 47 | // Debug console 48 | Serial.begin(9600); 49 | 50 | pinMode(SDCARD_CS, OUTPUT); 51 | digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card 52 | 53 | Ethernet.init(MKRETH_CS); // Init MKR ETH shield 54 | 55 | Blynk.begin(BLYNK_AUTH_TOKEN); 56 | // You can also specify server: 57 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 58 | //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080); 59 | // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example 60 | } 61 | 62 | void loop() 63 | { 64 | Blynk.run(); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /examples/Boards_Ethernet/Arduino_MKR_ETH_SSL/Arduino_MKR_ETH_SSL.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKR ETH shield 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires the latest Ethernet library (2.0.0+) 21 | 22 | WARNING: If you have an SD card, you may need to disable it 23 | by setting pin 4 to HIGH. Read more here: 24 | https://www.arduino.cc/en/Main/ArduinoEthernetShield 25 | 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #define MKRETH_CS 5 45 | #define SDCARD_CS 4 46 | 47 | void setup() 48 | { 49 | // Debug console 50 | Serial.begin(9600); 51 | 52 | pinMode(SDCARD_CS, OUTPUT); 53 | digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card 54 | 55 | Ethernet.init(MKRETH_CS); // Init MKR ETH shield 56 | 57 | // Enable NTP time helper (needed for SSL authentiction) 58 | ArduinoBearSSL.onGetTime(ntpGetTime); 59 | 60 | Blynk.begin(BLYNK_AUTH_TOKEN); 61 | // You can also specify server: 62 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 63 | //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080); 64 | // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example 65 | } 66 | 67 | void loop() 68 | { 69 | Blynk.run(); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /examples/Boards_Ethernet/ENC28J60/ENC28J60.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | For this example you need EthernetENC library: 18 | https://github.com/jandrassy/EthernetENC 19 | 20 | Typical wiring would be (this is for Arduino UNO, 21 | search for correct wiring for your board): 22 | VCC -- 5V 23 | GND -- GND 24 | CS -- D10 25 | SI -- D11 26 | SCK -- D13 27 | SO -- D12 28 | INT -- D2 29 | 30 | Feel free to apply it to any other example. It's simple! 31 | *************************************************************/ 32 | 33 | /* Comment this out to disable prints and save space */ 34 | #define BLYNK_PRINT Serial 35 | 36 | /* Fill in information from Blynk Device Info here */ 37 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 38 | //#define BLYNK_TEMPLATE_NAME "Device" 39 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 40 | 41 | 42 | #include 43 | #include 44 | 45 | void setup() 46 | { 47 | // Debug console 48 | Serial.begin(9600); 49 | 50 | Blynk.begin(BLYNK_AUTH_TOKEN); 51 | // You can also specify server: 52 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 53 | //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080); 54 | } 55 | 56 | void loop() 57 | { 58 | Blynk.run(); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /examples/Boards_GSM/Arduino_MKRGSM/Arduino_MKRGSM.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKRGSM 1400 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires MKRGSM library 21 | from https://www.arduino.cc/en/Reference/MKRGSM 22 | 23 | Feel free to apply it to any other example. It's simple! 24 | *************************************************************/ 25 | 26 | /* Comment this out to disable prints and save space */ 27 | #define BLYNK_PRINT Serial 28 | 29 | /* Fill in information from Blynk Device Info here */ 30 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 31 | //#define BLYNK_TEMPLATE_NAME "Device" 32 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | // Your SIM and GPRS credentials 40 | // Leave empty, if missing pin, user or pass 41 | char pin[] = ""; 42 | char apn[] = "YourAPN"; 43 | char user[] = ""; 44 | char pass[] = ""; 45 | 46 | GSMClient client; 47 | GPRS gprs; 48 | GSM gsmAccess; 49 | 50 | void setup() 51 | { 52 | // Debug console 53 | Serial.begin(9600); 54 | 55 | Blynk.begin(BLYNK_AUTH_TOKEN, gsmAccess, gprs, client, pin, apn, user, pass); 56 | } 57 | 58 | void loop() 59 | { 60 | Blynk.run(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/Boards_GSM/Arduino_MKRNB/Arduino_MKRNB.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKRNB 1500 18 | to connect your project to Blynk. 19 | NOTE: This requires MKRGSM library 20 | from https://www.arduino.cc/en/Reference/MKRNB 21 | Feel free to apply it to any other example. It's simple! 22 | *************************************************************/ 23 | /* Comment this out to disable prints and save space */ 24 | #define BLYNK_PRINT Serial 25 | 26 | /* Fill in information from Blynk Device Info here */ 27 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 28 | //#define BLYNK_TEMPLATE_NAME "Device" 29 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 30 | 31 | 32 | #include 33 | #include 34 | 35 | NBClient client; 36 | GPRS gprs; 37 | NB nbAccess; 38 | 39 | // Your SIM credential 40 | // Leave empty, if missing pin 41 | char pin[] = ""; 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | Blynk.begin(BLYNK_AUTH_TOKEN, nbAccess, gprs, client, pin); 48 | } 49 | void loop() 50 | { 51 | Blynk.run(); 52 | } 53 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Adafruit_Feather_M0_WiFi/Adafruit_Feather_M0_WiFi.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Adafruit Feather M0 WiFi 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WiFi101 library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | 37 | // Your WiFi credentials. 38 | // Set password to "" for open networks. 39 | char ssid[] = "YourNetworkName"; 40 | char pass[] = "YourPassword"; 41 | 42 | void setup() 43 | { 44 | // Debug console 45 | Serial.begin(9600); 46 | 47 | WiFi.setPins(8, 7, 4, 2); 48 | 49 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 50 | // You can also specify server: 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 52 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_MKR1000/Arduino_MKR1000.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKR1000 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WiFi101 library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // Your WiFi credentials. 39 | // Set password to "" for open networks. 40 | char ssid[] = "YourNetworkName"; 41 | char pass[] = "YourPassword"; 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | 48 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 49 | // You can also specify server: 50 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_MKR1010/Arduino_MKR1010.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino MKR 1010 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WiFiNINA library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // Your WiFi credentials. 39 | // Set password to "" for open networks. 40 | char ssid[] = "YourNetworkName"; 41 | char pass[] = "YourPassword"; 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | 48 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 49 | // You can also specify server: 50 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_WiFi_Shield/Arduino_WiFi_Shield.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino WiFi shield 18 | to connect your project to Blynk. 19 | 20 | Please update your shield firmware: 21 | https://www.arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading 22 | 23 | Feel free to apply it to any other example. It's simple! 24 | *************************************************************/ 25 | 26 | /* Comment this out to disable prints and save space */ 27 | #define BLYNK_PRINT Serial 28 | 29 | /* Fill in information from Blynk Device Info here */ 30 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 31 | //#define BLYNK_TEMPLATE_NAME "Device" 32 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | // Your WiFi credentials. 40 | // Set password to "" for open networks. 41 | char ssid[] = "YourNetworkName"; 42 | char pass[] = "YourPassword"; 43 | 44 | void setup() 45 | { 46 | // Debug console 47 | Serial.begin(9600); 48 | 49 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 50 | // You can also specify server: 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 52 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_WiFi_Shield_101/Arduino_WiFi_Shield_101.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino WiFi 101 shield 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WiFi101 library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // Your WiFi credentials. 39 | // Set password to "" for open networks. 40 | char ssid[] = "YourNetworkName"; 41 | char pass[] = "YourPassword"; 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | 48 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 49 | // You can also specify server: 50 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_Yun/Arduino_Yun.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino Yun Bridge 18 | to connect your project to Blynk. 19 | 20 | Feel free to apply it to any other example. It's simple! 21 | *************************************************************/ 22 | 23 | /* Comment this out to disable prints and save space */ 24 | #define BLYNK_PRINT Serial 25 | 26 | /* Fill in information from Blynk Device Info here */ 27 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 28 | //#define BLYNK_TEMPLATE_NAME "Device" 29 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 30 | 31 | 32 | #include 33 | #include 34 | 35 | void setup() 36 | { 37 | // Debug console 38 | Serial.begin(9600); 39 | 40 | Blynk.begin(BLYNK_AUTH_TOKEN); 41 | // You can also specify server: 42 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 43 | //Blynk.begin(BLYNK_AUTH_TOKEN, IPAddress(192,168,1,100), 8080); 44 | } 45 | 46 | void loop() 47 | { 48 | Blynk.run(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Arduino_org_UNO_WiFi/Arduino_org_UNO_WiFi.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use Arduino.org UNO WiFi 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WiFi Link library 21 | 22 | Please update your UNO WiFi firmware to WiFiLink 1.0.0 (at least). 23 | 24 | Feel free to apply it to any other example. It's simple! 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | 39 | // Your WiFi credentials. 40 | // Set password to "" for open networks. 41 | char ssid[] = "YourNetworkName"; 42 | char pass[] = "YourPassword"; 43 | 44 | void setup() 45 | { 46 | // Debug console 47 | Serial.begin(9600); 48 | 49 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 50 | // You can also specify server: 51 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 52 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP32_WiFi/ESP32_WiFi.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on ESP32 chip. 18 | 19 | NOTE: This requires ESP32 support package: 20 | https://github.com/espressif/arduino-esp32 21 | 22 | Please be sure to select the right ESP32 module 23 | in the Tools -> Board menu! 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | // Your WiFi credentials. 43 | // Set password to "" for open networks. 44 | char ssid[] = "YourNetworkName"; 45 | char pass[] = "YourPassword"; 46 | 47 | void setup() 48 | { 49 | // Debug console 50 | Serial.begin(9600); 51 | 52 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP32_WiFi_SSL/ESP32_WiFi_SSL.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on ESP32 chip. 18 | 19 | NOTE: This requires ESP32 support package: 20 | https://github.com/espressif/arduino-esp32 21 | 22 | Please be sure to select the right ESP32 module 23 | in the Tools -> Board menu! 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | // Your WiFi credentials. 43 | // Set password to "" for open networks. 44 | char ssid[] = "YourNetworkName"; 45 | char pass[] = "YourPassword"; 46 | 47 | void setup() 48 | { 49 | // Debug console 50 | Serial.begin(9600); 51 | 52 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP8266_Shield/ESP8266_Shield.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to use ESP8266 Shield (with AT commands) 19 | to connect your project to Blynk. 20 | 21 | WARNING! 22 | It's very tricky to get it working. Please read this article: 23 | http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | 41 | // Your WiFi credentials. 42 | // Set password to "" for open networks. 43 | char ssid[] = "YourNetworkName"; 44 | char pass[] = "YourPassword"; 45 | 46 | // Hardware Serial on Mega, Leonardo, Micro... 47 | #define EspSerial Serial1 48 | 49 | // or Software Serial on Uno, Nano... 50 | //#include 51 | //SoftwareSerial EspSerial(2, 3); // RX, TX 52 | 53 | // Your ESP8266 baud rate: 54 | #define ESP8266_BAUD 115200 55 | 56 | ESP8266 wifi(&EspSerial); 57 | 58 | void setup() 59 | { 60 | // Debug console 61 | Serial.begin(9600); 62 | 63 | delay(10); 64 | 65 | // Set ESP8266 baud rate 66 | EspSerial.begin(ESP8266_BAUD); 67 | delay(10); 68 | 69 | Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass); 70 | } 71 | 72 | void loop() 73 | { 74 | Blynk.run(); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP8266_Standalone/ESP8266_Standalone.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on ESP8266 chip. 18 | 19 | NOTE: This requires ESP8266 support package: 20 | https://github.com/esp8266/Arduino 21 | 22 | Please be sure to select the right ESP8266 module 23 | in the Tools -> Board menu! 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | 41 | // Your WiFi credentials. 42 | // Set password to "" for open networks. 43 | char ssid[] = "YourNetworkName"; 44 | char pass[] = "YourPassword"; 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP8266_Standalone_Manual_IP/ESP8266_Standalone_Manual_IP.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on ESP8266 chip. 18 | 19 | NOTE: This requires ESP8266 support package: 20 | https://github.com/esp8266/Arduino 21 | 22 | Please be sure to select the right ESP8266 module 23 | in the Tools -> Board menu! 24 | 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | 39 | // Your WiFi credentials. 40 | // Set password to "" for open networks. 41 | char ssid[] = "YourNetworkName"; 42 | char pass[] = "YourPassword"; 43 | 44 | 45 | // Mac address should be different for each device in your LAN 46 | byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; 47 | IPAddress device_ip (192, 168, 0, 80); 48 | IPAddress dns_ip ( 8, 8, 8, 8); 49 | IPAddress gateway_ip (192, 168, 0, 1); 50 | IPAddress subnet_mask(255, 255, 255, 0); 51 | 52 | void setup() 53 | { 54 | // Debug console 55 | Serial.begin(9600); 56 | 57 | // Setup WiFi network 58 | WiFi.config(device_ip, gateway_ip, subnet_mask); 59 | WiFi.begin(ssid, pass); 60 | 61 | // Setup Blynk 62 | Blynk.config(BLYNK_AUTH_TOKEN); 63 | while (Blynk.connect() == false) { 64 | } 65 | 66 | } 67 | 68 | void loop() 69 | { 70 | Blynk.run(); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/ESP8266_Standalone_SSL/ESP8266_Standalone_SSL.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on ESP8266 chip. 18 | 19 | NOTE: This requires ESP8266 support package: 20 | https://github.com/esp8266/Arduino 21 | 22 | Please be sure to select the right ESP8266 module 23 | in the Tools -> Board menu! 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | 41 | // Your WiFi credentials. 42 | // Set password to "" for open networks. 43 | char ssid[] = "YourNetworkName"; 44 | char pass[] = "YourPassword"; 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Fishino/Fishino.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to use Fishino to connect your project to Blynk. 19 | 20 | NOTE: This requires Fishino Software libraries: 21 | http://fishino.it/en/download/ 22 | 23 | Change WiFi ssid, pass, and Blynk auth token to run :) 24 | Feel free to apply it to any other example. It's simple! 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | // Your WiFi credentials. 41 | // Set password to "" for open networks. 42 | char ssid[] = "YourNetworkName"; 43 | char pass[] = "YourPassword"; 44 | 45 | void setup() 46 | { 47 | // Debug console 48 | Serial.begin(9600); 49 | 50 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 51 | } 52 | 53 | void loop() 54 | { 55 | Blynk.run(); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/LinkItONE/LinkItONE.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use LinkItONE to connect your project to Blynk. 18 | 19 | Change WiFi ssid, pass, and Blynk auth token to run :) 20 | Feel free to apply it to any other example. It's simple! 21 | *************************************************************/ 22 | 23 | /* Comment this out to disable prints and save space */ 24 | #define BLYNK_PRINT Serial 25 | 26 | /* Fill in information from Blynk Device Info here */ 27 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 28 | //#define BLYNK_TEMPLATE_NAME "Device" 29 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 30 | 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | // Your WiFi credentials. 37 | // Choose wifi_sec from LWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP 38 | char ssid[] = "YourNetworkName"; 39 | char pass[] = "YourPassword"; 40 | int wifi_sec = LWIFI_WPA; 41 | 42 | void setup() 43 | { 44 | // Debug console 45 | Serial.begin(9600); 46 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, wifi_sec); 47 | } 48 | 49 | void loop() 50 | { 51 | Blynk.run(); 52 | } 53 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/RN_XV_WiFly/RN_XV_WiFly.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use WiFly RN-XV 18 | to connect your project to Blynk. 19 | 20 | For this example you need WiFlyHQ library: 21 | https://github.com/harlequin-tech/WiFlyHQ 22 | 23 | NOTE: Ensure a stable serial connection! 24 | Hardware serial is preferred. 25 | Firmware version 4.41 or later is preferred. 26 | 27 | Change WiFi ssid, pass, and Blynk auth token to run :) 28 | Feel free to apply it to any other example. It's simple! 29 | *************************************************************/ 30 | 31 | /* Comment this out to disable prints and save space */ 32 | #define BLYNK_PRINT Serial 33 | 34 | /* Fill in information from Blynk Device Info here */ 35 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 36 | //#define BLYNK_TEMPLATE_NAME "Device" 37 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 38 | 39 | 40 | #include 41 | #include 42 | 43 | // Your WiFi credentials. 44 | // Set password to "" for open networks. 45 | char ssid[] = "YourNetworkName"; 46 | char pass[] = "YourPassword"; 47 | 48 | #define WiFlySerial Serial1 49 | // This can be a SoftwareSerial object: 50 | //#include 51 | //SoftwareSerial WiFlySerial(2, 3); // RX, TX 52 | 53 | WiFly wifly; 54 | 55 | void setup() 56 | { 57 | // Debug console 58 | Serial.begin(9600); 59 | 60 | delay(10); 61 | 62 | WiFlySerial.begin(9600); // Set your RN-XV baud rate 63 | delay(10); 64 | 65 | // Bind WiFly driver to the serial 66 | if (!wifly.begin(&WiFlySerial)) { 67 | BLYNK_FATAL("Failed to start wifly"); 68 | } 69 | 70 | // You can try increasing baud rate: 71 | //wifly.setBaud(115200); 72 | //WiFlySerial.begin(115200); 73 | 74 | Blynk.begin(BLYNK_AUTH_TOKEN, wifly, ssid, pass); 75 | } 76 | 77 | void loop() 78 | { 79 | Blynk.run(); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/RedBear_Duo_WiFi/RedBear_Duo_WiFi.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use RedBear Duo 18 | to connect your project to Blynk. 19 | 20 | Feel free to apply it to any other example. It's simple! 21 | *************************************************************/ 22 | 23 | /* Comment this out to disable prints and save space */ 24 | #define BLYNK_PRINT Serial 25 | 26 | /* Fill in information from Blynk Device Info here */ 27 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 28 | //#define BLYNK_TEMPLATE_NAME "Device" 29 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 30 | 31 | 32 | #include 33 | 34 | // Your WiFi credentials. 35 | // Choose wifi_sec from WPA2, WPA, or WEP 36 | char ssid[] = "YourNetworkName"; 37 | char pass[] = "YourPassword"; 38 | int wifi_sec = WPA2; 39 | 40 | //SYSTEM_MODE(AUTOMATIC); 41 | SYSTEM_MODE(MANUAL); 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | 48 | delay(5000); 49 | 50 | WiFi.on(); 51 | WiFi.setCredentials(ssid, pass, wifi_sec); 52 | WiFi.connect(); 53 | 54 | Blynk.begin(BLYNK_AUTH_TOKEN); 55 | // Or specify server using one of those commands: 56 | //Blynk.begin(BLYNK_AUTH_TOKEN, "blynk.cloud", 80); 57 | //Blynk.begin(BLYNK_AUTH_TOKEN, server_ip, port); 58 | } 59 | 60 | void loop() 61 | { 62 | Blynk.run(); 63 | } 64 | 65 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Sparkfun_Blynk_Board/Sparkfun_Blynk_Board.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs on Sparkfun Blynk Board. 18 | 19 | NOTE: This requires ESP8266 support package: 20 | https://github.com/esp8266/Arduino 21 | 22 | You can select NodeMCU 1.0 (compatible board) 23 | in the Tools -> Board menu 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | 41 | // Your WiFi credentials. 42 | // Set password to "" for open networks. 43 | char ssid[] = "YourNetworkName"; 44 | char pass[] = "YourPassword"; 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 52 | // You can also specify server: 53 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 54 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 55 | } 56 | 57 | void loop() 58 | { 59 | Blynk.run(); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/TinyDuino_WiFi/TinyDuino_WiFi.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use TinyCircuits CC3000 shield 18 | to connect your project to Blynk. 19 | 20 | NOTE: Firmware version 1.14 or later is preferred. 21 | Tools->Board should be "Arduino Pro or Pro Mini" 22 | Tools->Processor should be "ATmega 328 (3.3V, 8MHz)" 23 | 24 | Change WiFi ssid, pass, and Blynk auth token to run :) 25 | Feel free to apply it to any other example. It's simple! 26 | *************************************************************/ 27 | 28 | /* Comment this out to disable prints and save space */ 29 | #define BLYNK_PRINT Serial 30 | 31 | /* Fill in information from Blynk Device Info here */ 32 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 33 | //#define BLYNK_TEMPLATE_NAME "Device" 34 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 35 | 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | // Your WiFi credentials. 42 | // Choose wifi_sec from WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 43 | char ssid[] = "YourNetworkName"; 44 | char pass[] = "YourPassword"; 45 | int wifi_sec = WLAN_SEC_WPA2; 46 | 47 | void setup() 48 | { 49 | // Debug console 50 | Serial.begin(9600); 51 | 52 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, wifi_sec); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/WildFire_V3/WildFire_V3.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use CC3000 on WildFire board 18 | to connect your project to Blynk. 19 | 20 | NOTE: You need to install Arduino IDE WildFire support: 21 | http://shop.wickeddevice.com/resources/wildfire/ 22 | 23 | NOTE: Firmware version 1.14 or later is preferred. 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | WildFire wildfire; 44 | 45 | // Your WiFi credentials. 46 | // Choose wifi_sec from WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2 47 | char ssid[] = "YourNetworkName"; 48 | char pass[] = "YourPassword"; 49 | int wifi_sec = WLAN_SEC_WPA2; 50 | 51 | void setup() 52 | { 53 | // Debug console 54 | Serial.begin(9600); 55 | 56 | wildfire.begin(); 57 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, wifi_sec); 58 | } 59 | 60 | void loop() 61 | { 62 | Blynk.run(); 63 | } 64 | 65 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/WildFire_V4/WildFire_V4.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use WildFire V4 18 | to connect your project to Blynk. 19 | 20 | NOTE: You need to install Arduino IDE WildFire support: 21 | http://shop.wickeddevice.com/resources/wildfire/ 22 | 23 | Change WiFi ssid, pass, and Blynk auth token to run :) 24 | Feel free to apply it to any other example. It's simple! 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | 39 | // Your WiFi credentials. 40 | // Set password to "" for open networks. 41 | char ssid[] = "YourNetworkName"; 42 | char pass[] = "YourPassword"; 43 | 44 | // Digital the pin that is used to reset/enable the ESP8266 module 45 | const int EspSwitch = 23; 46 | 47 | ESP8266 wifi(&Serial1); 48 | 49 | void setup() 50 | { 51 | // Debug console 52 | Serial.begin(9600); 53 | delay(10); 54 | 55 | // Set ESP8266 baud rate 56 | Serial1.begin(115200); 57 | delay(10); 58 | 59 | // Reset ESP 60 | pinMode(EspSwitch, OUTPUT); 61 | digitalWrite(EspSwitch, LOW); 62 | delay(50); 63 | digitalWrite(EspSwitch, HIGH); 64 | 65 | // Configure Blynk connection 66 | Blynk.begin(BLYNK_AUTH_TOKEN, wifi, ssid, pass); 67 | } 68 | 69 | void loop() 70 | { 71 | Blynk.run(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/Wio_Terminal/Wio_Terminal.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example runs directly on Wio Terminal. 18 | 19 | NOTE: This requires Wio Terminal Wi-Fi support package: 20 | https://wiki.seeedstudio.com/Wio-Terminal-Network-Overview/ 21 | 22 | Please be sure to select the right Wio Terminal module 23 | in the Tools -> Board menu! 24 | 25 | Change WiFi ssid, pass, and Blynk auth token to run :) 26 | Feel free to apply it to any other example. It's simple! 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | // Your WiFi credentials. 43 | // Set password to "" for open networks. 44 | char ssid[] = "YourNetworkName"; 45 | char pass[] = "YourPassword"; 46 | 47 | void setup() 48 | { 49 | // Debug console 50 | Serial.begin(9600); 51 | 52 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/WizFi250/WizFi250.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use WizFi250 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WizFi250 library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | #include 34 | #include 35 | 36 | // Your WiFi credentials. 37 | // Set password to "" for open networks. 38 | char ssid[] = "YourNetworkName"; 39 | char pass[] = "YourPassword"; 40 | 41 | void setup() 42 | { 43 | // Debug console 44 | Serial.begin(9600); 45 | WiFi.init(); 46 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 47 | // You can also specify server: 48 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 49 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 50 | } 51 | 52 | void loop() 53 | { 54 | Blynk.run(); 55 | } 56 | -------------------------------------------------------------------------------- /examples/Boards_WiFi/WizFi310/WizFi310.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example shows how to use WizFi310 18 | to connect your project to Blynk. 19 | 20 | NOTE: This requires WizFi310 library 21 | 22 | Feel free to apply it to any other example. It's simple! 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | 37 | // Your WiFi credentials. 38 | // Set password to "" for open networks. 39 | char ssid[] = "YourNetworkName"; 40 | char pass[] = "YourPassword"; 41 | 42 | void setup() 43 | { 44 | // Debug console 45 | Serial.begin(9600); 46 | 47 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 48 | // You can also specify server: 49 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, "blynk.cloud", 80); 50 | //Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass, IPAddress(192,168,1,100), 8080); 51 | } 52 | 53 | void loop() 54 | { 55 | Blynk.run(); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /examples/GettingStarted/GetData/GetData.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can use this sketch as a debug tool that prints all incoming values 19 | sent by a widget connected to a Virtual Pin 1 in the Blynk App. 20 | 21 | App dashboard setup: 22 | Slider widget (0...100) on V1 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // This function will be called every time Slider Widget 39 | // in Blynk app writes values to the Virtual Pin 1 40 | BLYNK_WRITE(V1) 41 | { 42 | int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable 43 | // You can also use: 44 | // String i = param.asStr(); 45 | // double d = param.asDouble(); 46 | Serial.print("V1 Slider value is: "); 47 | Serial.println(pinValue); 48 | } 49 | 50 | void setup() 51 | { 52 | // Debug console 53 | Serial.begin(9600); 54 | 55 | Blynk.begin(BLYNK_AUTH_TOKEN); 56 | } 57 | 58 | void loop() 59 | { 60 | Blynk.run(); 61 | } 62 | 63 | -------------------------------------------------------------------------------- /examples/GettingStarted/PushData/PushData.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how value can be pushed from Arduino to 19 | the Blynk App. 20 | 21 | NOTE: 22 | BlynkTimer provides SimpleTimer functionality: 23 | http://playground.arduino.cc/Code/SimpleTimer 24 | 25 | App dashboard setup: 26 | Value Display widget attached to Virtual Pin V5 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | BlynkTimer timer; 43 | 44 | // This function sends Arduino's up time every second to Virtual Pin (5). 45 | void myTimerEvent() 46 | { 47 | // You can send any value at any time. 48 | // Please don't send more that 10 values per second. 49 | Blynk.virtualWrite(V5, millis() / 1000); 50 | } 51 | 52 | void setup() 53 | { 54 | // Debug console 55 | Serial.begin(9600); 56 | 57 | Blynk.begin(BLYNK_AUTH_TOKEN); 58 | 59 | // Setup a function to be called every second 60 | timer.setInterval(1000L, myTimerEvent); 61 | } 62 | 63 | void loop() 64 | { 65 | Blynk.run(); 66 | timer.run(); // Initiates BlynkTimer 67 | } 68 | 69 | -------------------------------------------------------------------------------- /examples/GettingStarted/Servo/Servo.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Rotate a servo using a slider! 19 | 20 | App dashboard setup: 21 | Slider widget (0...180) on V3 22 | *************************************************************/ 23 | 24 | /* Comment this out to disable prints and save space */ 25 | #define BLYNK_PRINT Serial 26 | 27 | /* Fill in information from Blynk Device Info here */ 28 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 29 | //#define BLYNK_TEMPLATE_NAME "Device" 30 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 31 | 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | Servo servo; 39 | 40 | BLYNK_WRITE(V3) 41 | { 42 | servo.write(param.asInt()); 43 | } 44 | 45 | void setup() 46 | { 47 | // Debug console 48 | Serial.begin(9600); 49 | 50 | Blynk.begin(BLYNK_AUTH_TOKEN); 51 | 52 | servo.attach(9); 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/GettingStarted/VirtualPinRead/VirtualPinRead.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This sketch shows how to read values from Virtual Pins 19 | 20 | App dashboard setup: 21 | Slider widget (0...100) on Virtual Pin V1 22 | *************************************************************/ 23 | 24 | /* Comment this out to disable prints and save space */ 25 | #define BLYNK_PRINT Serial 26 | 27 | /* Fill in information from Blynk Device Info here */ 28 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 29 | //#define BLYNK_TEMPLATE_NAME "Device" 30 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 31 | 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | // This function will be called every time Slider Widget 38 | // in Blynk app writes values to the Virtual Pin V1 39 | BLYNK_WRITE(V1) 40 | { 41 | int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable 42 | 43 | // process received value 44 | } 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | Blynk.begin(BLYNK_AUTH_TOKEN); 52 | } 53 | 54 | void loop() 55 | { 56 | Blynk.run(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/GettingStarted/VirtualPinWrite/VirtualPinWrite.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This sketch shows how to write values to Virtual Pins 19 | 20 | NOTE: 21 | BlynkTimer provides SimpleTimer functionality: 22 | http://playground.arduino.cc/Code/SimpleTimer 23 | 24 | App dashboard setup: 25 | Value Display widget attached to Virtual Pin V5 26 | *************************************************************/ 27 | 28 | /* Comment this out to disable prints and save space */ 29 | #define BLYNK_PRINT Serial 30 | 31 | /* Fill in information from Blynk Device Info here */ 32 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 33 | //#define BLYNK_TEMPLATE_NAME "Device" 34 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 35 | 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | BlynkTimer timer; 42 | 43 | // This function sends Arduino's up time every second to Virtual Pin (5) 44 | void myTimerEvent() 45 | { 46 | // You can send any value at any time. 47 | // Please don't send more that 10 values per second. 48 | Blynk.virtualWrite(V5, millis() / 1000); 49 | } 50 | 51 | void setup() 52 | { 53 | // Debug console 54 | Serial.begin(9600); 55 | 56 | Blynk.begin(BLYNK_AUTH_TOKEN); 57 | 58 | // Setup a function to be called every second 59 | timer.setInterval(1000L, myTimerEvent); 60 | } 61 | 62 | void loop() 63 | { 64 | Blynk.run(); 65 | timer.run(); // Initiates BlynkTimer 66 | } 67 | 68 | -------------------------------------------------------------------------------- /examples/More/FormatString/FormatString.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can construct and display any strings on a Value Display. 19 | 20 | App dashboard setup: 21 | Value Display widget attached to V5 22 | *************************************************************/ 23 | 24 | /* Comment this out to disable prints and save space */ 25 | #define BLYNK_PRINT Serial 26 | 27 | /* Fill in information from Blynk Device Info here */ 28 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 29 | //#define BLYNK_TEMPLATE_NAME "Device" 30 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 31 | 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | BlynkTimer timer; 38 | 39 | // This function sends Arduino's up time every second to Virtual Pin (5) 40 | void sendTemperature() 41 | { 42 | // Generate random temperature value 10.0 to 30.0 (for example) 43 | float t = float(random(100, 300)) / 10; 44 | 45 | // Format: 1 decimal place, add ℃ 46 | String str = String(t, 1) + "℃"; 47 | 48 | // Send it to the server 49 | Blynk.virtualWrite(V5, str); 50 | } 51 | 52 | void setup() 53 | { 54 | // Debug console 55 | Serial.begin(9600); 56 | 57 | Blynk.begin(BLYNK_AUTH_TOKEN); 58 | 59 | // Setup a function to be called every second 60 | timer.setInterval(1000L, sendTemperature); 61 | } 62 | 63 | void loop() 64 | { 65 | Blynk.run(); 66 | timer.run(); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /examples/More/HandleDisconnect/HandleDisconnect.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to keep WiFi connection on ESP8266. 19 | 20 | *************************************************************/ 21 | 22 | /* Comment this out to disable prints and save space */ 23 | #define BLYNK_PRINT Serial 24 | 25 | /* Fill in information from Blynk Device Info here */ 26 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 27 | //#define BLYNK_TEMPLATE_NAME "Device" 28 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 29 | 30 | 31 | #include 32 | #include 33 | 34 | // Your WiFi credentials. 35 | // Set password to "" for open networks. 36 | char ssid[] = "YourNetworkName"; 37 | char pass[] = "YourPassword"; 38 | 39 | 40 | int lastConnectionAttempt = millis(); 41 | int connectionDelay = 5000; // try to reconnect every 5 seconds 42 | 43 | void setup() 44 | { 45 | // Debug console 46 | Serial.begin(9600); 47 | 48 | Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 49 | } 50 | 51 | void loop() 52 | { 53 | // check WiFi connection: 54 | if (WiFi.status() != WL_CONNECTED) 55 | { 56 | // (optional) "offline" part of code 57 | 58 | // check delay: 59 | if (millis() - lastConnectionAttempt >= connectionDelay) 60 | { 61 | lastConnectionAttempt = millis(); 62 | 63 | // attempt to connect to Wifi network: 64 | if (pass && strlen(pass)) 65 | { 66 | WiFi.begin((char*)ssid, (char*)pass); 67 | } 68 | else 69 | { 70 | WiFi.begin((char*)ssid); 71 | } 72 | } 73 | } 74 | else 75 | { 76 | Blynk.run(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /examples/More/PrintAllVirtual/PrintAllVirtual.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | This example uses BLYNK_WRITE_DEFAULT to capture arbitrary 18 | virtual pin changes. This may be useful if you have lots 19 | of DataStreams with controls. 20 | It also shows how to iterate over all parameter values. 21 | *************************************************************/ 22 | 23 | /* Comment this out to disable prints and save space */ 24 | #define BLYNK_PRINT Serial 25 | 26 | /* Fill in information from Blynk Device Info here */ 27 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 28 | //#define BLYNK_TEMPLATE_NAME "Device" 29 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 30 | 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | // This is called for all virtual pins, that don't have BLYNK_WRITE handler 37 | BLYNK_WRITE_DEFAULT() { 38 | Serial.print("input V"); 39 | Serial.print(request.pin); 40 | Serial.println(":"); 41 | // Print all parameter values 42 | for (auto i = param.begin(); i < param.end(); ++i) { 43 | Serial.print("* "); 44 | Serial.println(i.asString()); 45 | } 46 | } 47 | 48 | void setup() 49 | { 50 | // Debug console 51 | Serial.begin(9600); 52 | 53 | Blynk.begin(BLYNK_AUTH_TOKEN); 54 | } 55 | 56 | void loop() 57 | { 58 | Blynk.run(); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /examples/More/RTC_Advanced/RTC_Advanced.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Blynk can provide your device with time data, like an RTC. 19 | Please note that the accuracy of this method is up to several seconds. 20 | 21 | NOTE: there's a better way to get a detailed time and timezone info. 22 | See TimeAndLocation example for details! 23 | 24 | *************************************************************/ 25 | 26 | /* Comment this out to disable prints and save space */ 27 | #define BLYNK_PRINT Serial 28 | 29 | /* Fill in information from Blynk Device Info here */ 30 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 31 | //#define BLYNK_TEMPLATE_NAME "Device" 32 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | BlynkTimer timer; 40 | 41 | void requestTime() { 42 | Blynk.sendInternal("rtc", "sync"); 43 | } 44 | 45 | BLYNK_WRITE(InternalPinRTC) { 46 | long t = param.asLong(); 47 | Serial.print("Unix time: "); 48 | Serial.print(t); 49 | Serial.println(); 50 | } 51 | 52 | void setup() 53 | { 54 | // Debug console 55 | Serial.begin(9600); 56 | 57 | Blynk.begin(BLYNK_AUTH_TOKEN); 58 | 59 | timer.setInterval(10000L, requestTime); 60 | } 61 | 62 | void loop() 63 | { 64 | Blynk.run(); 65 | timer.run(); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /examples/More/ServerAsDataStorage/ServerAsDataStorage_MultiValue/ServerAsDataStorage_MultiValue.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows you how you can use server as storage for 19 | your data like EEPROM 20 | 21 | App dashboard setup (optional): 22 | Value display on V1 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | BlynkTimer timer; 39 | int uptimeCounter; 40 | String someStaticData = "SomeStaticData"; 41 | 42 | // This function will run every time Blynk connection is established 43 | BLYNK_CONNECTED() { 44 | //get data stored in virtual pin V0 from server 45 | Blynk.syncVirtual(V0); 46 | } 47 | 48 | // restoring counter from server 49 | BLYNK_WRITE(V0) 50 | { 51 | //restoring int value 52 | uptimeCounter = param[0].asInt(); 53 | //restoring string value 54 | someStaticData = param[1].asString(); 55 | } 56 | 57 | void increment() { 58 | uptimeCounter++; 59 | 60 | //storing int and string in V0 pin on server 61 | Blynk.virtualWrite(V0, uptimeCounter, someStaticData); 62 | 63 | //updating value display with uptimeCounter 64 | Blynk.virtualWrite(V1, uptimeCounter); 65 | } 66 | 67 | void setup() 68 | { 69 | // Debug console 70 | Serial.begin(9600); 71 | 72 | Blynk.begin(BLYNK_AUTH_TOKEN); 73 | 74 | timer.setInterval(1000L, increment); 75 | } 76 | 77 | void loop() 78 | { 79 | Blynk.run(); 80 | timer.run(); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /examples/More/ServerAsDataStorage/ServerAsDataStorage_SingleValue/ServerAsDataStorage_SingleValue.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows you how you can use server as storage for 19 | your data like EEPROM 20 | 21 | App dashboard setup (optional): 22 | Value display on V0 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | BlynkTimer timer; 39 | int uptimeCounter; 40 | 41 | // This function will run every time Blynk connection is established 42 | BLYNK_CONNECTED() { 43 | //get data stored in virtual pin V0 from server 44 | Blynk.syncVirtual(V0); 45 | } 46 | 47 | // restoring counter from server 48 | BLYNK_WRITE(V0) 49 | { 50 | //restoring int value 51 | uptimeCounter = param.asInt(); 52 | } 53 | 54 | void increment() { 55 | uptimeCounter++; 56 | 57 | //storing int in V0 pin on server 58 | Blynk.virtualWrite(V0, uptimeCounter); 59 | } 60 | 61 | void setup() 62 | { 63 | // Debug console 64 | Serial.begin(9600); 65 | 66 | Blynk.begin(BLYNK_AUTH_TOKEN); 67 | 68 | timer.setInterval(1000L, increment); 69 | } 70 | 71 | void loop() 72 | { 73 | Blynk.run(); 74 | timer.run(); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /examples/More/SetProperty/SetProperty_MultiValue/SetProperty_MultiValue.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can set predefined properties (color, label, ...) of any widget. 19 | Read more: https://docs.blynk.io/en/blynk.edgent-firmware-api/widget-properties 20 | 21 | Datastream setup: 22 | Virtual Pin V1, type: Integer, min: 1, max: 3 23 | 24 | App dashboard setup: 25 | Menu Widget on V1 with 2 items: "Item 1", "Add items" 26 | *************************************************************/ 27 | 28 | /* Comment this out to disable prints and save space */ 29 | #define BLYNK_PRINT Serial 30 | 31 | /* Fill in information from Blynk Device Info here */ 32 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 33 | //#define BLYNK_TEMPLATE_NAME "Device" 34 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 35 | 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | BLYNK_WRITE(V1) { 42 | int value = param.asInt(); 43 | if (value == 1) { 44 | Serial.println("Item 1 selected"); 45 | } else if (value == 2) { 46 | // If item 2 is selected, change menu items... 47 | BlynkParamAllocated items(128); // list length, in bytes 48 | items.add("New item 1"); 49 | items.add("New item 2"); 50 | items.add("New item 3"); 51 | Blynk.setProperty(V1, "labels", items); 52 | 53 | // You can also use it like this: 54 | //Blynk.setProperty(V1, "labels", "item 1", "item 2", "item 3"); 55 | 56 | } else { 57 | Serial.println("Unknown item selected"); 58 | } 59 | } 60 | 61 | void setup() 62 | { 63 | // Debug console 64 | Serial.begin(9600); 65 | 66 | Blynk.begin(BLYNK_AUTH_TOKEN); 67 | } 68 | 69 | void loop() 70 | { 71 | Blynk.run(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /examples/More/SetProperty/SetProperty_SingleValue/SetProperty_SingleValue.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can set predefined properties (color, label, ...) of any widget. 19 | Read more: https://docs.blynk.io/en/blynk.edgent-firmware-api/widget-properties 20 | 21 | App dashboard setup: 22 | Gauge widget (0...100) on V0 23 | Slider widget (0...100) on V1 24 | *************************************************************/ 25 | 26 | /* Comment this out to disable prints and save space */ 27 | #define BLYNK_PRINT Serial 28 | 29 | /* Fill in information from Blynk Device Info here */ 30 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 31 | //#define BLYNK_TEMPLATE_NAME "Device" 32 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #define BLYNK_GREEN "#23C48E" 40 | #define BLYNK_BLUE "#04C0F8" 41 | #define BLYNK_YELLOW "#ED9D00" 42 | #define BLYNK_RED "#D3435C" 43 | #define BLYNK_DARK_BLUE "#5F7CD8" 44 | 45 | String gaugeColor; 46 | 47 | BLYNK_WRITE(V1) { 48 | int gaugeValue = param.asInt(); 49 | 50 | String newColor; 51 | if (gaugeValue > 80) { 52 | newColor = BLYNK_RED; 53 | } else if (gaugeValue > 50) { 54 | newColor = BLYNK_YELLOW; 55 | } else { 56 | newColor = BLYNK_GREEN; 57 | } 58 | 59 | // Send only if changed 60 | if (newColor != gaugeColor) { 61 | gaugeColor = newColor; 62 | Blynk.setProperty(V0, "color", gaugeColor); 63 | } 64 | 65 | Blynk.virtualWrite(V0, gaugeValue); 66 | } 67 | 68 | void setup() 69 | { 70 | // Debug console 71 | Serial.begin(9600); 72 | 73 | Blynk.begin(BLYNK_AUTH_TOKEN); 74 | } 75 | 76 | void loop() 77 | { 78 | Blynk.run(); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /examples/More/Stroboscope/Stroboscope.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This is a simple stroboscope. 19 | You can turn it on and of using a button, 20 | and control frequency with a slider. 21 | 22 | App dashboard setup: 23 | Button widget (Switch) on V1 24 | Slider widget (100...1000) on V2 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #define LED_PIN 4 41 | 42 | BlynkTimer timer; 43 | BlynkTimer::Handle t1; 44 | 45 | // Toggle LED 46 | void ledBlynk() 47 | { 48 | digitalWrite(LED_PIN, !digitalRead(LED_PIN)); 49 | } 50 | 51 | // Enable/disable blinking using virtual pin 1 52 | BLYNK_WRITE(V1) 53 | { 54 | if (param.asInt()) { 55 | t1.enable(); 56 | } else { 57 | t1.disable(); 58 | digitalWrite(LED_PIN, LOW); 59 | } 60 | } 61 | 62 | // Change blink interval using virtual pin 2 63 | BLYNK_WRITE(V2) 64 | { 65 | long interval = param.asLong(); 66 | t1.changeInterval(interval); 67 | } 68 | 69 | void setup() 70 | { 71 | // Debug console 72 | Serial.begin(9600); 73 | 74 | Blynk.begin(BLYNK_AUTH_TOKEN); 75 | 76 | // Configure LED and timer 77 | pinMode(LED_PIN, OUTPUT); 78 | t1 = timer.setInterval(500L, ledBlynk); 79 | t1.disable(); 80 | } 81 | 82 | void loop() 83 | { 84 | Blynk.run(); 85 | timer.run(); 86 | } 87 | 88 | -------------------------------------------------------------------------------- /examples/More/Sync/ButtonInterrupt/ButtonInterrupt.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to monitor a button state 19 | using interrupts mechanism. 20 | 21 | App dashboard setup: 22 | LED widget on V1 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | WidgetLED led1(V1); 39 | 40 | // We make these values volatile, as they are used in interrupt context 41 | volatile bool pinChanged = false; 42 | volatile int pinValue = 0; 43 | 44 | // Most boards won't send data to WiFi out of interrupt handler. 45 | // We just store the value and process it in the main loop. 46 | void checkPin() 47 | { 48 | // Invert state, since button is "Active LOW" 49 | pinValue = !digitalRead(2); 50 | 51 | // Mark pin value changed 52 | pinChanged = true; 53 | } 54 | 55 | void setup() 56 | { 57 | // Debug console 58 | Serial.begin(9600); 59 | 60 | Blynk.begin(BLYNK_AUTH_TOKEN); 61 | 62 | // Make pin 2 HIGH by default 63 | pinMode(2, INPUT_PULLUP); 64 | // Attach INT to our handler 65 | attachInterrupt(digitalPinToInterrupt(2), checkPin, CHANGE); 66 | } 67 | 68 | void loop() 69 | { 70 | Blynk.run(); 71 | 72 | if (pinChanged) { 73 | 74 | // Process the value 75 | if (pinValue) { 76 | led1.on(); 77 | } else { 78 | led1.off(); 79 | } 80 | 81 | // Clear the mark, as we have processed the value 82 | pinChanged = false; 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /examples/More/Sync/ButtonPoll/ButtonPoll.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to monitor a button state 19 | using polling mechanism. 20 | 21 | App dashboard setup: 22 | LED widget on V1 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int prevState = -1; 39 | int currState = -1; 40 | long lastChangeTime = 0; 41 | 42 | void checkPin() 43 | { 44 | // Invert state, since button is "Active LOW" 45 | int state = !digitalRead(2); 46 | 47 | // Debounce mechanism 48 | long t = millis(); 49 | if (state != prevState) { 50 | lastChangeTime = t; 51 | } 52 | if (t - lastChangeTime > 50) { 53 | if (state != currState) { 54 | currState = state; 55 | Blynk.virtualWrite(V1, state); 56 | } 57 | } 58 | prevState = state; 59 | } 60 | 61 | void setup() 62 | { 63 | // Debug console 64 | Serial.begin(9600); 65 | 66 | Blynk.begin(BLYNK_AUTH_TOKEN); 67 | 68 | // Make pin 2 default HIGH, and attach INT to our handler 69 | pinMode(2, INPUT_PULLUP); 70 | } 71 | 72 | void loop() 73 | { 74 | Blynk.run(); 75 | checkPin(); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /examples/More/Sync/HardwareSyncStateFromApp/HardwareSyncStateFromApp.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can synchronize the state of widgets with hardware states, 19 | even if hardware resets or looses connection temporarily 20 | 21 | App dashboard setup: 22 | Slider widget (0...1024) on V0 23 | Value display (0...1024) on V2 24 | Button widget on digital pin (connected to an LED) 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | // This function will run every time Blynk connection is established 41 | BLYNK_CONNECTED() { 42 | // Request Blynk server to re-send latest values for all pins 43 | Blynk.syncAll(); 44 | 45 | // You can also update individual virtual pins like this: 46 | //Blynk.syncVirtual(V0, V2); 47 | 48 | // Let's write your hardware uptime to Virtual Pin 2 49 | int value = millis() / 1000; 50 | Blynk.virtualWrite(V2, value); 51 | } 52 | 53 | BLYNK_WRITE(V0) 54 | { 55 | // Use of syncAll() will cause this function to be called 56 | // Parameter holds last slider value 57 | int sliderValue0 = param.asInt(); 58 | } 59 | 60 | BLYNK_WRITE(V2) 61 | { 62 | // You'll get uptime value here as result of syncAll() 63 | int uptime = param.asInt(); 64 | } 65 | 66 | void setup() 67 | { 68 | // Debug console 69 | Serial.begin(9600); 70 | 71 | Blynk.begin(BLYNK_AUTH_TOKEN); 72 | } 73 | 74 | void loop() 75 | { 76 | Blynk.run(); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /examples/Widgets/Joystick/Joystick.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | You can receive x and y coords for joystick movement within App. 19 | 20 | Datastream setup: 21 | Virtual Pin V0, type: String 22 | 23 | App dashboard setup: 24 | Add Joystick widget, select mode: Advanced, attach it V0 25 | 26 | NOTE: Advanced mode means device will receive both x and y on a single Datastream 27 | *************************************************************/ 28 | 29 | /* Comment this out to disable prints and save space */ 30 | #define BLYNK_PRINT Serial 31 | 32 | /* Fill in information from Blynk Device Info here */ 33 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 34 | //#define BLYNK_TEMPLATE_NAME "Device" 35 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | 42 | BLYNK_WRITE(V0) { 43 | int x = param[0].asInt(); 44 | int y = param[1].asInt(); 45 | 46 | // Do something with x and y 47 | Serial.print("X = "); 48 | Serial.print(x); 49 | Serial.print("; Y = "); 50 | Serial.println(y); 51 | } 52 | 53 | void setup() 54 | { 55 | // Debug console 56 | Serial.begin(9600); 57 | 58 | Blynk.begin(BLYNK_AUTH_TOKEN); 59 | } 60 | 61 | void loop() 62 | { 63 | Blynk.run(); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /examples/Widgets/LCD/LCD_AdvancedMode/LCD_AdvancedMode.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Output any data on LCD widget! 19 | 20 | Datastream setup: 21 | Virtual Pin V9, type: String 22 | 23 | App dashboard setup: 24 | LCD widget, switch to ADVANCED mode, attach it to V9 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | WidgetLCD lcd(V9); 41 | 42 | void setup() 43 | { 44 | // Debug console 45 | Serial.begin(9600); 46 | 47 | Blynk.begin(BLYNK_AUTH_TOKEN); 48 | 49 | lcd.clear(); //Use it to clear the LCD Widget 50 | lcd.print(4, 0, "Hello"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print") 51 | lcd.print(4, 1, "World"); 52 | // Please use timed events when LCD printintg in void loop to avoid sending too many commands 53 | // It will cause a FLOOD Error, and connection will be dropped 54 | } 55 | 56 | void loop() 57 | { 58 | Blynk.run(); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /examples/Widgets/LCD/LCD_SimpleMode/LCD_SimpleMode.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Output any data on LCD widget! 19 | 20 | Datastream setup: 21 | Virtual Pin V8, type: Integer, min: 0, max: 10000 22 | Virtual Pin V9, type: Integer, min: 0, max: 10000000 23 | 24 | App dashboard setup: 25 | LCD widget, SIMPLE mode. In Settings tab: 26 | - Attach V8 to first line 27 | - Attach V9 to second line 28 | Switch to Design tab: 29 | - Set first line message to: "/value1/ seconds" 30 | - Set second line message to: "/value2/ ms" 31 | *************************************************************/ 32 | 33 | /* Comment this out to disable prints and save space */ 34 | #define BLYNK_PRINT Serial 35 | 36 | /* Fill in information from Blynk Device Info here */ 37 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 38 | //#define BLYNK_TEMPLATE_NAME "Device" 39 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 40 | 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | BlynkTimer timer; 47 | 48 | void sendSeconds() { 49 | Blynk.virtualWrite(V8, millis() / 1000); 50 | } 51 | 52 | void sendMillis() { 53 | Blynk.virtualWrite(V9, millis()); 54 | } 55 | 56 | void setup() 57 | { 58 | // Debug console 59 | Serial.begin(9600); 60 | 61 | Blynk.begin(BLYNK_AUTH_TOKEN); 62 | 63 | // Setup a function to be called every second 64 | timer.setInterval(1000L, sendSeconds); 65 | // Setup a function to be called every second 66 | timer.setInterval(1000L, sendMillis); 67 | } 68 | 69 | void loop() 70 | { 71 | Blynk.run(); 72 | timer.run(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /examples/Widgets/LED/LED_Blink/LED_Blink.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Blynk using a LED widget on your phone! 19 | 20 | Datastream setup: 21 | Virtual Pin V3, type: Integer, min: 0, max: 255 22 | 23 | App/Web dashboard setup: 24 | LED widget on V3 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | WidgetLED led1(V3); 41 | 42 | BlynkTimer timer; 43 | 44 | // V3 LED Widget is blinking 45 | void blinkLedWidget() 46 | { 47 | if (led1.getValue()) { 48 | led1.off(); 49 | Serial.println("LED on V3: off"); 50 | } else { 51 | led1.on(); 52 | Serial.println("LED on V3: on"); 53 | } 54 | } 55 | 56 | void setup() 57 | { 58 | // Debug console 59 | Serial.begin(9600); 60 | 61 | Blynk.begin(BLYNK_AUTH_TOKEN); 62 | 63 | timer.setInterval(1000L, blinkLedWidget); 64 | } 65 | 66 | void loop() 67 | { 68 | Blynk.run(); 69 | timer.run(); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /examples/Widgets/LED/LED_Color/LED_Color.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Blynk using a LED widget on your phone! 19 | 20 | Datastream setup: 21 | Virtual Pin V3, type: Integer, min: 0, max: 255 22 | 23 | App/Web dashboard setup: 24 | LED widget on V3 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | WidgetLED led1(V3); 41 | 42 | BlynkTimer timer; 43 | bool ledStatus = false; 44 | 45 | #define BLYNK_GREEN "#23C48E" 46 | #define BLYNK_BLUE "#04C0F8" 47 | #define BLYNK_YELLOW "#ED9D00" 48 | #define BLYNK_RED "#D3435C" 49 | #define BLYNK_DARK_BLUE "#5F7CD8" 50 | 51 | BLYNK_CONNECTED() { 52 | // Turn LED on, so colors are visible 53 | led1.on(); 54 | } 55 | 56 | // V3 LED Widget is blinking 57 | void blinkLedWidget() 58 | { 59 | if (ledStatus) { 60 | led1.setColor(BLYNK_RED); 61 | Serial.println("LED on V3: red"); 62 | ledStatus = false; 63 | } else { 64 | led1.setColor(BLYNK_GREEN); 65 | Serial.println("LED on V3: green"); 66 | ledStatus = true; 67 | } 68 | } 69 | 70 | void setup() 71 | { 72 | // Debug console 73 | Serial.begin(9600); 74 | 75 | Blynk.begin(BLYNK_AUTH_TOKEN); 76 | 77 | // Setup periodic color change 78 | timer.setInterval(1000L, blinkLedWidget); 79 | } 80 | 81 | void loop() 82 | { 83 | Blynk.run(); 84 | timer.run(); 85 | } 86 | 87 | -------------------------------------------------------------------------------- /examples/Widgets/LED/LED_Fade/LED_Fade.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Fade using a LED widget on your phone! 19 | 20 | Datastream setup: 21 | Virtual Pin V3, type: Integer, min: 0, max: 255 22 | 23 | App/Web dashboard setup: 24 | LED widget on V3 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | WidgetLED led1(V3); 41 | 42 | BlynkTimer timer; 43 | 44 | // V3 LED Widget is fading 45 | void fadeLedWidget() 46 | { 47 | static int value = 0; 48 | static int delta = 30; 49 | value += delta; 50 | if (value > 255 || value < 0) { 51 | delta = -delta; 52 | } else { 53 | Serial.print("LED on V3: "); 54 | Serial.println(value); 55 | led1.setValue(value); 56 | } 57 | } 58 | 59 | void setup() 60 | { 61 | // Debug console 62 | Serial.begin(9600); 63 | 64 | Blynk.begin(BLYNK_AUTH_TOKEN); 65 | 66 | timer.setInterval(300L, fadeLedWidget); 67 | } 68 | 69 | void loop() 70 | { 71 | Blynk.run(); 72 | timer.run(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /examples/Widgets/LED/LED_StatusOfButton/LED_StatusOfButton.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Blynk using a LED widget on your phone! 19 | 20 | Datastream setup: 21 | Virtual Pin V3, type: Integer, min: 0, max: 255 22 | 23 | App/Web dashboard setup: 24 | LED widget on V3 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | // Select your pin with physical button 41 | const int btnPin = 4; 42 | 43 | WidgetLED led1(V3); 44 | 45 | BlynkTimer timer; 46 | 47 | // V3 LED Widget represents the physical button state 48 | boolean btnState = false; 49 | void buttonLedWidget() 50 | { 51 | // Read button 52 | boolean isPressed = (digitalRead(btnPin) == LOW); 53 | 54 | // If state has changed... 55 | if (isPressed != btnState) { 56 | if (isPressed) { 57 | led1.on(); 58 | } else { 59 | led1.off(); 60 | } 61 | btnState = isPressed; 62 | } 63 | } 64 | 65 | void setup() 66 | { 67 | // Debug console 68 | Serial.begin(9600); 69 | 70 | Blynk.begin(BLYNK_AUTH_TOKEN); 71 | 72 | // Setup physical button pin (active low) 73 | pinMode(btnPin, INPUT_PULLUP); 74 | 75 | timer.setInterval(500L, buttonLedWidget); 76 | } 77 | 78 | void loop() 79 | { 80 | Blynk.run(); 81 | timer.run(); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /examples/Widgets/Map/Map.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Output any data on Map widget! 19 | 20 | Datastream setup: 21 | Virtual Pin V6, type: String 22 | 23 | App dashboard setup: 24 | Map widget on V6 25 | 26 | NOTE: This is for the App Map widget only. 27 | The Web Dashboard has different functionality. Read More: 28 | https://docs.blynk.io/en/blynk.console/widgets-console/map 29 | *************************************************************/ 30 | 31 | /* Comment this out to disable prints and save space */ 32 | #define BLYNK_PRINT Serial 33 | 34 | /* Fill in information from Blynk Device Info here */ 35 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 36 | //#define BLYNK_TEMPLATE_NAME "Device" 37 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 38 | 39 | 40 | #include 41 | #include 42 | #include 43 | 44 | WidgetMap myMap(V6); 45 | 46 | void setup() 47 | { 48 | // Debug console 49 | Serial.begin(9600); 50 | 51 | Blynk.begin(BLYNK_AUTH_TOKEN); 52 | 53 | // If you want to remove all points: 54 | //myMap.clear(); 55 | 56 | int index = 0; 57 | double lat = 50.4495378; 58 | double lon = 30.5251447; 59 | myMap.location(index, lat, lon, "Monument of Independence"); 60 | } 61 | 62 | void loop() 63 | { 64 | Blynk.run(); 65 | } 66 | 67 | -------------------------------------------------------------------------------- /examples/Widgets/Menu/Menu.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how to use the Menu Widget. 19 | 20 | Datastream setup: 21 | Virtual Pin V1, type: Integer, min: 1, max: 3 22 | 23 | App/Web dashboard setup: 24 | Menu widget attached to V1 (put 3 items in it) 25 | 26 | For Integer DS, pay attention to the Datastream range. 27 | Apps automatically assign values to the menu items, 28 | starting with the minimal datastream value. 29 | It's also possible to use Enum datastreams. 30 | *************************************************************/ 31 | 32 | /* Comment this out to disable prints and save space */ 33 | #define BLYNK_PRINT Serial 34 | 35 | /* Fill in information from Blynk Device Info here */ 36 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 37 | //#define BLYNK_TEMPLATE_NAME "Device" 38 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 39 | 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | BLYNK_WRITE(V1) { 46 | switch (param.asInt()) 47 | { 48 | case 1: // Item 1 49 | Serial.println("Item 1 selected"); 50 | break; 51 | case 2: // Item 2 52 | Serial.println("Item 2 selected"); 53 | break; 54 | case 3: // Item 3 55 | Serial.println("Item 3 selected"); 56 | break; 57 | default: 58 | Serial.println("Unknown item selected"); 59 | } 60 | } 61 | 62 | void setup() 63 | { 64 | // Debug console 65 | Serial.begin(9600); 66 | 67 | Blynk.begin(BLYNK_AUTH_TOKEN); 68 | } 69 | 70 | void loop() 71 | { 72 | Blynk.run(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /examples/Widgets/MusicPlayer/MusicPlayer.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | This example shows how you can process commands from player widget 19 | 20 | Datastream setup: 21 | Virtual Pin V5, type: String 22 | 23 | App dashboard setup: 24 | Music Player widget on V5 25 | *************************************************************/ 26 | 27 | /* Comment this out to disable prints and save space */ 28 | #define BLYNK_PRINT Serial 29 | 30 | /* Fill in information from Blynk Device Info here */ 31 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 32 | //#define BLYNK_TEMPLATE_NAME "Device" 33 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 34 | 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | BLYNK_WRITE(V5) 41 | { 42 | String action = param.asStr(); 43 | 44 | if (action == "play") { 45 | // Do something 46 | } 47 | if (action == "stop") { 48 | // Do something 49 | } 50 | if (action == "next") { 51 | // Do something 52 | } 53 | if (action == "prev") { 54 | // Do something 55 | } 56 | 57 | Blynk.setProperty(V5, "label", action); 58 | Serial.print(action); 59 | Serial.println(); 60 | } 61 | 62 | void setup() 63 | { 64 | // Debug console 65 | Serial.begin(9600); 66 | 67 | Blynk.begin(BLYNK_AUTH_TOKEN); 68 | } 69 | 70 | void loop() 71 | { 72 | Blynk.run(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /examples/Widgets/TimeInput/SimpleTimeInput/SimpleTimeInput.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Datastream setup: 19 | Virtual Pin V1, type: String 20 | 21 | App dashboard setup: 22 | Time Input widget on V1 with only start time option 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | BLYNK_WRITE(V1) { 39 | long startTimeInSecs = param[0].asLong(); 40 | Serial.println(startTimeInSecs); 41 | Serial.println(); 42 | } 43 | 44 | void setup() 45 | { 46 | // Debug console 47 | Serial.begin(9600); 48 | 49 | Blynk.begin(BLYNK_AUTH_TOKEN); 50 | } 51 | 52 | void loop() 53 | { 54 | Blynk.run(); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /examples/Widgets/TimeInput/UpdateTimeInputState/UpdateTimeInputState.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Blynk is a platform with iOS and Android apps to control 3 | ESP32, Arduino, Raspberry Pi and the likes over the Internet. 4 | You can easily build mobile and web interfaces for any 5 | projects by simply dragging and dropping widgets. 6 | 7 | Downloads, docs, tutorials: https://www.blynk.io 8 | Sketch generator: https://examples.blynk.cc 9 | Blynk community: https://community.blynk.cc 10 | Follow us: https://www.fb.com/blynkapp 11 | https://twitter.com/blynk_app 12 | 13 | Blynk library is licensed under MIT license 14 | This example code is in public domain. 15 | 16 | ************************************************************* 17 | 18 | Datastream setup: 19 | Virtual Pin V1, type: String 20 | 21 | App dashboard setup: 22 | Time Input widget on V1 23 | *************************************************************/ 24 | 25 | /* Comment this out to disable prints and save space */ 26 | #define BLYNK_PRINT Serial 27 | 28 | /* Fill in information from Blynk Device Info here */ 29 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 30 | //#define BLYNK_TEMPLATE_NAME "Device" 31 | //#define BLYNK_AUTH_TOKEN "YourAuthToken" 32 | 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | void setup() 39 | { 40 | // Debug console 41 | Serial.begin(9600); 42 | 43 | Blynk.begin(BLYNK_AUTH_TOKEN); 44 | } 45 | 46 | //as soon as connected update TimeInput widget state 47 | BLYNK_CONNECTED() { 48 | //seconds from the start of a day. 0 - min, 86399 - max 49 | int startAt = 5 * 60; //00:05 50 | 51 | //seconds from the start of a day. 0 - min, 86399 - max 52 | int stopAt = (60 + 5) * 60; //01:05 53 | 54 | //timezone 55 | //full list of supported timezones could be found here 56 | //https://www.mkyong.com/java/java-display-list-of-timezone-with-gmt/ 57 | char tz[] = "Europe/Kiev"; 58 | 59 | Blynk.virtualWrite(V1, startAt, stopAt, tz); 60 | 61 | //you may also pass day 62 | //char days[] = "1"; //Monday 63 | //Blynk.virtualWrite(V1, startAt, stopAt, tz, days); 64 | 65 | //or days 66 | //char days[] = "1,2,3"; //Monday, Tuesday, Wednesday 67 | //Blynk.virtualWrite(V1, startAt, stopAt, tz, days); 68 | } 69 | 70 | void loop() 71 | { 72 | Blynk.run(); 73 | } 74 | 75 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Blynk", 3 | "version": "1.3.2", 4 | "description": "Build a smartphone app for your project in minutes. Blynk allows creating IoT solutions easily. It supports WiFi, Ethernet, Cellular connectivity. Works with over 400 boards like ESP8266, ESP32, Arduino, Raspberry Pi, Particle, etc.", 5 | "keywords": "sensors, control, device, smartphone, mobile, app, web, cloud, communication, protocol, iot, m2m, wifi, ble, bluetooth, ethernet, usb, serial, gsm, gprs, 3g, data, esp8266, http", 6 | "authors": [ 7 | { 8 | "name": "Blynk", 9 | "url": "https://github.com/blynkkk" 10 | }, 11 | { 12 | "name": "Volodymyr Shymanskyy", 13 | "url": "https://github.com/vshymanskyy", 14 | "maintainer": true 15 | } 16 | ], 17 | "repository": 18 | { 19 | "type": "git", 20 | "url": "https://github.com/blynkkk/blynk-library.git" 21 | }, 22 | "homepage": "https://blynk.io", 23 | "export": { 24 | "exclude": [ 25 | "linux", 26 | "extras", 27 | "tests" 28 | ] 29 | }, 30 | "dependencies": { 31 | "blynkkk/BlynkNcpDriver": "^0.6.3" 32 | }, 33 | "frameworks": "*", 34 | "platforms": "*", 35 | "examples": "examples/*/*/*.ino" 36 | } 37 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Blynk 2 | version=1.3.2 3 | author=Blynk 4 | license=MIT 5 | maintainer=Volodymyr Shymanskyy 6 | sentence=Build a smartphone app for your project in minutes! 7 | paragraph=It supports WiFi, Ethernet, Cellular connectivity. Works with over 400 boards like ESP8266, ESP32, Arduino, Raspberry Pi, Particle, etc. 8 | category=Communication 9 | url=https://blynk.io 10 | architectures=* 11 | includes=Blynk.h 12 | depends=BlynkNcpDriver 13 | -------------------------------------------------------------------------------- /linux/BlynkOptionsParser.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | static 6 | void parse_options(int argc, char* argv[], 7 | const char*& auth, 8 | const char*& serv, 9 | uint16_t& port) 10 | { 11 | static struct option long_options[] = { 12 | {"token", required_argument, 0, 't'}, 13 | {"server", required_argument, 0, 's'}, 14 | {"port", required_argument, 0, 'p'}, 15 | {0, 0, 0, 0} 16 | }; 17 | 18 | // Set default values 19 | auth = NULL; 20 | serv = BLYNK_DEFAULT_DOMAIN; 21 | port = BLYNK_DEFAULT_PORT; 22 | 23 | const char* usage = 24 | "Usage: blynk [options]\n" 25 | "\n" 26 | "Options:\n" 27 | " -t auth, --token=auth Your auth token\n" 28 | " -s addr, --server=addr Server name (default: " BLYNK_DEFAULT_DOMAIN ")\n" 29 | " -p num, --port=num Server port (default: " BLYNK_TOSTRING(BLYNK_DEFAULT_PORT) ")\n" 30 | "\n"; 31 | 32 | int rez; 33 | while (-1 != (rez = getopt_long(argc, argv,"t:s:p:", long_options, NULL))) { 34 | switch (rez) { 35 | case 't': auth = optarg; break; 36 | case 's': serv = optarg; break; 37 | case 'p': port = atoi(optarg); break; 38 | default : printf(usage); exit(1); 39 | }; 40 | }; 41 | 42 | // Check mandatory options 43 | if (!auth) { 44 | printf(usage); 45 | exit(1); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /linux/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # To build on RaspberryPi: 3 | # 1. Install WiringPi: http://wiringpi.com/download-and-install/ 4 | # 2. Run: 5 | # make target=raspberry 6 | # sudo blynk --token=YourAuthToken 7 | # 8 | 9 | CC ?= gcc 10 | CXX ?= g++ 11 | CXXFLAGS += -I ../src/ -I ./ -DLINUX 12 | LDFLAGS += -lrt -lpthread 13 | 14 | ifeq ($(build),debug) 15 | CXXFLAGS += -c -g2 -O0 \ 16 | -Wall -Weffc++ \ 17 | -Wextra -Wcast-align \ 18 | -Wchar-subscripts -Wcomment -Wconversion \ 19 | -Wdisabled-optimization \ 20 | -Wfloat-equal -Wformat -Wformat=2 \ 21 | -Wformat-nonliteral -Wformat-security \ 22 | -Wformat-y2k \ 23 | -Wimplicit -Wimport -Winit-self -Winline \ 24 | -Winvalid-pch \ 25 | -Wunsafe-loop-optimizations -Wlong-long -Wmissing-braces \ 26 | -Wmissing-field-initializers -Wmissing-format-attribute \ 27 | -Wmissing-include-dirs -Wmissing-noreturn \ 28 | -Wpacked -Wparentheses -Wpointer-arith \ 29 | -Wredundant-decls -Wreturn-type \ 30 | -Wsequence-point -Wshadow -Wsign-compare -Wstack-protector \ 31 | -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default \ 32 | -Wswitch-enum -Wtrigraphs -Wuninitialized \ 33 | -Wunknown-pragmas -Wunreachable-code -Wunused \ 34 | -Wunused-function -Wunused-label \ 35 | -Wunused-value -Wunused-variable \ 36 | -Wvolatile-register-var -Wwrite-strings 37 | 38 | # Disable some warnings 39 | CXXFLAGS += -Wno-variadic-macros -Wno-unused-parameter -Wno-vla 40 | 41 | # Uncomment this to get pedantic warnings: 42 | #CXXFLAGS += -pedantic -Wvariadic-macros -Wunused-parameter -Waggregate-return -Wcast-qual -Wpadded 43 | else 44 | CXXFLAGS += -c -O3 -w 45 | LDFLAGS += -s 46 | endif 47 | 48 | ifeq ($(target),raspberry) 49 | CXXFLAGS += -DRASPBERRY 50 | LDFLAGS += -lwiringPi 51 | endif 52 | 53 | SOURCES=main.cpp \ 54 | ../src/utility/BlynkDebug.cpp \ 55 | ../src/utility/BlynkHandlers.cpp \ 56 | ../src/utility/BlynkTimer.cpp 57 | 58 | OBJECTS=$(SOURCES:.cpp=.o) 59 | EXECUTABLE=blynk 60 | 61 | all: $(SOURCES) $(EXECUTABLE) 62 | 63 | clean: 64 | -rm $(OBJECTS) $(EXECUTABLE) 65 | 66 | $(EXECUTABLE): $(OBJECTS) 67 | $(CXX) $(OBJECTS) $(LDFLAGS) -o $@ 68 | 69 | .cpp.o: 70 | $(CXX) $(CXXFLAGS) $< -o $@ 71 | -------------------------------------------------------------------------------- /linux/README.md: -------------------------------------------------------------------------------- 1 | # Linux Quick Start Guide (Ubuntu, Raspberry Pi, ...) 2 | 3 | 0. Connect your Raspberry Pi to the internet and open it's console. ^_^ 4 | 5 | 1. Install WiringPi: 6 | http://wiringpi.com/download-and-install/ 7 | 8 | 2. Download and build Blynk: 9 | ```bash 10 | $ git clone https://github.com/blynkkk/blynk-library.git 11 | $ cd blynk-library/linux 12 | $ make clean all target=raspberry 13 | ``` 14 | 15 | 3. Run Blynk: 16 | ```bash 17 | $ sudo ./blynk --token=YourAuthToken 18 | ``` 19 | 20 | We have also provided a build script, you can try just running (inside of the "linux" directory): 21 | 22 | ```bash 23 | $ ./build.sh raspberry 24 | ``` 25 | -------------------------------------------------------------------------------- /linux/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | case "$1" in 4 | raspberry) 5 | sudo apt-get update 6 | sudo apt-get upgrade 7 | sudo apt-get install build-essential git-core 8 | git clone git://git.drogon.net/wiringPi 9 | cd wiringPi 10 | git pull origin 11 | ./build 12 | gpio -v 13 | cd .. 14 | make clean all target=raspberry 15 | exit 0 16 | ;; 17 | linux) 18 | make clean all 19 | exit 0 20 | ;; 21 | esac 22 | 23 | echo "Please specify platform: raspberry, linux" 24 | exit 1 25 | -------------------------------------------------------------------------------- /linux/main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file main.cpp 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | */ 9 | 10 | /* Fill in information from your Blynk Template here */ 11 | //#define BLYNK_TEMPLATE_ID "TMPxxxxxx" 12 | //#define BLYNK_TEMPLATE_NAME "Device" 13 | 14 | #define BLYNK_FIRMWARE_VERSION "0.1.0" 15 | 16 | //#define BLYNK_DEBUG 17 | #define BLYNK_PRINT stdout 18 | #ifdef RASPBERRY 19 | #include 20 | #else 21 | #include 22 | #endif 23 | #include 24 | #include 25 | 26 | static BlynkTransportSocket _blynkTransport; 27 | BlynkSocket Blynk(_blynkTransport); 28 | 29 | static const char *auth, *serv; 30 | static uint16_t port; 31 | 32 | #include 33 | 34 | BlynkTimer tmr; 35 | 36 | BLYNK_WRITE(V1) 37 | { 38 | printf("Got a value: %s\n", param[0].asStr()); 39 | } 40 | 41 | void setup() 42 | { 43 | Blynk.begin(auth, serv, port); 44 | tmr.setInterval(1000, [](){ 45 | Blynk.virtualWrite(V0, BlynkMillis()/1000); 46 | }); 47 | } 48 | 49 | void loop() 50 | { 51 | Blynk.run(); 52 | tmr.run(); 53 | } 54 | 55 | 56 | int main(int argc, char* argv[]) 57 | { 58 | parse_options(argc, argv, auth, serv, port); 59 | 60 | setup(); 61 | while(true) { 62 | loop(); 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blynkkk/blynk-library/4328597e39de20c7c181bff5c4ee75bf697ca637/scripts/README.md -------------------------------------------------------------------------------- /scripts/blynk-ser.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | 4 | REM === Edit these lines to match your need === 5 | 6 | set COMM_PORT=COM1 7 | set COMM_BAUD=9600 8 | set SERV_ADDR=blynk.cloud 9 | set SERV_PORT=80 10 | 11 | REM === Edit lines below only if absolutely sure what you're doing === 12 | 13 | rem Get command line options 14 | set SCRIPTS_PATH=%~dp0 15 | 16 | :loop 17 | IF NOT "%1"=="" ( 18 | IF "%1"=="-c" set COMM_PORT=%2& SHIFT & SHIFT & GOTO :loop 19 | IF "%1"=="-b" set COMM_BAUD=%2& SHIFT & SHIFT & GOTO :loop 20 | IF "%1"=="-s" set SERV_ADDR=%2& SHIFT & SHIFT & GOTO :loop 21 | IF "%1"=="-p" set SERV_PORT=%2& SHIFT & SHIFT & GOTO :loop 22 | 23 | CALL :usage 24 | GOTO :eof 25 | ) 26 | 27 | rem Find ports 28 | set PORTS= 29 | for /f "tokens=4 delims=: " %%A in ('mode^|findstr "COM[0-9]*:"') do IF not [%%A] == [] set PORTS=!PORTS! %%A 30 | set PORTS=!PORTS:~1! 31 | 32 | rem Check port 33 | rem Skip check if no ports at all - Windows bug? 34 | if not "x%PORTS%"=="x~1" ( 35 | if "x!PORTS:%COMM_PORT%=!"=="x%PORTS%" ( 36 | echo %COMM_PORT% not found, or may be busy. 37 | set /p COMM_PORT="Select serial port [ %PORTS% ]: " 38 | ) 39 | ) 40 | 41 | rem Create exe 42 | if not exist "%SCRIPTS_PATH%\com2tcp.exe" ( 43 | copy "%SCRIPTS_PATH%\com2tcp.bin" "%SCRIPTS_PATH%\com2tcp.exe" > NUL 44 | ) 45 | 46 | rem Do the job 47 | echo Connecting device at %COMM_PORT% to %SERV_ADDR%:%SERV_PORT%... 48 | 49 | rem Try resetting board 50 | rem mode %COMM_PORT%:%COMM_BAUD%,N,8,1 >nul 51 | 52 | :restart 53 | "%SCRIPTS_PATH%\com2tcp.exe" --baud %COMM_BAUD% --ignore-dsr \\.\%COMM_PORT% %SERV_ADDR% %SERV_PORT% 54 | echo Reconnecting in 3s... 55 | timeout /T 3 56 | goto restart 57 | 58 | 59 | goto:eof 60 | 61 | :usage 62 | echo. 63 | echo. This script redirects serial communication to the server. 64 | echo. 65 | echo. You can specify port, baud rate, and server endpoint like this: 66 | echo. blynk-ser.bat -c ^ -b ^ -s ^ -p ^ 67 | echo. 68 | echo. The defaults are: 69 | echo. -c /dev/ttyUSB0 (on Linux) 70 | echo. COM1 (on Windows) 71 | echo. /dev/tty.usbserial (on OSX) 72 | echo. -b 9600 73 | echo. -s blynk.cloud 74 | echo. -p 80 75 | echo. 76 | echo. If the specified serial port is not found, it will ask to enter another one. 77 | echo. The script also tries to reestablish connection if it was lost. 78 | goto:eof 79 | -------------------------------------------------------------------------------- /scripts/certs/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID5TCCAs2gAwIBAgIJAIHSnb+cv4ECMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYD 3 | VQQGEwJVQTENMAsGA1UECAwES3lpdjENMAsGA1UEBwwES3lpdjELMAkGA1UECgwC 4 | SVQxEzARBgNVBAsMCkJseW5rIEluYy4xGDAWBgNVBAMMD2JseW5rLWNsb3VkLmNv 5 | bTEfMB0GCSqGSIb3DQEJARYQZG1pdHJpeUBibHluay5jYzAeFw0xNjAzMTcxMTU4 6 | MDdaFw0yMTAzMTYxMTU4MDdaMIGIMQswCQYDVQQGEwJVQTENMAsGA1UECAwES3lp 7 | djENMAsGA1UEBwwES3lpdjELMAkGA1UECgwCSVQxEzARBgNVBAsMCkJseW5rIElu 8 | Yy4xGDAWBgNVBAMMD2JseW5rLWNsb3VkLmNvbTEfMB0GCSqGSIb3DQEJARYQZG1p 9 | dHJpeUBibHluay5jYzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALso 10 | bhbXQuNlzYBFa9h9pd69n43yrGTL4Ba6k5Q1zDwY9HQbMdfC5ZfnCkqT7Zf+R5MO 11 | RW0Q9nLsFNLJkwKnluRCYGyUES8NAmDLQBbZoVc8mv9K3mIgAQvGyY2LmKak5GSI 12 | V0PC3x+iN03xU2774+Zi7DaQd7vTl/9RGk8McyHe/s5Ikbe14bzWcY9ZV4PKgCck 13 | p1chbmLhSfGbT3v64sL8ZbIppQk57/JgsZMrVpjExvxQPZuJfWbtoypPfpYO+O8l 14 | 1szaMlTEPIZVMoYi9uE+DnOlhzJFn6Ac4FMrDzJXzMmCweSX3IxguvXALeKhUHQJ 15 | +VP3G6Q3pkZRVKz+5XsCAwEAAaNQME4wHQYDVR0OBBYEFJtqtI62Io66cZgiTR5L 16 | A5Tl5m+xMB8GA1UdIwQYMBaAFJtqtI62Io66cZgiTR5LA5Tl5m+xMAwGA1UdEwQF 17 | MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAKphjtEOGs7oC3S87+AUgIw4gFNOuv+L 18 | C98/l47OD6WtsqJKvCZ1lmKxY5aIro9FBPk8ktCOsbwEjE+nyr5wul+6CLFr+rnv 19 | 7OHYGwLpjoz+rZgYJiQ61E1m0AZ4y9Fyd+D90HW6247vrBXyEiUXOhN/oDDVfDQA 20 | eqmNBx1OqWel81D3tA7zPMA7vUItyWcFIXNjOCP+POy7TMxZuhuPMh5bVu+/cthl 21 | /Q9u/Z2lKl4CWV0Ivt2BtlN6iefva0e2AP/As+gfwjxrb0t11zSILLNJ+nxRIwg+ 22 | k4MGb1zihKbIXUzsjslONK4FY5rlQUSwKJgEAVF0ClxB4g6dECm0ckc= 23 | -----END CERTIFICATE----- 24 | -------------------------------------------------------------------------------- /scripts/com2tcp.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blynkkk/blynk-library/4328597e39de20c7c181bff5c4ee75bf697ca637/scripts/com2tcp.bin -------------------------------------------------------------------------------- /src/Adapters/BlynkArduinoNB.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkArduinoNB.h 3 | * @author Riccardo Rizzo 4 | * @license This project is released under the MIT License (MIT) 5 | * @date Dec 2018 6 | * @brief 7 | * 8 | */ 9 | 10 | #ifndef BlynkArduinoNB_h 11 | #define BlynkArduinoNB_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "MKRNB" 15 | #endif 16 | 17 | #ifndef BLYNK_HEARTBEAT 18 | #define BLYNK_HEARTBEAT 60 19 | #endif 20 | 21 | #ifndef BLYNK_TIMEOUT_MS 22 | #define BLYNK_TIMEOUT_MS 6000 23 | #endif 24 | 25 | #define BLYNK_SEND_ATOMIC 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class BlynkSIM 33 | : public BlynkProtocol 34 | { 35 | typedef BlynkProtocol Base; 36 | public: 37 | BlynkSIM(BlynkArduinoClient& transp) 38 | : Base(transp) 39 | {} 40 | 41 | bool connectNetwork(NB& modem, GPRS& gprs, const char* pin) 42 | { 43 | BLYNK_LOG1(BLYNK_F("Modem init...")); 44 | if (!modem.begin(pin)) { 45 | BLYNK_FATAL(BLYNK_F("Cannot init")); 46 | return false; 47 | } 48 | 49 | BLYNK_LOG3(BLYNK_F("Connecting to "),"", BLYNK_F(" ...")); 50 | if (!gprs.attachGPRS()) { 51 | BLYNK_FATAL(BLYNK_F("Connect GPRS failed")); 52 | return false; 53 | } 54 | 55 | BLYNK_LOG1(BLYNK_F("Connected to GPRS")); 56 | return true; 57 | } 58 | 59 | void config(NB& nb, 60 | GPRS& gprs, 61 | NBClient& nbclient, 62 | const char* auth, 63 | const char* domain = BLYNK_DEFAULT_DOMAIN, 64 | uint16_t port = BLYNK_DEFAULT_PORT) 65 | { 66 | Base::begin(auth); 67 | modem = &nb; 68 | modemGPRS = &gprs; 69 | 70 | this->conn.setClient(&nbclient); 71 | this->conn.begin(domain, port); 72 | } 73 | 74 | void begin(const char* auth, 75 | NB& nb, 76 | GPRS& gprs, 77 | NBClient& nbclient, 78 | const char* pin, 79 | const char* domain = BLYNK_DEFAULT_DOMAIN, 80 | uint16_t port = BLYNK_DEFAULT_PORT) 81 | { 82 | config(nb, gprs, nbclient, auth, domain, port); 83 | connectNetwork(nb, gprs, pin); 84 | while(this->connect() != true) {} 85 | } 86 | 87 | private: 88 | NB* modem; 89 | GPRS* modemGPRS; 90 | NBClient* nbclient; 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/Adapters/BlynkSerial.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSerial.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkStream_h 12 | #define BlynkStream_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "Serial" 16 | #endif 17 | 18 | #ifdef PARTICLE 19 | #include 20 | #else 21 | #include 22 | #endif 23 | #include 24 | 25 | class BlynkTransportStream 26 | { 27 | public: 28 | BlynkTransportStream() 29 | : stream(NULL), conn(0) 30 | {} 31 | 32 | // IP redirect not available 33 | void begin(char BLYNK_UNUSED *h, uint16_t BLYNK_UNUSED p) {} 34 | 35 | void begin(Stream& s) { 36 | stream = &s; 37 | } 38 | 39 | bool connect() { 40 | BLYNK_LOG1(BLYNK_F("Connecting...")); 41 | stream->flush(); 42 | return conn = true; 43 | } 44 | void disconnect() { conn = false; } 45 | 46 | size_t read(void* buf, size_t len) { 47 | char* beg = (char*)buf; 48 | char* end = beg + len; 49 | millis_time_t startMillis = BlynkMillis(); 50 | while ((beg < end) && (BlynkMillis() - startMillis < BLYNK_TIMEOUT_MS)) { 51 | int c = stream->read(); 52 | if (c < 0) 53 | continue; 54 | *beg++ = (char)c; 55 | } 56 | return beg-(char*)buf; 57 | } 58 | size_t write(const void* buf, size_t len) { 59 | stream->write((const uint8_t*)buf, len); 60 | return len; 61 | } 62 | 63 | bool connected() { return conn; } 64 | int available() { return stream->available(); } 65 | 66 | protected: 67 | Stream* stream; 68 | bool conn; 69 | }; 70 | 71 | class BlynkStream 72 | : public BlynkProtocol 73 | { 74 | typedef BlynkProtocol Base; 75 | public: 76 | BlynkStream(BlynkTransportStream& transp) 77 | : Base(transp) 78 | {} 79 | 80 | void config(Stream& stream, 81 | const char* auth) 82 | { 83 | Base::begin(auth); 84 | this->conn.begin(stream); 85 | } 86 | 87 | void begin(Stream& stream, const char* auth) { 88 | config(stream, auth); 89 | while(this->connect() != true) {} 90 | } 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/Blynk.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file Blynk.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Nov 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef Blynk_h 12 | #define Blynk_h 13 | 14 | #include 15 | #warning "Please include a board-specific header file, instead of Blynk.h (see examples)" 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/Blynk/BlynkEveryN.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef BLYNKEVERYN_H 3 | #define BLYNKEVERYN_H 4 | 5 | #include 6 | 7 | millis_time_t blynk_count_millis() { 8 | const millis_time_t ms = BlynkMillis(); 9 | return ms; 10 | } 11 | 12 | uint16_t blynk_count_seconds16() { 13 | const millis_time_t ms = BlynkMillis(); 14 | return (ms / 1000); 15 | } 16 | 17 | uint16_t blynk_count_minutes16() 18 | { 19 | const millis_time_t ms = BlynkMillis(); 20 | return (ms / (60000L)) & 0xFFFF; 21 | } 22 | 23 | uint8_t blynk_count_hours8() 24 | { 25 | const millis_time_t ms = BlynkMillis(); 26 | return (ms / (3600000L)) & 0xFF; 27 | } 28 | 29 | template 30 | class BlynkPeriodic { 31 | public: 32 | T mPrev; 33 | T mPeriod; 34 | 35 | BlynkPeriodic() { reset(); mPeriod = 1; }; 36 | BlynkPeriodic(T period) { reset(); setPeriod(period); }; 37 | void setPeriod( T period) { mPeriod = period; }; 38 | T getTime() { return (T)(timeGetter()); }; 39 | T getPeriod() { return mPeriod; }; 40 | T getElapsed() { return getTime() - mPrev; } 41 | T getRemaining() { return mPeriod - getElapsed(); } 42 | T getLastTriggerTime() { return mPrev; } 43 | bool ready() { 44 | bool isReady = (getElapsed() >= mPeriod); 45 | if( isReady ) { reset(); } 46 | return isReady; 47 | } 48 | void reset() { mPrev = getTime(); }; 49 | void trigger() { mPrev = getTime() - mPeriod; }; 50 | 51 | operator bool() { return ready(); } 52 | }; 53 | 54 | typedef BlynkPeriodic BlynkEveryNMillis; 55 | typedef BlynkPeriodic BlynkEveryNSeconds; 56 | typedef BlynkPeriodic BlynkEveryNMinutes; 57 | typedef BlynkPeriodic BlynkEveryNHours; 58 | 59 | #define BLYNK_EVERY_N_MILLIS_I(NAME,N) static BlynkEveryNMillis NAME(N); if(NAME) 60 | #define BLYNK_EVERY_N_SECONDS_I(NAME,N) static BlynkEveryNSeconds NAME(N); if(NAME) 61 | #define BLYNK_EVERY_N_MINUTES_I(NAME,N) static BlynkEveryNMinutes NAME(N); if(NAME) 62 | #define BLYNK_EVERY_N_HOURS_I(NAME,N) static BlynkEveryNHours NAME(N); if(NAME) 63 | 64 | #define BLYNK_EVERY_N_MILLIS(N) BLYNK_EVERY_N_MILLIS_I(BLYNK_CONCAT2(PER, __COUNTER__),N) 65 | #define BLYNK_EVERY_N_SECONDS(N) BLYNK_EVERY_N_SECONDS_I(BLYNK_CONCAT2(PER, __COUNTER__),N) 66 | #define BLYNK_EVERY_N_MINUTES(N) BLYNK_EVERY_N_MINUTES_I(BLYNK_CONCAT2(PER, __COUNTER__),N) 67 | #define BLYNK_EVERY_N_HOURS(N) BLYNK_EVERY_N_HOURS_I(BLYNK_CONCAT2(PER, __COUNTER__),N) 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/Blynk/BlynkTemplates.h: -------------------------------------------------------------------------------- 1 | class BlynkStackOnly 2 | { 3 | protected: 4 | BlynkStackOnly() {} 5 | ~BlynkStackOnly() {} 6 | 7 | private: 8 | /// @brief Declared as private to prevent usage of dynamic memory 9 | void* operator new(size_t size); 10 | /// @brief Declared as private to prevent usage of dynamic memory 11 | void operator delete(void *p); 12 | }; 13 | 14 | class BlynkNonCopyable 15 | { 16 | protected: 17 | BlynkNonCopyable(){} 18 | ~BlynkNonCopyable(){} 19 | 20 | private: 21 | /// @brief Declared as private to prevent usage of copy constructor 22 | BlynkNonCopyable(const BlynkNonCopyable&); 23 | /// @brief Declared as private to prevent usage of assignment operator 24 | BlynkNonCopyable& operator=(const BlynkNonCopyable&); 25 | }; 26 | 27 | template 28 | class BlynkSingleton 29 | : public BlynkNonCopyable 30 | { 31 | public: 32 | /** @brief Returns the instance of the singleton type 33 | When called for the first time, the singleton instance will be 34 | created. All subsequent calls will return a reference to the 35 | previously created instance. 36 | @return The singleton instance 37 | */ 38 | static T* instance() 39 | { 40 | static T instance; 41 | return &instance; 42 | } 43 | protected: 44 | BlynkSingleton() {} 45 | ~BlynkSingleton() {} 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /src/Blynk/BlynkWidgetBase.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkWidgetBase.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 6 | * @date Nov 2016 7 | * @brief 8 | */ 9 | 10 | #ifndef BlynkWidgetBase_h 11 | #define BlynkWidgetBase_h 12 | 13 | #include 14 | 15 | class BlynkWidgetBase 16 | { 17 | public: 18 | BlynkWidgetBase(uint8_t vPin) : mPin(vPin) {} 19 | void setVPin(uint8_t vPin) { mPin = vPin; } 20 | 21 | void onWrite(BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED ¶m) { 22 | BLYNK_LOG1(BLYNK_F("BlynkWidgetBase::onWrite should not be called")); 23 | } 24 | 25 | template 26 | void setLabel(Args... args) { 27 | Blynk.setProperty(mPin, "label", args...); 28 | } 29 | 30 | template 31 | void setColor(Args... args) { 32 | Blynk.setProperty(mPin, "color", args...); 33 | } 34 | 35 | template 36 | void setMin(Args... args) { 37 | Blynk.setProperty(mPin, "min", args...); 38 | } 39 | 40 | template 41 | void setMax(Args... args) { 42 | Blynk.setProperty(mPin, "max", args...); 43 | } 44 | 45 | protected: 46 | uint8_t mPin; 47 | }; 48 | 49 | class BlynkAttachWidgetHelper { 50 | public: 51 | template 52 | explicit BlynkAttachWidgetHelper(T& widget, uint8_t vPin) { 53 | widget.setVPin(vPin); 54 | } 55 | }; 56 | 57 | // Could use __attribute__ ((constructor)), but hope for better portability 58 | #define BLYNK_ATTACH_WIDGET(widget, pin) \ 59 | BlynkAttachWidgetHelper BLYNK_CONCAT2(blnk_widget_helper_, __COUNTER__)((widget), (pin)); \ 60 | BLYNK_WRITE(pin) { (widget).onWrite(request, param); } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/BlynkSimpleBLEPeripheral.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleBLEPeripheral.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 6 | * @date Mar 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleBLEPeripheral_h 12 | #define BlynkSimpleBLEPeripheral_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "BLEPeripheral" 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/BlynkSimpleCC3000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleCC3000.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | */ 9 | 10 | #ifndef BlynkSimpleCC3000_h 11 | #define BlynkSimpleCC3000_h 12 | 13 | #include 14 | #include 15 | 16 | // Use hardware SPI for the remaining pins 17 | // SCK = 13, MISO = 12, and MOSI = 11 18 | Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, 19 | SPI_CLOCK_DIVIDER); // you can change this clock speed 20 | 21 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 22 | static BlynkTransportCC3000 _blynkTransport(cc3000); 23 | BlynkCC3000 Blynk(cc3000, _blynkTransport); 24 | #else 25 | extern BlynkCC3000 Blynk; 26 | #endif 27 | 28 | #include 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/BlynkSimpleEnergiaEthernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleEnergiaEthernet.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Oct 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleEnergiaEthernet_h 12 | #define BlynkSimpleEnergiaEthernet_h 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 19 | static EthernetClient _blynkEthernetClient; 20 | static BlynkArduinoClient _blynkTransport(_blynkEthernetClient); 21 | BlynkEthernet Blynk(_blynkTransport); 22 | #else 23 | extern BlynkEthernet Blynk; 24 | #endif 25 | 26 | #include 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/BlynkSimpleEnergiaWiFi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleEnergiaWiFi.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleEnergiaWiFi_h 12 | #define BlynkSimpleEnergiaWiFi_h 13 | 14 | #include 15 | #include 16 | 17 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 18 | static WiFiClient _blynkWifiClient; 19 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 20 | BlynkWifiCommon Blynk(_blynkTransport); 21 | #else 22 | extern BlynkWifiCommon Blynk; 23 | #endif 24 | 25 | #include 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/BlynkSimpleEthernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleEthernet.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleEthernet_h 12 | #define BlynkSimpleEthernet_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "W5100" 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 23 | static EthernetClient _blynkEthernetClient; 24 | static BlynkArduinoClient _blynkTransport(_blynkEthernetClient); 25 | BlynkEthernet Blynk(_blynkTransport); 26 | #else 27 | extern BlynkEthernet Blynk; 28 | #endif 29 | 30 | #include 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/BlynkSimpleEthernetENC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleUipEthernet.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleUipEthernet_h 12 | #define BlynkSimpleUipEthernet_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "ENC28J60" 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 22 | static EthernetClient _blynkEthernetClient; 23 | static BlynkArduinoClient _blynkTransport(_blynkEthernetClient); 24 | BlynkEthernet Blynk(_blynkTransport); 25 | #else 26 | extern BlynkEthernet Blynk; 27 | #endif 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/BlynkSimpleIntelEdisonWiFi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleIntelEdisonWiFi.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleIntelEdisonWiFi_h 12 | #define BlynkSimpleIntelEdisonWiFi_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "WiFi" 16 | #endif 17 | 18 | #define BLYNK_MINIMIZE_PINMODE_USAGE 19 | 20 | #include 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/BlynkSimpleMKR1000.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleMKR1000.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleMKR1000_h 12 | #define BlynkSimpleMKR1000_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "WiFi" 16 | #endif 17 | 18 | #include 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/BlynkSimpleMKRGSM.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleMKRGSM.h 3 | * @author Riccardo Rizzo 4 | * @license This project is released under the MIT License (MIT) 5 | * @date Dec 2018 6 | * @brief 7 | * 8 | */ 9 | 10 | #ifndef BlynkSimpleMKRGSM_h 11 | #define BlynkSimpleMKRGSM_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "MKRGSM" 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 21 | static BlynkArduinoClient _blynkTransport; 22 | BlynkSIM Blynk(_blynkTransport); 23 | #else 24 | extern BlynkSIM Blynk; 25 | #endif 26 | 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/BlynkSimpleMKRNB.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleMKRNB.h 3 | * @author Riccardo Rizzo 4 | * @license This project is released under the MIT License (MIT) 5 | * @date Dec 2018 6 | * @brief 7 | * 8 | */ 9 | 10 | #ifndef BlynkSimpleMKRNB_h 11 | #define BlynkSimpleMKRNB_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "MKRNB" 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 21 | static BlynkArduinoClient _blynkTransport; 22 | BlynkSIM Blynk(_blynkTransport); 23 | #else 24 | extern BlynkSIM Blynk; 25 | #endif 26 | 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/BlynkSimpleParticle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleParticle.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleParticle_h 12 | #define BlynkSimpleParticle_h 13 | 14 | #include 15 | 16 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 17 | static BlynkTransportParticle _blynkTransport; 18 | BlynkParticle Blynk(_blynkTransport); 19 | #else 20 | extern BlynkParticle Blynk; 21 | #endif 22 | 23 | #include "BlynkWidgets.h" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/BlynkSimpleParticleSSL.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleParticle.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2022 Volodymyr Shymanskyy 6 | * @date Mar 2022 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleParticle_h 12 | #define BlynkSimpleParticle_h 13 | 14 | #include 15 | 16 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 17 | static BlynkTransportParticle _blynkTransport; 18 | BlynkParticle Blynk(_blynkTransport); 19 | #else 20 | extern BlynkParticle Blynk; 21 | #endif 22 | 23 | #include 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/BlynkSimpleRedBear_Duo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleRedBear_Duo.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Dec 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleRedBear_Duo_h 12 | #define BlynkSimpleRedBear_Duo_h 13 | 14 | #include "BlynkParticle.h" 15 | 16 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 17 | static BlynkTransportParticle _blynkTransport; 18 | BlynkParticle Blynk(_blynkTransport); 19 | #else 20 | extern BlynkParticle Blynk; 21 | #endif 22 | 23 | #include "BlynkWidgets.h" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/BlynkSimpleSerialBLE.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSerialBLE.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 6 | * @date Mar 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSerialBLE_h 12 | #define BlynkSerialBLE_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "SerialBLE" 16 | #endif 17 | 18 | #define BLYNK_SEND_ATOMIC 19 | #define BLYNK_SEND_CHUNK 20 20 | #define BLYNK_SEND_THROTTLE 40 21 | #define BLYNK_NO_INFO 22 | 23 | #include 24 | 25 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 26 | BlynkTransportStream _blynkTransport; 27 | BlynkStream Blynk(_blynkTransport); 28 | #else 29 | extern BlynkStream Blynk; 30 | #endif 31 | 32 | #include 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/BlynkSimpleStream.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleStream.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 6 | * @date Mar 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleStream_h 12 | #define BlynkSimpleStream_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "Stream" 16 | #endif 17 | 18 | #include 19 | 20 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 21 | BlynkTransportStream _blynkTransport; 22 | BlynkStream Blynk(_blynkTransport); 23 | #else 24 | extern BlynkStream Blynk; 25 | #endif 26 | 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/BlynkSimpleTinyDuino.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleTinyDuino.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | */ 9 | 10 | #ifndef BlynkSimpleTinyDuino_h 11 | #define BlynkSimpleTinyDuino_h 12 | 13 | #ifndef BLYNK_INFO_DEVICE 14 | #define BLYNK_INFO_DEVICE "TinyDuino" 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | // Pin definitions for the TinyCircuits WiFi TinyShield 21 | #define ADAFRUIT_CC3000_IRQ 2 22 | #define ADAFRUIT_CC3000_VBAT A3 23 | #define ADAFRUIT_CC3000_CS 8 24 | 25 | // Use hardware SPI for the remaining pins (on an UNO, SCK = 13, MISO = 12, and MOSI = 11) 26 | Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT, SPI_CLOCK_DIVIDER); 27 | 28 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 29 | static BlynkTransportCC3000 _blynkTransport(cc3000); 30 | BlynkCC3000 Blynk(cc3000, _blynkTransport); 31 | #else 32 | extern BlynkCC3000 Blynk; 33 | #endif 34 | 35 | 36 | #include 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/BlynkSimpleTinyGSM.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleTinyGSM.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Nov 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleTinyGSM_h 12 | #define BlynkSimpleTinyGSM_h 13 | 14 | #include 15 | 16 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 17 | static BlynkArduinoClient _blynkTransport; 18 | BlynkSIM Blynk(_blynkTransport); 19 | #else 20 | extern BlynkSIM Blynk; 21 | #endif 22 | 23 | #include 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/BlynkSimpleUIPEthernet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleUipEthernet.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleUipEthernet_h 12 | #define BlynkSimpleUipEthernet_h 13 | 14 | #error "BlynkSimpleUipEthernet.h is deprecated. Please use BlynkSimpleEthernetENC.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/BlynkSimpleWiFiLink.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWifiLink.h 3 | * @ 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2017 7 | * @brief 8 | * 9 | */ 10 | #ifndef BlynkSimpleWiFiLink_h 11 | #define BlynkSimpleWiFiLink_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "WiFiLink" 15 | #endif 16 | 17 | #define BLYNK_SEND_ATOMIC 18 | #define BLYNK_SEND_CHUNK 64 19 | 20 | #include 21 | #include 22 | 23 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 24 | static WiFiClient _blynkWifiClient; 25 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 26 | BlynkWifiCommon Blynk(_blynkTransport); 27 | #else 28 | extern BlynkWifiCommon Blynk; 29 | #endif 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/BlynkSimpleWiFiNINA.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWiFiNINA.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2018 Volodymyr Shymanskyy 6 | * @date Sep 2018 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWiFiNINA_h 12 | #define BlynkSimpleWiFiNINA_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "WiFiNINA" 16 | #endif 17 | 18 | #define BLYNK_SEND_ATOMIC 19 | //#define BLYNK_USE_SSL 20 | 21 | #include 22 | #include 23 | 24 | //static WiFiSSLClient _blynkWifiClient; 25 | static WiFiClient _blynkWifiClient; 26 | 27 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 28 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 29 | BlynkWifiCommon Blynk(_blynkTransport); 30 | #else 31 | extern BlynkWifiCommon Blynk; 32 | #endif 33 | 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/BlynkSimpleWiFiShield101.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWiFiShield101.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWiFiShield101_h 12 | #define BlynkSimpleWiFiShield101_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "WiFi101" 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 22 | static WiFiClient _blynkWifiClient; 23 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 24 | BlynkWifiCommon Blynk(_blynkTransport); 25 | #else 26 | extern BlynkWifiCommon Blynk; 27 | #endif 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/BlynkSimpleWiFiShield101_SSL.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWiFiShield101.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWiFiShield101_h 12 | #define BlynkSimpleWiFiShield101_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "WiFi101" 16 | #endif 17 | 18 | #include 19 | #include 20 | 21 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 22 | static WiFiSSLClient _blynkWifiClient; 23 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 24 | BlynkWifiCommon Blynk(_blynkTransport); 25 | #else 26 | extern BlynkWifiCommon Blynk; 27 | #endif 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/BlynkSimpleWiFly.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWiFly.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWiFly_h 12 | #define BlynkSimpleWiFly_h 13 | 14 | #include 15 | 16 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 17 | static BlynkTransportWiFly _blynkTransport; 18 | BlynkWiFly Blynk(_blynkTransport); 19 | #else 20 | extern BlynkWiFly Blynk; 21 | #endif 22 | 23 | #include 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/BlynkSimpleWifi.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWifi.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Jan 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWifi_h 12 | #define BlynkSimpleWifi_h 13 | 14 | #ifndef BLYNK_INFO_CONNECTION 15 | #define BLYNK_INFO_CONNECTION "HDG204" 16 | #endif 17 | 18 | // Fix for WiFi shield (it has a crazy ping duration) 19 | #define BLYNK_TIMEOUT_MS 6000UL 20 | #define BLYNK_SEND_ATOMIC 21 | #define BLYNK_SEND_CHUNK 64 22 | 23 | #include 24 | #include 25 | 26 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 27 | static WiFiClient _blynkWifiClient; 28 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 29 | BlynkWifiCommon Blynk(_blynkTransport); 30 | #else 31 | extern BlynkWifiCommon Blynk; 32 | #endif 33 | 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/BlynkSimpleWildFire.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWildFire.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleWildFire_h 12 | #define BlynkSimpleWildFire_h 13 | 14 | #include 15 | 16 | WildFire_CC3000 cc3000; 17 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 18 | static BlynkTransportWildFire _blynkTransport(cc3000); 19 | BlynkWildFire Blynk(cc3000, _blynkTransport); 20 | #else 21 | extern BlynkWildFire Blynk; 22 | #endif 23 | 24 | #include 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/BlynkSimpleWizFi250.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWizFi310.h 3 | * @ 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Oct 2017 7 | * @brief 8 | * 9 | */ 10 | #ifndef BlynkSimpleWizFi250_h 11 | #define BlynkSimpleWizFi250_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "WizFi250" 15 | #endif 16 | 17 | #define BLYNK_SEND_ATOMIC 18 | #define BLYNK_SEND_CHUNK 64 19 | 20 | #include 21 | #include 22 | 23 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 24 | static WiFiClient _blynkWifiClient; 25 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 26 | BlynkWifiCommon Blynk(_blynkTransport); 27 | #else 28 | extern BlynkWifiCommon Blynk; 29 | #endif 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/BlynkSimpleWizFi310.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleWizFi310.h 3 | * @ 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Oct 2017 7 | * @brief 8 | * 9 | */ 10 | #ifndef BlynkSimpleWizFi310_h 11 | #define BlynkSimpleWizFi310_h 12 | 13 | #ifndef BLYNK_INFO_CONNECTION 14 | #define BLYNK_INFO_CONNECTION "WizFi310" 15 | #endif 16 | 17 | #define BLYNK_SEND_ATOMIC 18 | #define BLYNK_SEND_CHUNK 64 19 | 20 | #include 21 | #include 22 | 23 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 24 | static WiFiClient _blynkWifiClient; 25 | static BlynkArduinoClient _blynkTransport(_blynkWifiClient); 26 | BlynkWifiCommon Blynk(_blynkTransport); 27 | #else 28 | extern BlynkWifiCommon Blynk; 29 | #endif 30 | 31 | #include 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/BlynkSimpleYun.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkSimpleYun.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef BlynkSimpleYun_h 12 | #define BlynkSimpleYun_h 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | typedef BlynkArduinoClient BlynkArduinoClientYun; 19 | 20 | class BlynkYun 21 | : public BlynkProtocol< BlynkArduinoClientYun > 22 | { 23 | typedef BlynkProtocol< BlynkArduinoClientYun > Base; 24 | public: 25 | BlynkYun(BlynkArduinoClientYun& transp) 26 | : Base(transp) 27 | {} 28 | 29 | void config(const char* auth, 30 | const char* domain = BLYNK_DEFAULT_DOMAIN, 31 | uint16_t port = BLYNK_DEFAULT_PORT) 32 | { 33 | Base::begin(auth); 34 | this->conn.begin(domain, port); 35 | } 36 | 37 | void config(const char* auth, 38 | IPAddress ip, 39 | uint16_t port = BLYNK_DEFAULT_PORT) 40 | { 41 | Base::begin(auth); 42 | this->conn.begin(ip, port); 43 | } 44 | 45 | void begin(const char* auth, 46 | const char* domain = BLYNK_DEFAULT_DOMAIN, 47 | uint16_t port = BLYNK_DEFAULT_PORT) 48 | { 49 | BLYNK_LOG1(BLYNK_F("Bridge init...")); 50 | Bridge.begin(); 51 | config(auth, domain, port); 52 | while(this->connect() != true) {} 53 | } 54 | 55 | void begin(const char* auth, 56 | IPAddress ip, 57 | uint16_t port = BLYNK_DEFAULT_PORT) 58 | { 59 | BLYNK_LOG1(BLYNK_F("Bridge init...")); 60 | Bridge.begin(); 61 | config(auth, ip, port); 62 | while(this->connect() != true) {} 63 | } 64 | 65 | }; 66 | 67 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_BLYNK) 68 | static BridgeClient _blynkYunClient; 69 | static BlynkArduinoClient _blynkTransport(_blynkYunClient); 70 | BlynkYun Blynk(_blynkTransport); 71 | #else 72 | extern BlynkYun Blynk; 73 | #endif 74 | 75 | #include 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/BlynkWidgets.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file BlynkWidgets.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | // Cannot auto-include as these have library dependencies 17 | //#include 18 | 19 | template 20 | class VPinWriteOnChange { 21 | 22 | public: 23 | VPinWriteOnChange(int vpin) 24 | : _vPin(vpin) 25 | { 26 | reset(); 27 | } 28 | 29 | VPinWriteOnChange& operator= (const T& value) { 30 | update(value); 31 | return *this; 32 | } 33 | 34 | void reset() { 35 | _hasValue = false; 36 | } 37 | 38 | bool hasValue() const { 39 | return _hasValue; 40 | } 41 | 42 | void set(const T& value) { 43 | _value = value; 44 | _hasValue = true; 45 | } 46 | 47 | void update(const T& value) { 48 | if (!hasValue() || value != _value) { 49 | set(value); 50 | report(); 51 | } 52 | } 53 | 54 | void report() { 55 | if (hasValue()) { 56 | Blynk.virtualWrite(_vPin, _value); 57 | } 58 | } 59 | 60 | private: 61 | const int _vPin; 62 | T _value; 63 | bool _hasValue; 64 | }; 65 | 66 | template<> 67 | class VPinWriteOnChange { 68 | 69 | public: 70 | VPinWriteOnChange(int vpin, float threshold) 71 | : _vPin(vpin) 72 | , _threshold(threshold) 73 | { 74 | reset(); 75 | } 76 | 77 | VPinWriteOnChange& operator= (const float& value) { 78 | update(value); 79 | return *this; 80 | } 81 | 82 | void reset() { 83 | _value = NAN; 84 | } 85 | 86 | bool hasValue() const { 87 | return !isnan(_value); 88 | } 89 | 90 | void set(const float& value) { 91 | _value = value; 92 | } 93 | 94 | void update(const float& value) { 95 | if (!hasValue() || fabs(value - _value) > _threshold) { 96 | set(value); 97 | report(); 98 | } 99 | } 100 | 101 | void report() { 102 | if (hasValue()) { 103 | Blynk.virtualWrite(_vPin, _value); 104 | } 105 | } 106 | 107 | private: 108 | const int _vPin; 109 | float _value; 110 | float _threshold; 111 | }; 112 | -------------------------------------------------------------------------------- /src/WidgetLCD.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WidgetLCD.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2015 7 | * @brief 8 | */ 9 | 10 | #ifndef WidgetLCD_h 11 | #define WidgetLCD_h 12 | 13 | #include 14 | 15 | class WidgetLCD 16 | : public BlynkWidgetBase 17 | { 18 | public: 19 | WidgetLCD(uint8_t vPin) : BlynkWidgetBase(vPin) {} 20 | 21 | void clear() { 22 | Blynk.virtualWrite(mPin, "clr"); 23 | } 24 | 25 | template 26 | void print(int x, int y, const T& str) { 27 | char mem[BLYNK_MAX_SENDBYTES]; 28 | BlynkParam cmd(mem, 0, sizeof(mem)); 29 | cmd.add("p"); 30 | cmd.add(x); 31 | cmd.add(y); 32 | cmd.add(str); 33 | Blynk.virtualWrite(mPin, cmd); 34 | } 35 | 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/WidgetLED.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WidgetLED.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Apr 2015 7 | * @brief 8 | */ 9 | 10 | #ifndef WidgetLED_h 11 | #define WidgetLED_h 12 | 13 | #include 14 | 15 | class WidgetLED 16 | : public BlynkWidgetBase 17 | { 18 | public: 19 | WidgetLED(uint8_t vPin) 20 | : BlynkWidgetBase(vPin) 21 | , mValue(0) 22 | {} 23 | 24 | uint8_t getValue() const { 25 | return mValue; 26 | } 27 | 28 | void setValue(uint8_t value) { 29 | mValue = value; 30 | Blynk.virtualWrite(mPin, value); 31 | } 32 | 33 | void on() { 34 | setValue(255); 35 | } 36 | 37 | void off() { 38 | setValue(0); 39 | } 40 | 41 | private: 42 | uint8_t mValue; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/WidgetMap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WidgetMap.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 6 | * @date Nov 2016 7 | * @brief 8 | */ 9 | 10 | #ifndef WidgetMap_h 11 | #define WidgetMap_h 12 | 13 | #include 14 | 15 | class WidgetMap 16 | : public BlynkWidgetBase 17 | { 18 | public: 19 | WidgetMap(uint8_t vPin) : BlynkWidgetBase(vPin) {} 20 | 21 | void clear() { 22 | Blynk.virtualWrite(mPin, "clr"); 23 | } 24 | 25 | template 26 | void location(const T1& index, const T2& lat, const T3& lon, const T4& value) { 27 | Blynk.virtualWrite(mPin, index, lat, lon, value); 28 | } 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/WidgetRTC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file WidgetRTC.h 3 | * @author Volodymyr Shymanskyy 4 | * @license This project is released under the MIT License (MIT) 5 | * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 6 | * @date Mar 2016 7 | * @brief 8 | * 9 | */ 10 | 11 | #ifndef WidgetRTC_h 12 | #define WidgetRTC_h 13 | 14 | #if !defined(ARDUINO) 15 | #error WidgetRTC is not available on this platform! 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | class WidgetRTC 23 | : public BlynkSingleton 24 | { 25 | public: 26 | WidgetRTC() {} 27 | void begin(); 28 | 29 | private: 30 | static time_t requestTimeSync(); 31 | }; 32 | 33 | // This is called by Time library when it needs time sync 34 | time_t WidgetRTC::requestTimeSync() 35 | { 36 | // Request RTC widget update from the server 37 | Blynk.sendInternal("rtc", "sync"); 38 | // Tell the Time library that we'll set it later 39 | return 0; 40 | } 41 | 42 | inline 43 | void WidgetRTC::begin() 44 | { 45 | setSyncProvider(requestTimeSync); 46 | } 47 | 48 | BLYNK_WRITE(InternalPinRTC) { 49 | const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013 50 | unsigned long blynkTime = param.asLong(); 51 | 52 | if (blynkTime >= DEFAULT_TIME) { // Check the integer is a valid time (greater than Jan 1 2013) 53 | setTime(blynkTime); // Sync Time library clock to the value received from Blynk 54 | BLYNK_LOG1(BLYNK_F("Time sync: OK")); 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/utility/BlynkDateTime.h: -------------------------------------------------------------------------------- 1 | 2 | #warning "Please include Blynk/BlynkDateTime.h, instead of utility/BlynkDateTime.h" 3 | #include 4 | -------------------------------------------------------------------------------- /src/utility/BlynkStreamMulti.h: -------------------------------------------------------------------------------- 1 | #ifndef BlynkStreamMulti_h 2 | #define BlynkStreamMulti_h 3 | 4 | #ifndef BLYNK_MULTI_STREAM_MAX_QTY 5 | #define BLYNK_MULTI_STREAM_MAX_QTY 6 6 | #endif 7 | 8 | class MultiStream 9 | : public Stream 10 | { 11 | public: 12 | MultiStream() {} 13 | virtual ~MultiStream() {} 14 | 15 | bool addStream(Stream* stream) { 16 | if (stream && _streamsQty < BLYNK_MULTI_STREAM_MAX_QTY) { 17 | _streams[_streamsQty++] = stream; 18 | return true; 19 | } 20 | return false; 21 | } 22 | 23 | bool addStream(Stream& stream) { 24 | return addStream(&stream); 25 | } 26 | 27 | /* 28 | * Writing 29 | */ 30 | 31 | virtual size_t write(uint8_t ch) { 32 | for (int i=0; i<_streamsQty; i++) { 33 | _streams[i]->write(ch); 34 | } 35 | return 1; 36 | } 37 | 38 | virtual void flush() { 39 | for (int i=0; i<_streamsQty; i++) { 40 | return _streams[i]->flush(); 41 | } 42 | } 43 | 44 | /* 45 | * Reading 46 | */ 47 | 48 | virtual int available() { 49 | for (int i=0; i<_streamsQty; i++) { 50 | int avail = _streams[i]->available(); 51 | if (avail > 0) { return avail; } 52 | } 53 | return 0; 54 | } 55 | 56 | virtual int read() { 57 | for (int i=0; i<_streamsQty; i++) { 58 | if (_streams[i]->available()) { 59 | return _streams[i]->read(); 60 | } 61 | } 62 | return -1; 63 | } 64 | 65 | virtual int peek() { 66 | for (int i=0; i<_streamsQty; i++) { 67 | if (_streams[i]->available()) { 68 | return _streams[i]->peek(); 69 | } 70 | } 71 | return -1; 72 | } 73 | 74 | private: 75 | Stream* _streams[BLYNK_MULTI_STREAM_MAX_QTY]; 76 | int _streamsQty = 0; 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /src/utility/BlynkStreamNull.h: -------------------------------------------------------------------------------- 1 | #ifndef BlynkStreamNull_h 2 | #define BlynkStreamNull_h 3 | 4 | class NullStream 5 | : public Stream 6 | { 7 | public: 8 | 9 | /* 10 | * Writing 11 | */ 12 | 13 | virtual size_t write(uint8_t) override { 14 | return 1; 15 | } 16 | 17 | virtual size_t write(const uint8_t* buffer, size_t size) override { 18 | (void)buffer; 19 | (void)size; 20 | return size; 21 | } 22 | 23 | virtual int availableForWrite() { 24 | return 4096; 25 | } 26 | 27 | virtual void flush() {} 28 | 29 | /* 30 | * Reading 31 | */ 32 | 33 | virtual int available() override { 34 | return 0; 35 | } 36 | 37 | virtual int read() override { 38 | return -1; 39 | } 40 | 41 | virtual int peek() override { 42 | return -1; 43 | } 44 | 45 | virtual size_t readBytes(char* buffer, size_t len) { 46 | (void)buffer; 47 | (void)len; 48 | return 0; 49 | } 50 | 51 | virtual int read(uint8_t* buffer, size_t len) { 52 | (void)buffer; 53 | (void)len; 54 | return 0; 55 | } 56 | }; 57 | 58 | #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_NULLSTREAM) 59 | static NullStream NullStream; 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/utility/BlynkUtility.h: -------------------------------------------------------------------------------- 1 | 2 | #warning "Please include Blynk/BlynkUtility.h, instead of utility/BlynkUtility.h" 3 | #include 4 | -------------------------------------------------------------------------------- /src/utility/utility.cpp: -------------------------------------------------------------------------------- 1 | /* no longer used */ 2 | -------------------------------------------------------------------------------- /tests/BlynkFootprintTest/BlynkFootprintTest.ino: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * This is just a test of Blynk library memory footprint. 3 | * It doesn't use serial, wifi, ethernet or any other library. 4 | * It uses a volatile variable to simulate server stream. 5 | * 6 | * You should NOT flash this program 7 | * to your hardware or try to run it. 8 | * 9 | **************************************************************/ 10 | 11 | //#define ENABLE_MINIMIZATION 12 | #define ENABLE_HANDLERS 13 | 14 | #ifdef ENABLE_MINIMIZATION 15 | #define BLYNK_NO_BUILTIN 16 | #define BLYNK_NO_INFO 17 | #define BLYNK_NO_FLOAT 18 | #endif 19 | 20 | #include 21 | 22 | char auth[] = "12345678901234567890123456789012"; 23 | 24 | volatile uint8_t test; 25 | 26 | // This function is used by Blynk to receive data 27 | size_t BlynkStreamRead(void* buf, size_t len) 28 | { 29 | uint8_t* byte_buff = (uint8_t*)buf; 30 | size_t res = len; 31 | while (len--) { 32 | *byte_buff++ = test; 33 | } 34 | return res; 35 | } 36 | 37 | // This function is used by Blynk to send data 38 | size_t BlynkStreamWrite(const void* buf, size_t len) 39 | { 40 | uint8_t* byte_buff = (uint8_t*)buf; 41 | size_t res = len; 42 | while (len--) { 43 | test = *byte_buff++; 44 | } 45 | return res; 46 | } 47 | 48 | void setup() 49 | { 50 | Blynk.begin(auth); 51 | Blynk.connect(); 52 | } 53 | 54 | #ifdef ENABLE_HANDLERS 55 | 56 | BLYNK_CONNECTED() 57 | { 58 | test = 1; 59 | } 60 | 61 | BLYNK_DISCONNECTED() 62 | { 63 | test = 2; 64 | } 65 | 66 | BLYNK_WRITE(V3) 67 | { 68 | test = param.asInt(); 69 | } 70 | 71 | BLYNK_READ(V4) 72 | { 73 | Blynk.virtualWrite(V4, millis(), BlynkFreeRam()); 74 | } 75 | 76 | #endif /* ENABLE_HANDLERS */ 77 | 78 | void loop() 79 | { 80 | bool hasIncomingData = (test > 0); 81 | 82 | if (!Blynk.run(hasIncomingData)) { 83 | 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /tests/SerialXconnect/SerialXconnect.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This utility allows you to cross-connect two serial channels 3 | * using any Arduino-compatible hardware. 4 | * 5 | * This is usefull for: 6 | * Checking wiring 7 | * Converting baud rate 8 | * Sending AT commands 9 | * etc. 10 | * 11 | * Popular AT command sets: 12 | * ESP8266: http://www.espressif.com/sites/default/files/4a-esp8266_at_instruction_set_en_v1.5.4_0.pdf 13 | * SIM800L: https://www.itead.cc/wiki/images/6/6f/SIM800_Series_AT_Command_Manual_V1.05.pdf 14 | * XBee: https://cdn.sparkfun.com/learn/materials/29/22AT%20Commands.pdf 15 | */ 16 | 17 | #define ser1 Serial 18 | 19 | #if defined(HAVE_HWSERIAL1) 20 | #define ser2 Serial1 21 | #else 22 | #warning Using Software Serial! 23 | #include 24 | SoftwareSerial SerialSw(2, 3); 25 | #define ser2 SerialSw 26 | #endif 27 | 28 | void setup() { 29 | ser1.begin(9600); 30 | while (!ser1); 31 | delay(10); 32 | ser2.begin(9600); 33 | delay(10); 34 | } 35 | 36 | void loop() { 37 | if (ser1.available()) { 38 | int c = ser1.read(); 39 | if (!parseCommands(c)) { 40 | ser2.write(c); 41 | } 42 | } 43 | if (ser2.available()) { 44 | ser1.write(ser2.read()); 45 | } 46 | } 47 | 48 | /* 49 | * Special commands: 50 | * !speed=1000000 (after ESP8266 command: AT+UART_CUR=1000000,8,1,0,0) 51 | */ 52 | 53 | char cmd_prefix[] = "!speed="; 54 | uint8_t cmd_prefix_idx = 0; 55 | 56 | bool parseCommands(int c) { 57 | if (c == cmd_prefix[cmd_prefix_idx]) { 58 | cmd_prefix_idx++; 59 | if (cmd_prefix_idx >= sizeof(cmd_prefix) - 1) { 60 | String cmd = ser1.readStringUntil('\n'); 61 | long baud = cmd.toInt(); 62 | ser1.print("Speed:"); ser1.println(baud); 63 | ser2.begin(baud); 64 | cmd_prefix_idx = 0; 65 | } 66 | return true; 67 | } else if (cmd_prefix_idx > 0) { 68 | ser2.write(cmd_prefix, cmd_prefix_idx); 69 | cmd_prefix_idx = 0; 70 | } 71 | return false; 72 | } 73 | 74 | --------------------------------------------------------------------------------