I'm a beginner with the arduino and lua language. editing 2 working scripts to get what i need done.
i have an ldr connected to my esp8266 i need the code to publish to an mqtt topic when a set threshold is read. However, i keep seeing this error: expected initializer before '}' token
What am i doing wrong?
Any help is much appreciated.
void setup() {
pinMode(13, OUTPUT); //pin connected to the relay
Serial.begin(115200); //sets serial port for communication
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, wifi_password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
// Debugging - Output the IP Address of the ESP8266
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// Connect to MQTT Broker
// client.connect returns a boolean value to let us know if the connection was successful.
if (client.connect(clientID)) {
Serial.println("Connected to MQTT Broker!");
}
else {
Serial.println("Connection to MQTT Broker failed...");
}
void loop()
{
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue); //prints the values coming from the sensor on the screen
if (sensorValue < 700) //setting a threshold value
//digitalWrite(2,HIGH); //turn relay ON
client.publish(mqtt_topic, "Button pressed!");
else digitalWrite(2, LOW); //turn relay OFF
delay(100);
}