Hy pro's,
i become from the following code at compiling so very bad errors......
Hardware nodemcu V3 , Arduino IDE 1.8.8, IDE Parameter Generic esp8266 module
Sketch
#include <IRremoteESP8266.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <IRrecv.h>
#include <IRsend.h>
#include <IRutils.h>
int RECV_PIN = 5; // =ESP8266 Pin D1 verbunden mit OUT des OS-1838B
IRrecv irrecv(RECV_PIN);
decode_results results;
// Netzwerk Einstellungen
const char* ssid = ""; //SSID des WLAN
const char* password = ""; //Passwort des WLAN
const char* host = ""; //IP des Servers, der die IR Codes an ein Unterhaltungsgerät schickt
IPAddress ip(); //Feste IP des Servers, frei wählbar, muss mit Client Sketch übereinstimmen (Variable host)
IPAddress gateway(); //Gatway (IP Router eintragen)
IPAddress subnet(255,255,255,0); //Subnet Maske
WiFiClient client;
uint16_t rawCodes[RAWBUF]; // [The durations if raw]
int codeLen; // [The length of the code]
//[Get the infrared codes from remote]
void storeCode(decode_results *results)
{
int count = results->rawlen;
Serial.println("IR Codes empfangen");
codeLen = results->rawlen - 1;
for (int i = 1; i <= codeLen; i++)
{
if (i % 2)
{
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; // Mark
Serial.print(" m");
}
else
{
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; // Space
Serial.print(" s");
}
Serial.print(rawCodes[i - 1], DEC);
}
Serial.println("");
}
void setup()
{
Serial.begin(115200); // debugging
WiFi.begin(ssid, password); // WLAN starten
WiFi.config(ip, gateway, subnet);
Serial.println("WiFi Verbindung wird aufgebaut");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Eigene IP des ESP-Modul: ");
Serial.println(WiFi.localIP());
irrecv.enableIRIn(); // Receiver starten FEHLT IM ORIGINAL SKETCH!!!
}
void sendIR() //senden der IR Codes über WLAN
{
if (client.connect(host, 80))
{
Serial.println("Sende Codes"); // debugging
client.print("GET /");
for (int i = 0; i < codeLen; i++)
{
client.print(rawCodes[i]);
}
client.println(" HTTP/1.1");
client.println("Hallo Server"); // debugging
client.println();
client.println();
client.stop();
}
else // debugging
{
Serial.println("Keine Verbindung zum Server");
}
}
void loop()
{
if (irrecv.decode(&results))
{
storeCode(&results);
sendIR();
irrecv.resume(); // Receive the next value
}
}
Errors
irSender:44:19: error: 'RAWBUF' was not declared in this scope
uint16_t rawCodes[RAWBUF]; // [The durations if raw]
^
C:\Users\Lenovo\AppData\Local\Temp\arduino_modified_sketch_244984\irSender.ino: In function 'void storeCode(decode_results*)':
irSender:57:11: error: 'rawCodes' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; // Mark
^
irSender:57:48: error: 'USECPERTICK' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; // Mark
^
irSender:57:62: error: 'MARK_EXCESS' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS; // Mark
^
irSender:62:11: error: 'rawCodes' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; // Space
^
irSender:62:48: error: 'USECPERTICK' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; // Space
^
irSender:62:62: error: 'MARK_EXCESS' was not declared in this scope
rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS; // Space
^
irSender:65:20: error: 'rawCodes' was not declared in this scope
Serial.print(rawCodes[i - 1], DEC);
^
C:\Users\Lenovo\AppData\Local\Temp\arduino_modified_sketch_244984\irSender.ino: In function 'void sendIR()':
irSender:96:22: error: 'rawCodes' was not declared in this scope
client.print(rawCodes[i]);
^
exit status 1
'RAWBUF' was not declared in this scope
Could anybody say whats wrong with the code, i didn't have no more newbeeideas what can i do.
Thx