Hologram and SIM800L Cellular connection failed

Hello all, I’m really new and I have been trying to get this hackersbox kit working for a while now, I have been following Ben’s tutorial and Lib GitHub - hologram-io/hologram-SIMCOM I have my setup shown below. however I can’t get this to work for the life of me. I get a Cellular connection failed error. however on the hologram side in the datalog I am getting a socket error: connection timed out log that is also pasted below with the sketch code. any help or guidance would be grateful on how to fix this and work!

using the hologram-SIMCOM-0.4.0 Lib

Serial Monitor output:

DEBUG: Verbose monitoring and modem serial access enabled
DEBUG: Write Modem Serial = AT

DEBUG: Modem Serial Buffer = AT
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+IPR=19200

DEBUG: Modem Serial Buffer = AT+IPR=19200
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CPIN?

DEBUG: Modem Serial Buffer = AT+CPIN?
DEBUG: Modem Serial Buffer = +CPIN: READY
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CFUN=1

DEBUG: Modem Serial Buffer = AT+CFUN=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CMGF=1

DEBUG: Modem Serial Buffer = AT+CMGF=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPSHUT

DEBUG: Modem Serial Buffer = AT+CIPSHUT
DEBUG: Modem Serial Buffer = SHUT OK
DEBUG: Write Modem Serial = AT+CGATT?

DEBUG: Modem Serial Buffer = AT+CGATT?
DEBUG: Modem Serial Buffer = +CGATT: 0
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPMUX=1

DEBUG: Modem Serial Buffer = AT+CIPMUX=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CSTT="hologram"

DEBUG: Modem Serial Buffer = AT+CSTT="hologram"
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIICR

DEBUG: Modem Serial Buffer = AT+CIICR
DEBUG: Modem Serial Buffer = +PDP: DEACT
DEBUG: Modem Serial Buffer = ERROR
ERROR: Error resp when calling AT+CIICR

ERROR: begin() failed at +CIICR
Cellular connection failed
Setup complete

Hologram Datalog:

Socket error: timed out
{
    "received": "2017-04-23T08:15:34.936290",
    "authtype": "deviceid",
    "tags": [
        "_DEVICE_98803_",
        "_API_RESP_"
    ],
    "device_name": "Arduino",
    "source": 98803,
    "messageid": "77710a7f-06cf-498c-b293-0a0e236d48b8",
    "record_id": "0739968e-27fd-11e7-bd8e-bc764e200321",
    "data": "U29ja2V0IGVycm9yOiB0aW1lZCBvdXQ=",
    "device_id": 98803
}

Sketch

#include <HologramSIMCOM.h>

#define RX_PIN 8 //SIM800 RX connected to pin D8
#define TX_PIN 7 //SIM800 TX connected to pin D7
#define RESET_PIN 10 //SIM800 reset connected to pin D10
#define HOLO_KEY "REMOVED" //replace w/your SIM key
#define LED_PIN 13 //led
#define BTN_PIN 12 //push button

int ledState = 0; //this variable tracks the state of the LED, negative if off, positive if on
int ledSwitch = 0;
unsigned ledStart;
unsigned ledLongest = 0;
unsigned lastSend = millis();
int sendInterval = 120; // send stats every 2 minutes

HologramSIMCOM Hologram(TX_PIN, RX_PIN, RESET_PIN, HOLO_KEY); // Instantiate Hologram

void setup() {
    Serial.begin(19200);
    while(!Serial);

    // Start modem and connect to Hologram's global network
    Hologram.debug();
    bool cellConnected = Hologram.begin(19200, 8888); // set baud to 19200 and start server on port 8888
    if(cellConnected) {
        Serial.println(F("Cellular is connected"));
    } else {
        Serial.println(F("Cellular connection failed"));
    }

    //set modes for used pins
    pinMode(LED_PIN, OUTPUT);
    pinMode(BTN_PIN, INPUT);

    Serial.println(F("Setup complete"));
}

void loop() {
    Hologram.debug();

    // Toggle LED with physical button press
    if(digitalRead(BTN_PIN) == HIGH) {
        toggleLed();
        while(digitalRead(BTN_PIN) == HIGH); // wait until user stops pressing button
    }

    // Check for inbound messages
    // Toggle LED through inbound messages
    if(Hologram.availableMessage() > 0) {
        String message = Hologram.readMessage();

        if(message == "LED") { // send message "LED" to toggle led remotely
            toggleLed();
        } else {
            Serial.print(F("Unknown inbound message: "));
            Serial.println(message);
        }
    }

    // Send collected data of LED stats
    sendLedData();
}

void toggleLed() {
    ledState = !ledState;
    digitalWrite(LED_PIN, ledState);

    ledSwitch++; // count switches

    // Check for new logest record
    if(ledState) {
        ledStart = millis();
    } else if(ledStart > 0 && (millis() - ledStart) > ledLongest) {
        // we have a new record!
        ledLongest = millis() - ledStart;
        ledStart = 0;
    }

    delay(100); // needs a little time to settle down
}

