-->
Page 1 of 1

Confused about how to use wifi

PostPosted: Thu Feb 18, 2016 11:21 pm
by OnlineDishwasher
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?

Re: Confused about how to use wifi

PostPosted: Fri Feb 19, 2016 8:48 am
by martinayotte
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.

Re: Confused about how to use wifi

PostPosted: Fri Feb 19, 2016 8:57 am
by OnlineDishwasher
This is why! Thanks