I went ahead and began using OTA to program my particle Electron until I can find the correct device drivers. However I’m working on sending a SMS message to a Phone Number and I’m using a button State drawing the pin D0 to low using a 1K pulldown resistor. When I push the button I simply connect the 3.3V to the DO and the D7 comes on… but it doesn’t turn off for some reason. I’ve double checked the circuit and it looks correct. Here’s the code. Not sure if my brackets will be recognized when I post code but here goes.
#define MAX_PHONE_NUMBER 14
#define CTRL_Z 0x1A
#define TIMEOUT 10000
boolean gain; // Gain setting, 0 = X1, 1 = X16;
unsigned int ms; // Integration ("shutter") time in milliseconds
unsigned int data1;
unsigned int data2;
const int buttonPin = D0; // the number of the pushbutton pin
const int ledPin = D7;
int buttonState = 1;
;
char szPhoneNumber[MAX_PHONE_NUMBER] = "+15155055000"; //just a random phone number
int lowerLimit = 10;
boolean smsSend = false;
int callback(int type, const char* buf, int len, char* param){
Serial.print("Return: ");
Serial.write((const uint8_t*)buf, len);
Serial.println();
return WAIT;
}
int setLowerLimit(String args){
lowerLimit = args.toInt();
return lowerLimit;
}
int sendMessage(char* pMessage){
char szCmd[64];
sprintf(szCmd, "AT+CMGS=\"+%s\",145\r\n", szPhoneNumber);
Serial.print("Sending command ");
Serial.print(szCmd);
Serial.println();
char szReturn[32] = "";
Cellular.command(callback, szReturn, TIMEOUT, "AT+CMGF=1\r\n");
Cellular.command(callback, szReturn, TIMEOUT, szCmd);
Cellular.command(callback, szReturn, TIMEOUT, pMessage);
sprintf(szCmd, "%c", CTRL_Z);
int retVal = Cellular.command(callback, szReturn, TIMEOUT, szCmd);
if(RESP_OK == retVal){
Serial.println("+OK, Message Send");
}
else{
Serial.println("+ERROR, error sending message");
}
return retVal;
}
void setup() {
Serial.begin(115200);
Spark.function("setmin", setLowerLimit);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
Serial.println();
Serial.println();
char szMessage[64];
strcpy(szMessage, "This is Particle Electron sending Text Message test!");
sendMessage(szMessage);
delay(1000);
}
else {
digitalWrite(ledPin, LOW);
}
}
For one it’s not sending the text message but the LED comes on… I’ve checked the connections and its not floating a high signal either so can anyone tell me what I might be doing wrong? Thanks