I have node mcu with ESP8266 wifi module. When i am trying to upload an example code then its not working.

This is the Error:-

inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)


exit status 1
invalid conversion from 'char' to 'const char*' [-fpermissive]


#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient

#include <PubNub.h>

const char *ssid =  "mym404";     // replace with your wifi ssid and wpa2 key
const char *pass =  "786110786";

char pubkey = 'pub-c-4a9cdbca-5688-4939-a852-f63cf6743980';
char subkey = 'sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094';

char pubchannel = 'demo_keyset';
char subchannel = 'demo_keyset';

void setup() {
    /* For debugging, set to speed of your choice */

       Serial.println("Connecting to ");

       WiFi.begin(ssid, pass); 
       while (WiFi.status() != WL_CONNECTED) 
      Serial.println("WiFi connected");

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);

void loop() {
    /* Maintain DHCP lease. For other HW, you may need to do
       something else here, or maybe nothing at all. */

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"message\"");
    if (!pclient) return;
    PublishCracker cheez;
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`. 
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);


Code is taken from pubnub arduino github example - https://github.com/pubnub/arduino/blob/master/examples/AdafruitFeatherM0WINC1500/AdafruitFeatherM0WINC1500.ino

  • are you able to compile PubNubDemo.ino? – jsotola Jan 26 at 18:21
  • change char * subchanel to const chat * subchanel – Juraj Jan 26 at 18:35
  • Tried but now it gives this error - invalid conversion from 'int' to 'const char*' [-fpermissive] , even pubnubDemo.ino shows same error. – Sultan Morbiwala Jan 28 at 12:02

problem was in the declaration of API keys and channel on the above code

Here is the right code:-

const char * pubkey = "publisher key from your account";
const char * subkey = "subscriber key from your account";

const char * pubchannel = "demo_keyset";
const char * subchannel = "demo_keyset";

Not the answer you're looking for? Browse other questions tagged or ask your own question.