Hello,
I have a problem, when my alarm turns on, I have the unfortunate habit of snoozing it 102 times before waking up... Wich brings me to my next problem : I'm trying to code an alarm that would turn on each day at 7AM and turn off only if I push a button placed as far away as possible from my bed (let's say the coffee machine). I'm planning on using two ESP8266 (ESP-01), a piezo buzzer and a push button... The first ESP makes the buzzer buzz at 7AM, to turn it off, I push the button connected to the other ESP, as simple has that ( or at least I thought )
Trying to code the program while waiting for the components, but with my godness level coding of 0%, I'm having trouble writing it correctly !
I did these two with parts of codes I found and modified them a little bit.
The "server" ESP ( AKA The buzzy one )
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
byte buzzer = 2;
char ssid[] = "Alladin";
char pass[] = "FlYING CARPET";
WiFiServer server(80);
IPAddress ip(192, 168, 0, 80);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);
const long utcOffsetInSeconds = 3600;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", utcOffsetInSeconds);
char Hours = timeClient.getHours();
char Minutes = timeClient.getMinutes();
char Seconds = timeClient.getSeconds();
WiFiClient client;
void setup() {
Serial.begin(115200); // only for debug
WiFi.config(ip, gateway, subnet); // forces to use the fix IP
WiFi.begin(ssid, pass); // connects to the WiFi router
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
server.begin(); // starts the server
}
void loop () {
timeClient.update();
if (Hours=="07")
(Minutes=="00")
(Seconds=="00");
{
if (client) {
if (client.connected()) {
String request = client.readStringUntil('\r');
while((request)==("He is still sleeping")) ;
{
Serial.println(".");
String request = client.readStringUntil('\r');
client.flush();
client.println("Waking him up\r");
digitalWrite(buzzer, LOW);
delay(500);
digitalWrite(buzzer, HIGH);
delay(500);
}
if ((request)==("He is awake !"));
{
client.stop();
digitalWrite(buzzer, LOW);
}
client.flush();
}
}
}
}
The error I get from the server ESP code
Arduino: 1.8.9 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, nonos-sdk 2.2.1 (legacy), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\CARLITO\Downloads\DHT_server_02\DHT_server_02.ino: In function 'void loop()':
DHT_server_02:40:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
if (Hours=="07")
^
DHT_server_02:41:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
(Minutes=="00")
^
DHT_server_02:42:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
(Seconds=="00");
^
DHT_server_02:42:18: error: expression cannot be used as a function
(Seconds=="00");
^
exit status 1
ISO C++ forbids comparison between pointer and integer [-fpermissive]
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
The "Client" ESP ( AKA The punched one )
#include <SPI.h>
#include <ESP8266WiFi.h>
byte button = 2;
char ssid[] = "I LOVE CATS";
char pass[] = "v3ry$ecureP4SSW0RD!";
unsigned long askTimer = 0;
IPAddress server(192,168,0,80);
WiFiClient client;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
pinMode(button, INPUT);
}
void loop () {
client.connect(server, 80);
client.println("He's still sleeping\r");
String answer = client.readStringUntil('\r');
if ((answer)==("Waking him up") );
{
if (digitalRead(button)==HIGH);
{
client.println("He's awake !\r");
}
}
client.flush();
delay(500);
}
I don't get any error from this one 8)
Do you have any idea of what's an "ISO C++ forbids comparison between pointer and integer [-fpermissive]" error and how to fix it ?
And what's the problem with line 33 ((Seconds=="00"); ) "error: expression cannot be used as a function ?"
Thank you !


