I'm getting the error message in the title and have no idea what it's on about- the board is connected. I'm using an ESP8266 to connect to wifi so it might be a problem with that?
Thanks in advance!
#include <fauxmoESP.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#include <Servo.h>
#define SERIAL_BAUDRATE 115200
#define WIFI_SSID "********"
#define WIFI_PASS "*******"
#define app1 "door close"
fauxmoESP fauxmo;
int servoPin = 7;
int bPin = 8;
Servo Servo1;
void wifiSetup() {
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
void setup() {
// put your setup code here, to run once:
Servo1.attach(servoPin);
Servo1.write(-100);
pinMode(bPin, INPUT);
Serial.begin(SERIAL_BAUDRATE);
wifiSetup();
fauxmo.createServer(true); // not needed, this is the default value
fauxmo.setPort(80); // This is required for gen3 devices
fauxmo.enable(true);
fauxmo.addDevice(app1);
fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state, unsigned char value) {
device_id, device_name, state ? "ON" : "OFF", value);
if ( (strcmp(device_name, app1) == 0) ) {
if (state) {
Serial.print("a");
} else {
Serial.print("b");
}
}
});
}
void loop() {
// put your main code here, to run repeatedly:
int pushed = digitalRead(bPin);
if (pushed == HIGH){
go();
}
fauxmo.handle();
static unsigned long last = millis();
if (millis() - last > 5000) {
last = millis();
}
if(Serial.available() > 0)
{
data = Serial.read();
Serial.print(data);
Serial.print("\n");
if(data == 'a')
go();
else if(data == 'b')
digitalWrite(4, LOW);
}
}
void go() {
Servo1.write(90);
delay(1000);
Servo1.write(-90);
delay(1000);
}
Is that the entire error message? In the IDE, there will be a "copy error message" button in the lower right of the IDE window. Copy the error and paste into a new post.
Serial.print("b");
}
}
}); // ************** this is probably not right
}
Your code would be easier to follow if it were indented in a standard manner. The IDE has the autoformat tool (ctrl-t or Tools, Auto Format) to do just that.
I downloaded a "flashing tool" for the esp8266 to try and get it to work, and it gave me new options for boards, but when I used any of them (including the normal Arduino UNO/genuino one) it gave me this error message:
Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Uno"
Build options changed, rebuilding all
In file included from /Users/USER/Documents/Arduino/libraries/ESP8266WiFi/src/WiFiClientSecure.h:41:0,
from /Users/USER/Documents/Arduino/libraries/ESP8266WiFi/src/WiFiServerSecure.h:20,
from /Users/USER/Documents/Arduino/servo1/servo1.ino:1:
/Users/USER/Documents/Arduino/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h:26:10: fatal error: vector: No such file or directory #include
^~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Okay so I went into the tools, downloaded the board for the esp8266 and set the board to "Generic ESP8266 module", and it's giving me a new error message that reads:
Arduino: 1.8.10 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Build options changed, rebuilding all
Multiple libraries were found for "WiFiServerSecure.h"
Used: /Users/USER/Documents/Arduino/libraries/ESP8266WiFi
Not used: /Users/USER/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/ESP8266WiFi
Multiple libraries were found for "Servo.h"
Used: /Users/USER/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/Servo
Not used: /private/var/folders/k9/_nyp1bq96nn4053t87qkhc100000gn/T/AppTranslocation/2EA1C980-F880-4104-A784-2EAE78323746/d/Arduino.app/Contents/Java/libraries/Servo
fork/exec /Users/USER/Library/Arduino15/packages/esp8266/tools/python3/3.7.2-post1/python3: no such file or directory
Error compiling for board Generic ESP8266 Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
CormAlan:
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
1/ Have you set "Show output during" options in File -> Preferences
2/ What are the exactt and complete references of your board ?
3/ Could you upload a screenshot of "File -> Preferences" window ?
Ok. The Arduino is connected to the computer, and the ESP8266 is connected to the Arduino. I've selected the Generic ESP8266 Module board in "Tools". The connection between the Arduino and esp8266 is this:
CormAlan:
I'm getting the error message in the title and have no idea what it's on about- the board is connected. I'm using an ESP8266 to connect to wifi so it might be a problem with that?
Okay I've attached a screencap of the preferences, and when I click "get board info" it gives me this:
BN: Arduino/Genuino Uno
VID: 0x2341
PID: 0x0043
SN: 55736323839351D090E1
Are you using a board equiped witn an ESP8266 or an Arduino/Genuino Uno ?
It seems you are using an Arduino/Genuino Uno. So in Tool/Board window of the IDE select "Arduino/Genuino Uno".
You can't use #include <ESP8266WiFi.h>
on an UNO.
Regards,
bidouilleelec
CormAlan:
Ok. The Arduino is connected to the computer, and the ESP8266 is connected to the Arduino. I've selected the Generic ESP8266 Module board in "Tools". The connection between the Arduino and esp8266 is this:
The code in your first post is ESP8266 code. As bidouilleelec pointed out, that will not work on an Uno and code written for an Uno will very likely not work with an ESP8266.
My I suggest, while you are developing the code, that you use a software serial port for the ESP so that you have the hardware serial (USB) free for uploading code, program output and debugging. Software serial ports do not work at more than 38400 baud so you need to take that into account.
void loop() {
// put your main code here, to run repeatedly:
int pushed = digitalRead(bPin);
if (pushed == HIGH){
go();
}
fauxmo.handle();
static unsigned long last = millis();
if (millis() - last > 5000) {
last = millis();
}
if(Serial.available() > 0)
{
data = Serial.read();
Serial.print(data);
Serial.print("\n");
if(data == 'a')
go();
else if(data == 'b')
digitalWrite(4, LOW);
}
}
It seems to me that you are mixing two sketches, one intended to be loaded on an ESP8266 and the other on a UNO to try to make a single sketch. That does not make sense.
Yeah, that's the exact tutorial I was using! Clearly, I don't know what I'm doing. Can't UNO code be mixed with the ESP8266 or do I need to disconnect it first?