// -----------------------------BNT SCB----------------------------- //
// BNT.IO SensorControllerBoard
// By Dominic Brand
// Version 1.0
// Using HC-SR04 Module
// Created at 01 June 2022
// ---------------------------------------------------------------- //
// ---------------------------------------------------------------- //
// TO-DO:
// - JSON string fügt werte hinzu (UltraSonic - DOOR) sich, weil configJson Global initialisiert wird. Evtl. Reseten
// - Init von Sender empfangen und Sensoren dementsprechen Aktivieren und initialisieren + Config Json beschreiben respektive Globals.h variabeln.
// - Polling erst starten, wenn Init befehl Seriel ankommt.
// - Sensor auf high oder low variabel mit config
//
// Weitere Sensoren:
// - Licht (Photoresistor)
// - Temperatur (Warnstufen: -20 C-> zu kalt; 50 C -> zu Warm; 150 C -> Alarm Feuer)
// - Evtl. LCD auf auf die Platine mit werten
// ---------------------------------------------------------------- //
#include "Sensors.h"
#include "HopperSensor.h"
#include "DoorSensor.h"
#include "TempSensor.h"
#include "UltraSonic.h"
#include "Globals.h"
bool isInitDone = false;
String JSON = "";
String ProductName = "BNT-SCB";
int ProductVersion = 1;
int ProductRevision = 0;
void Init();
void MsgReceived();
void getName();
void setup() {
Serial.begin(115200);
Init();
getName();
}
void loop() {
if (Serial.available() > 0) {
// read the incoming string:
String JSON = Serial.readString();
}
if(JSON != ""){
MsgReceived(JSON);
}
if(isInitDone){
Polling();
}
}
void Init(){
if(HopperSensorIsActive){
SetupDoorSensor(DoorAlertPin);
}
if(DoorSensorIsActive){
SetupHopperSensor(HopperAlertPin);
}
if(UltraSonicSensorIsActive){
SetupUltrasonicSensor(trigPin, echoPin);
}
if(TempSensorIsActive){
SetupTempSensor();
}
isInitDone = true;
}
void getName(){
configJSON["Device"] = Productname;
configJSON["Version"] = ProductVersion;
configJSON["Rev"] = ProductRevision;
serializeJson(configJSON, Serial);
Serial.write("\n");
configJSON.clear();
}
void MsgReceived(String Msg){
Serial.println(Msg);
}