An experimental NodeMCU Pusher client SDK
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

NodeMCU Pusher Client

An experimental Pusher client. Supports its most features, mainly missing the presence channel. Additional work is still required for better connectivety, error handling and attempt to further lower RAM usage.


To start, create a new pusher client instance, as shown below.

local pusher_client = pusher.createClient('<APPKEY>', 'http://<WEBSITE>/pusher/auth/', '<APPCLUSTER>')

Note that the second argument is optional and it's only required for private channels.

Now you can register the on_connection and on_close hooks. For example:

pusher_client.on_connection = function(client, socket_id)
    gpio.write(5, gpio.HIGH) -- turn on a led
pusher_client.on_close = function()
    gpio.write(5, gpio.LOW) -- turn off a led

After the hooks are setup, it's safe to call connect:


When connected, you can subscribe to channels and then bind/unbind a handler to a given event type:

    .bind('client-temperature_reading', function(data) print(data) end)

-- a bind can also be channel-independent:
pusher_client:bind('my-event-type', function(data) print(data) end)

-- to unbind:

-- or:
local subscription = pusher_client:subscribe('private-temperature_channel')
subscription.bind('some-event', function() subscription.unbind('some-event') end)

Lastly, for private channels it's possible to trigger messages, i.e.:

pusher_client:trigger('private-test-channel', 'event-type', {data = "table"})

Required firmware modules

  • cjson or sjson
  • crypto
  • file
  • http
  • net
  • node
  • websocket
  • wifi

Consider building your own image using this service. You can use esptool to flash your NodeMCU firmware.

Installing the library

Copy all files of this project to the NodeMCU. You can accomplish this using ESPlorer or nodemcu-tool.

Alternatively, you can run this one line to install it:

http.get("", nil, function(_, c) local f ="pusher_client.lua", "w+") if f then f:write(c) f:close() print("Latest client installed.") end end)