Am I even close? SIM800H for the Mobile Vote Box project


#1

It is my first project but I’ve spent weeks trying to figure this out before posting.

Here’s my sketch:


#include <HologramSIMCOM.h>

#define RX_PIN 2 //SIMCom RX - MCU TX
#define TX_PIN 3 //SIMCom TX - MCU RX
#define RESET_PIN 4 //SIMCom reset
#define HOLO_KEY "hidden<" //replace w/your SIM key
#define CONNECT_LED 12
#define VOTE1_BTN_PIN 6
#define VOTE1_LED_PIN 7
#define VOTE2_BTN_PIN 9
#define VOTE2_LED_PIN 10

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

String VOTE1_VALUE = "chicago";
String VOTE2_VALUE = "newYork";
String HOLOGRAM_TOPIC = "vote";

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

  // Start modem and connect to Hologram's global network
  Hologram.debug();

  //set modes for used pins
  pinMode(CONNECT_LED, OUTPUT);
  pinMode(VOTE1_BTN_PIN, INPUT);
  pinMode(VOTE1_LED_PIN, OUTPUT);
  pinMode(VOTE2_BTN_PIN, INPUT);
  pinMode(VOTE2_LED_PIN, OUTPUT);
  
  bool cellConnected = Hologram.begin(9600, 8888); // set baud to 19200 and start server on port 8888
  if(cellConnected) {
    digitalWrite(CONNECT_LED, HIGH);
  }
}

void loop() {
  Hologram.debug();

  if(digitalRead(VOTE1_BTN_PIN) == HIGH) {
    sendVote(VOTE1_VALUE,VOTE1_LED_PIN);
  }

  if(digitalRead(VOTE2_BTN_PIN) == HIGH) {
   sendVote(VOTE2_VALUE,VOTE2_LED_PIN);
  }
}

void sendVote(String VOTE_VALUE, const int VOTE_LED) {
  digitalWrite(VOTE_LED, HIGH); 
  // send to the Hologram Data Router
  if(Hologram.send(VOTE_VALUE, HOLOGRAM_TOPIC)) {
    // blink LED if vote was successful
    // this is crappy code, consider refactoring
    digitalWrite(VOTE_LED, LOW);
    delay(100);
    digitalWrite(VOTE_LED, HIGH);
    delay(100);
    digitalWrite(VOTE_LED, LOW);
    delay(100);
    digitalWrite(VOTE_LED, HIGH);
    delay(100);
    digitalWrite(VOTE_LED, LOW);
  } else {
    digitalWrite(VOTE_LED, LOW);
  }
}

Thanks for all ideas.


#2

And here is the verbose serial response:

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+CSQ

DEBUG: Modem Serial Buffer = AT+CSQ
DEBUG: Modem Serial Buffer = +CSQ: 0,0
ERROR: no signal
DEBUG: Modem Serial Buffer = OK
DEBUG: Write Modem Serial = AT+CGATT?

DEBUG: Modem Serial Buffer = AT+CGATT?
DEBUG: Modem Serial Buffer = +CGATT: 0
DEBUG: Modem Serial Buffer = OK
ERROR: Timeout when calling AT+CGATT?
| elapsed ms = 0
DEBUG: Write Modem Serial = AT+CIPSTATUS?

DEBUG: Modem Serial Buffer = AT+CIPSTATUS?
DEBUG: Write Modem Serial = AT+CIPMUX?

DEBUG: Modem Serial Buffer = ERROR
DEBUG: Modem Serial Buffer = AT+CIPMUX?
DEBUG: Modem Serial Buffer = +CIPMUX: 0
ERROR: Error resp when calling AT+CIPMUX?

DEBUG: Write Modem Serial = AT+CIFSR

DEBUG: Modem Serial Buffer = OK
DEBUG: Modem Serial Buffer = AT+CIFSR
DEBUG: Modem Serial Buffer = ERROR
ERROR: Error resp when calling AT+CIFSR

DEBUG: Write Modem Serial = AT+CSQ

DEBUG: Modem Serial Buffer = AT+CSQ
DEBUG: Modem Serial Buffer = +CSQ: 0,0
DEBUG: Write Modem Serial = AT+CIPSHUT

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

DEBUG: Modem Serial Buffer = AT+CSQ
DEBUG: Modem Serial Buffer = +CSQ: 0,0
ERROR: no signal
ERROR: unable to connect to cellular network


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.