Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By OnlineDishwasher
#41417 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:
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?
User avatar
By martinayotte
#41448 The library you mentioned link above is one for Arduino AVR connected to an ESP.

To use Wifi in in ArduinoESP, the libraries are already provided by the core, for example the .platformio/packages/framework-arduinoespressif/libraries/ESP8266WiFi/examples/WiFiClient.