Fix nodemcu/statusclient: I now know what a reed switch is
This commit is contained in:
parent
63f9f25b00
commit
66bc266f2e
1 changed files with 10 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* file: statusclient.ino
|
||||
* desc: This file is part of the Krautspace Doorstatus project. It's the
|
||||
* main file for a client, who deals with the input from a read sensor and
|
||||
* main file for a client, who deals with the input from a reed sensor and
|
||||
* push these values to a server. The code is make to run on a NodeMCU with
|
||||
* ESP8266 chip.
|
||||
*/
|
||||
|
@ -23,7 +23,7 @@ namespace cpp23 {
|
|||
// defining some constants
|
||||
enum : uint8_t {
|
||||
LED_PIN = 16, // D0
|
||||
READ_PIN = 5 // D1
|
||||
REED_PIN = 5 // D1
|
||||
};
|
||||
|
||||
enum class door_state {
|
||||
|
@ -73,12 +73,12 @@ void init_serial() {
|
|||
|
||||
void init_pins() {
|
||||
/*
|
||||
* set gpio for read sensor and led
|
||||
* set gpio for reed sensor and led
|
||||
*/
|
||||
pinMode(READ_PIN, INPUT_PULLUP);
|
||||
pinMode(REED_PIN, INPUT_PULLUP);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("[Pin] LED and READ initialized");
|
||||
Serial.println("[Pin] LED and REED sensor initialized");
|
||||
}
|
||||
|
||||
void init_wifi() {
|
||||
|
@ -99,14 +99,14 @@ void init_wifi() {
|
|||
|
||||
door_state read_door_state() {
|
||||
/*
|
||||
* die initialisierung des read-pin mit pullup bewirkt, daß am pin
|
||||
* die initialisierung des reed-switch-pins mit pullup bewirkt, dass am pin
|
||||
* 3,3 volt anliegen. die verbindung des pins mit GND sorgt dafür,
|
||||
* daß die spannung "abfließen" kann. dadurch hat der pin dann den
|
||||
* dass die spannung "abfließen" kann. dadurch hat der pin dann den
|
||||
* status 'low'.
|
||||
* geschlossene tür -> read geschlossen -> low
|
||||
* geöffnete tür -> read offen -> high
|
||||
* geschlossene tür -> reed geschlossen -> low
|
||||
* geöffnete tür -> reed offen -> high
|
||||
*/
|
||||
return (digitalRead(READ_PIN) == HIGH) ? door_state::open : door_state::closed;
|
||||
return (digitalRead(REED_PIN) == HIGH) ? door_state::open : door_state::closed;
|
||||
}
|
||||
|
||||
void set_clock() {
|
||||
|
|
Loading…
Reference in a new issue