Skip to content

Latest commit

 

History

History
75 lines (63 loc) · 2.49 KB

Implementing.md

File metadata and controls

75 lines (63 loc) · 2.49 KB

Implementing a Blynk HW client (library)

Currently we provide Arduino/C++ implementation of the library. It is very extensible and modular, look at the list of supported hardware. Adding new connection types and Arduino-compatible boards is easy.

TODO: Porting guide.

But some devices are programmed in other languages, like:

  • Espruino, JavaScript, Node.JS
  • MicroPython, Python
  • NodeMCU, eLua

This document hints how to write a custom library.

Blynk library main functions

  • Provide easy-to use API
  • Virtual pin handlers registration
  • Provide comfortable wrappers for some widgets
  • Manage connection
  • Should support different connection type/hardware, if applicable
  • Serialize/deserialize Blynk protocol
  • Handle direct pin operations
  • Should be portable across similar devices (or same technology/programming language), if possible
  • Should detect and notify the user about troubles where possible (especially Flood)

Adding new HW board

Different boards can be added by creating JSON board description file.

{
    "name": "Arduino UNO",
    "map": {
        "digital": {
            "pins": {
                "D0":  0,  "D1":  1,  "D2":  2,  "D3":  3, "D4": 4,
                "D5":  5,  "D6":  6,  "D7":  7,  "D8":  8, "D9": 9,
                "D10": 10, "D11": 11, "D12": 12, "D13": 13
            },
            "ops": [ "dr", "dw" ]
        },
        "analog": {
            "pins": {
                "A0": 14, "A1": 15, "A2": 16, "A3": 17, "A4": 18, "A5": 19
            },
            "ops": [ "dr", "dw", "ar" ],
            "arRange":[0, 1023]
        },
        "pwm": {
            "pins": [
                "D3", "D5", "D6", "D9", "D10", "D11"
            ],
            "ops": [ "aw" ],
            "awRange":[0, 255]
        },
        "virtual":  {
            "pinsRange": [ 0, 31 ],
            "ops": [ "vr", "vw" ]
        }
    }
}

Look at the full boards list. You can send us your own board description file for review and App integration.

There may be a problem that you want to start testing your implementation, but your board is not listed int the Blynk App. On Android, we now have a "Generic Board" specially for such purposes. Unfortunately iOS does not have it yet.

Basically you can select UNO board and check how it works using just virtual pins. Most digital pins will also work. Analog IO/PWM will not work in general, until we add your board to the App.