TrigBoard Ultimate System

From Kevin Darrah Wiki
Revision as of 23:30, 26 July 2019 by Krdarrah (talk | contribs)
Jump to: navigation, search

...Back to Projects:

TrigBoardUltimate.png

  • trigBoards are used in a normal way monitoring doors/windows/etc... or even modified to detect flooding, motion, force, or whatever. It does this and maintains long battery life due to its extremely low standby current. See the trigBoard page for more details. With the Ultimate system described here, this is the difference:
    • Uses ESPNow, which is an efficient point to point communication protocol. This means that when the trigBoards are triggered, they do not connect to the local WiFi network, but rather send an encrypted message to a gateway. It only takes ~1second to complete the transmission, which further improves battery life.
  • No WiFi here, instead a trigBoard is configured as an ESPNow "receiver". All trigBoards used for sensors are configured to transmit to this trigBoard "gateway". This is nice because the system does not rely on a WiFi network being up running and reliably connected to the internet.
  • Cellular using a Particle Boron module which does many things for the system here. This gives a nice reliable way to get the messages out without the need for WiFi. Also, these modules can be powered from USB power and/or a lithium battery. That means this is a battery backed system as well! Now, if the power goes out, the messages can still get out.
  • The cellular module sends the messages out with the use of Particle's cloud and Webhook integrations. This keeps the data payloads light and things super easy to setup and modify if needed.
  • Push Safer is used send push notifications out to any mobile device - this is the same service as described on the trigBoard page.
  • IO Adafruit is used for the monitoring devices, so they can subscribe to a value there. Any time it changes, these monitoring devices are notified and can alarm/buzz. In this system, an MP3 player with audio amplifier is used to speak out various messages based on which trigBoard was triggered - "The front door has opened" or "The garage door is still open"

Cellular Side

This code runs on the Particle Cellular module - just copy and paste this over to the web IDE https://build.particle.io/

String str1,str2;

void setup() {
    Serial.begin(115200);//debug
    Serial1.begin(9600);//from trigBoard
    
}

void loop() {
  if (Serial1.available() > 0) {// new data came in
     Serial.println("New Data");
     str1 = Serial1.readStringUntil('$');//that's the separator
     str2 = Serial1.readStringUntil('\0');
     sendData();
  }
}

void sendData(){
     unsigned long startConnectTime = millis();
     char pushMessage[50], pushName[50];
     str1.toCharArray(pushName, str1.length() + 1);
     str2.toCharArray(pushMessage, str2.length() + 1);
     Serial.println(str1);
     Serial.println(str2);
     
     String adaFruitData = "[{\"key\":\"house\", \"value\":\"";
     adaFruitData.concat(str1);
     adaFruitData.concat("\"}]");
     Particle.publish("homeSecurityPost", adaFruitData, PRIVATE, NO_ACK);//first send off to adafruit so our monitors can beep and do their thing
     
     String pushSaferPacket = "[{\"key\":\"t\", \"value\":\"";
     pushSaferPacket.concat(str1);
     pushSaferPacket.concat("\"},");
     pushSaferPacket.concat("{\"key\":\"m\", \"value\":\"");
     pushSaferPacket.concat(str2);
     pushSaferPacket.concat("\"}]");
     Particle.publish("pushSafer", pushSaferPacket, PRIVATE);//then send to push safer so we get the notifications on our mobile devices

     Serial.print(millis() - startConnectTime);
     Serial.println("ms to connect");
}