5 Responses

  1. Vicky Arora
    Vicky Arora at · · Reply

    I am new to programming with ESP & GCM working on your project and wanted to understand few things. I took your code and did the following changes to it as shown at the bottom of the comment.

    Everything works, but I am not able to figure out how the code get’s the token?
    Here is what I am getting in my Serial output

    File does not exist
    No registered devices
    gcmSendMsg – JsonArrays

    Changes made to the code as below:
    1. gcm_esp
    // /** Google API key */
    const String API_key = “MyGCMKey”;

    2. gcm_esp_Test
    // /** SSID of local WiFi network */
    const char* ssid = “MySSID”;
    // /** Password for local WiFi network */
    const char* password = “MyPassword”;

    3. gcm_esp_Test
    /* REMARK: I use fixed IP address for the ESP8266 module, not the DHCP function */
    /** IP address of this module */
    IPAddress ipAddr(192, 168, 0, xxx); // REPLACE WITH THE IP ADDRESS YOU WANT TO APPLY
    /** Gateway address of WiFi access point */
    IPAddress ipGateWay(192, 168, 0, xxx); // REPLACE WITH THE GATEWAY ADDRESS OF YOUR WIFI AP
    /** Network mask of the local lan */
    IPAddress ipSubNet(255, 255, 255, 0); // SHOULD WORK WITH MOST WIFI LANs

    I would really appreciate if you could help me in this.

    Thank you.

  2. JP
    JP at · · Reply

    Fantastic tutorial.

    I have got it work, but have been obliged to increase the DeviceId to 162

    if (newDeviceID.length() != 162) {

    140 seems to be no longer supported by Google ?

    However it works now.
    I can hadle the message intent in my Android App following Basic4Android tutorial here : https://www.b4x.com/android/forum/threads/simple-push-framework.35635/

    I have also seen that it should be possible to directly send a notification to the device :

    Here is a JSON-formatted message can containing both notification and data:

    “to” : “APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx…”,
    “notification” : {
    “body” : “great match!”,
    “title” : “Portugal vs. Denmark”,
    “icon” : “myicon”
    “data” : {
    “Nick” : “Mario”,
    “Room” : “PortugalVSDenmark”

    But I am not tottally “fluent” with your code and Json…
    so I don’t know where to add thes “notification” key.

    I believe it should be somewhere here :
    void loop() {
    // Handle new client request on HTTP server if available
    WiFiClient client = server.available();
    if (client) {

    if (doPush) {
    doPush = false;
    // Create messages & keys as JSON arrays
    DynamicJsonBuffer jsonBufferKeys;
    DynamicJsonBuffer jsonBufferMsgs;
    JsonArray& msgKeysJSON = jsonBufferKeys.createArray();
    JsonArray& msgsJSON = jsonBufferMsgs.createArray();
    char buf[4];
    char msgOne[24] = “Test message number “;
    gcmSendMsg(msgKeysJSON, msgsJSON);

    Any help please ?

Leave a Reply