Confused about how to use wifi
Posted: Thu Feb 18, 2016 11:21 pm
So I'm using platformio to build and flash code I write in C++. I can get the ESP to work with the IRremote library for ESP8266 and now I would like to do some network calls over wifi.
But I can't figure out how. Do I need a specific library? Most of the ESP8266 C++ libraries I find seem to be for the Arduino to use the ESP with AT commands. That's not what I want.
I want the ESP to perform HTTP GET calls following certain IR signals.
I tried this:
with this library: https://github.com/ekstrand/ESP8266wifi
But I'm getting a compile error:
I'm very new to C++ and I don't know if I'm using the wrong library or if I'm missing some files or dependencies?
But I can't figure out how. Do I need a specific library? Most of the ESP8266 C++ libraries I find seem to be for the Arduino to use the ESP with AT commands. That's not what I want.
I want the ESP to perform HTTP GET calls following certain IR signals.
I tried this:
Code: Select all
#include "Arduino.h"
#include <IRremoteESP8266.h>
#include <IRremoteInt.h>
#include <ESP8266wifi.h>
const char* ssid = "mywifi"
const char* password = "mypassword"
const int VOL_UP = 0x490;
const int VOL_DOWN = 0xc90;
const int ARROW_UP = 0x385d;
int RECV_PIN = D2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void connectwifi() {
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println('.');
}
Serial.print("Wifi connected with IP: ");
Serial.println(WiFi.localIP());
}
void setup() {
Serial.begin(115200);
irrecv.enableIRIn();
connectwifi();
Serial.println("Listening for Sony beams");
}
void loop() {
irrecv.decode(&results);
if (irrecv.decode(&results)) {
if(results.decode_type == SONY) {
Serial.println(results.value, HEX);
switch(results.value) {
case VOL_UP:
Serial.println("VOL UP");
break;
case ARROW_UP:
Serial.println("ARROW UP");
break;
case VOL_DOWN:
Serial.println("VOL DOWN");
break;
}
}
irrecv.resume();
}
delay(350);
}
with this library: https://github.com/ekstrand/ESP8266wifi
But I'm getting a compile error:
Code: Select all
.pioenvs/esp12e/ESP8266Wifi/ESP8266wifi.h:23:26: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>
^
compilation terminated.
I'm very new to C++ and I don't know if I'm using the wrong library or if I'm missing some files or dependencies?