void sendLedData() {
    unsigned m = millis();
    if(
            m - lastSend > (sendInterval * 1000)
            && ledSwitch > 0
            && Hologram.cellService()
            && Hologram.cellStrength() > 1) {

        String data = "{\"currentState\":" + String(ledState) + ",\"switched\":" + ledSwitch + ",\"longestOn\":" + ledLongest + "}";

        // Reset everything
        lastSend = m;
        ledSwitch = 0;
        ledLongest = 0;

        // send into space
        Hologram.send(data, String("LED_STATS, HACKERBOX"));
        //Hologram.sendSMS("+13125556666", "Sending SMS, your LED data is in the cloud ☁️");
    }
}

Setup Images
setup
setup2

Thanks for posting this @Chad_E. There are a few different issues I see. I’m not exactly sure what is happening, but I can confirm your sketch and wiring look good :thumbsup:.

Out of curiosity could you check the library version number? I remember seeing this error in v0.3.0, which we fixed in v0.4.0.

How to check the library version: Arduino IDE > Sketch > Include Library > Manage Libraries > search for “Hologram”. The library should appear with the version next to the name. If your version is anything other than 0.4.0, then you’ll need to get the latest from GitHub. Releases · hologram-io/hologram-SIMCOM · GitHub

In the next release, I’ll be adding the ability for Arduino Library Manager to handle installation.

I have confirmed that I am running 0.4.0.

hmmmmmmmmmm ← that’s extra long because I’m thinking extra hard. :smile:

Ok, let’s walk through this.

  1. PDP: DEACT means the network was attached at some point and something caused it to detach. Usually, a modem pin reset and an AT+CIPSHUT guarantees the modem not being in that state, both of which the library does in begin(). Here is a modem state flow diagram:

  2. Getting a socket error time out is very peculiar. That only happens when the modem receives inbound data from the cloud and does not respond to the server letting it know it got the message. So that means you were connected, you sent a message fro the cloud to the modem, the modem got the message but never responded.

We need more info in order to debug this issue. Let’s do this. I’ve made a branch of the repo and added commands to return the modem’s status at various points during begin().

Would you mind updating you library with this code? Then post the Serial Monitor logs here. Thanks!

https://github.com/hologram-io/hologram-SIMCOM/tree/print-status

I let it run for about 5 min and this was the output.

DEBUG: Verbose monitoring and modem serial access enabled
DEBUG: Write Modem Serial = AT

DEBUG: Modem Serial Buffer = AT
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPSTATUS

DEBUG: Modem Serial Buffer = AT+CIPSTATUS
DEBUG: Modem Serial Buffer = OK
DEBUG: Modem Serial Buffer = STATE: IP INITIAL

DEBUG: Write Modem Serial = AT+IPR=19200

DEBUG: Modem Serial Buffer = AT+IPR=19200
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CPIN?

DEBUG: Modem Serial Buffer = AT+CPIN?
DEBUG: Modem Serial Buffer = +CPIN: READY
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CFUN=1

DEBUG: Modem Serial Buffer = AT+CFUN=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CMGF=1

DEBUG: Modem Serial Buffer = AT+CMGF=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPSHUT

DEBUG: Modem Serial Buffer = AT+CIPSHUT
DEBUG: Modem Serial Buffer = SHUT OK
DEBUG: Write Modem Serial = AT+CIPSTATUS

DEBUG: Modem Serial Buffer = AT+CIPSTATUS
DEBUG: Modem Serial Buffer = OK
DEBUG: Modem Serial Buffer = STATE: IP INITIAL

DEBUG: Write Modem Serial = AT+CGATT?

DEBUG: Modem Serial Buffer = AT+CGATT?
DEBUG: Modem Serial Buffer = +CGATT: 0
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPSTATUS

DEBUG: Modem Serial Buffer = AT+CIPSTATUS
DEBUG: Modem Serial Buffer = OK
DEBUG: Modem Serial Buffer = STATE: IP INITIAL

DEBUG: Write Modem Serial = AT+CIPMUX=1

DEBUG: Modem Serial Buffer = AT+CIPMUX=1
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CSTT="hologram"

DEBUG: Modem Serial Buffer = AT+CSTT="hologram"
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CIPSTATUS

DEBUG: Modem Serial Buffer = AT+CIPSTATUS
DEBUG: Modem Serial Buffer = OK
DEBUG: Modem Serial Buffer = STATE: IP START

DEBUG: Write Modem Serial = AT+CIICR

DEBUG: Modem Serial Buffer = C: 0,,"","","","INITIAL"
DEBUG: Modem Serial Buffer = C: 1,,"","",",""TAAT+CIICR
DEBUG: Modem Serial Buffer = +PDP: R
ERROR: Timeout when calling AT+CIICR
 | elapsed ms = 0
ERROR: begin() failed at +CIICR
Cellular connection failed
Setup complete

been trying to see what I can figure out on this but, it’s still not working.

Hi @Chad_E

Had some time this afternoon to investigate the issue more. I believe this comes from not being connected to the local cell network. Either you have a faulty antenna or you’re in an area with no 2G service.

I went ahead and updated the library to v0.5.0. Now the library automatically heals the network connection if it is ever lost. This will not fix the issue if your area has no coverage but it will fix it if you temporarily drive through an area without coverage.