Hey Ho I want to control 4 Float switches they show me status if on or off.
Show them in Alexa to control Wifi switch AC Pump or magnetic valve.
I have one ESP8266 to control that. For control float switch led is on or off I want to take onboard LED
// Float switch
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define SERIAL_BAUDRATE 115200
fauxmoESP fauxmo;
// -----------------------------------------------------------------------------
// Wifi definieren
// -----------------------------------------------------------------------------
#define WIFI_SSID "ssid"
#define WIFI_PASS "pass"
// -----------------------------------------------------------------------------
// PINs definieren
// -----------------------------------------------------------------------------
#define FLOAT_SENSOR_1 2 // the number of the pushbutton pin 1
#define FLOAT_SENSOR_2 3 // the number of the pushbutton pin 2
#define FLOAT_SENSOR_3 4 // the number of the pushbutton pin 3
#define FLOAT_SENSOR_4 5 // the number of the pushbutton pin 3
#define LED 13 // the number of the LED pin
void wifiSetup() {
// Set WIFI module to STA mode
WiFi.mode(WIFI_STA);
// Verbinden
Serial.printf("[WIFI] Verbindung zu %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Warten
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
// Verbunden!
Serial.printf("[WIFI] Router WLAN, SSID: %s, IP Adresse: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
void callback(uint8_t device_id, const char * device_name, bool state) {
Serial.printf("[Funktion] %s Status: %s\n", device_name, state ? "AN" : "AUS");
}
void setup()
{
// initialize the LED pin as an output:
pinMode(LED, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(FLOAT_SENSOR_1, INPUT_PULLUP);
// initialize the pushbutton pin as an input:
pinMode(FLOAT_SENSOR_2, INPUT_PULLUP);
// initialize the pushbutton pin as an input:
pinMode(FLOAT_SENSOR_3, INPUT_PULLUP);
// initialize the pushbutton pin as an input:
pinMode(FLOAT_SENSOR_4, INPUT_PULLUP);
}
void loop() {
{
if(digitalRead(FLOAT_SENSOR_1) == LOW)
// turn LED on:
digitalWrite(LED, HIGH);
else
// turn LED off:
digitalWrite(LED, LOW);
if(digitalRead(FLOAT_SENSOR_2) == LOW)
// turn LED on:
digitalWrite(LED, HIGH);
else
// turn LED off:
digitalWrite(LED, LOW);
if(digitalRead(FLOAT_SENSOR_3) == LOW)
// turn LED on:
digitalWrite(LED, HIGH);
else
// turn LED off:
digitalWrite(LED, LOW);
if(digitalRead(FLOAT_SENSOR_4) == LOW)
// turn LED on:
digitalWrite(LED, HIGH);
else
// turn LED off:
digitalWrite(LED, LOW);
}
}
// Wifi
wifiSetup();
// -----------------------------------------------------------------------------
// Endgeraete Namen definieren
// -----------------------------------------------------------------------------
// Fauxmo
fauxmo.addDevice("Sensor 1");
fauxmo.addDevice("Sensor 2");
fauxmo.addDevice("Sensor 3");
fauxmo.addDevice("Sensor 4");
fauxmo.onMessage(callback);
}
uint8 _tj = 0;
void loop() {
fauxmo.handle();
}
I get these error message!!!
Float-Switch-Alexa:89:18: error: expected constructor, destructor, or type conversion before ';' token
wifiSetup();
^
Float-Switch-Alexa:95:7: error: 'fauxmo' does not name a type
fauxmo.addDevice("Sensor 1");
^
Float-Switch-Alexa:96:7: error: 'fauxmo' does not name a type
fauxmo.addDevice("Sensor 2");
^
Float-Switch-Alexa:97:7: error: 'fauxmo' does not name a type
fauxmo.addDevice("Sensor 3");
^
Float-Switch-Alexa:98:7: error: 'fauxmo' does not name a type
fauxmo.addDevice("Sensor 4");
^
Float-Switch-Alexa:100:7: error: 'fauxmo' does not name a type
fauxmo.onMessage(callback);
^
Float-Switch-Alexa:101:5: error: expected declaration before '}' token
}
^
exit status 1
expected constructor, destructor, or type conversion before ';' token
i'm to stupid to find right coding
thaks a lot for help!!!