Hello,
I am working on a remote start project for my car. It works very well sometimes, but I’m getting an annoying issue that I believe has to do with my setup function. I have the code written so the rgb led is lit while the board is running the setup function and then shuts off afterwards. Everything works correctly when the board boots immediately after uploading code to it, but when I unplug it and plug into a usb battery bank it only works sometimes. I can’t get it to work at all right now and I’m a bit lost. I’d appreciate some help. The led is turning on as it should, and then shuts off for a brief moment and turns right back on. It definitely shouldn’t be doing that, and doesn’t do it on successful boots. Seems like it’s rerunning the setup function or something.
Thanks,
Zain
Code:
String myPhone = “+1mynum”;
String iftttPhone = “+1iftttnum”;bool shouldSleep = false;
const int controlPin = R03;void lock() {
Serial.println(“Car is now locked”);digitalWrite(controlPin, HIGH);
Dash.snooze(100);
digitalWrite(controlPin, LOW);
}void unlock() {
Serial.println(“Car is now unlocked”);digitalWrite(controlPin, HIGH);
Dash.snooze(120);
digitalWrite(controlPin, LOW);
Dash.snooze(120);
digitalWrite(controlPin, HIGH);
Dash.snooze(120);
digitalWrite(controlPin, LOW);
}void start() {
Serial.println(“Car has been started”);digitalWrite(controlPin, HIGH);
Dash.snooze(4000);
digitalWrite(controlPin, LOW);
}void up() {
lock();
Dash.snooze(2000);
lock();
Serial.println(“Windows have been rolled up”);
}void executeCommand(String message) {
SerialCloud.println(“r”); // means successful command sent, will be
// interpreted on Hologram’s dashboard.if ((message == “lock”) || (message == “Lock”)) {
lock();
} else if ((message == “unlock”) || (message == “Unlock”)) {
unlock();
} else if ((message == “start”) || (message == “Start”)) {
start();
} else if ((message == “up”) || (message == “Up”)) {
up();
} else {
Serial.println(“No command parsed”);
}
}void smsHandler(const String &sender, const rtc_datetime_t ×tamp,
const String &message) {shouldSleep = false;
if ((sender == myPhone) || (sender == iftttPhone)) {
Serial.println("Command Recieved: ");
Serial.println(message);
executeCommand(message);
} else {
Serial.println("Command from unknown sender: ");
Serial.println(message);
}HologramCloud.setRGB(“AQUA”);
Dash.snooze(150);
HologramCloud.offRGB();
Dash.snooze(20);
shouldSleep = true;
}void setup() {
delay(1000);
Dash.begin();
HologramCloud.powerUp();
HologramCloud.connect();pinMode(controlPin, OUTPUT);
digitalWrite(controlPin, LOW);
HologramCloud.setRGB(“AQUA”);Serial.begin(9600);
SerialCloud.begin(115200);
HologramCloud.attachHandlerSMS(smsHandler);Serial.println(“Online”);
SerialCloud.println(“Online”);
delay(1000);
HologramCloud.offRGB();
shouldSleep = true;
}void loop() {
if ((shouldSleep) && ((HologramCloud.checkSMS()) == 0)) {
Dash.deepSleepSec(10);
shouldSleep = false;
if (!HologramCloud.isConnected()){
HologramCloud.powerUp();
HologramCloud.connect();
}
}Dash.snooze(100);
if (HologramCloud.checkSMS() == 0) {
shouldSleep = true;
}
}