Bom dia, por favor eu não consigo encontrar essas duas bibliotecas para o ESP8266, são elas: ESPWiFi.h e ESPHTTPClient.h. Alguém sabe onde posso encontra-las?

Exibições: 713

Responder esta

Respostas a este tópico

Boa tarde, Luiz. 

Se esta com dúvidas sobre como instalar bibliotecas, sugiro a leitura do meu tutorial:

Tutorial: Arduino - Instalando Bibliotecas (leia tudo)

http://labdegaragem.com/profiles/blogs/tutorial-arduino-instalando-...

O problema não é a instalação das bibliotecas, elas estão instaladas mais não sei porque a IDE não as usa, ou não as reconhece.

A Biblioteca só é reconhecida após a reinicialização da IDE Arduino. 

Como informei no tutorial

Informe o link das bibliotecas, que você instalou.

Qual procedimento usou?

Boa noite baixei do Github para a Área de Trabalho, e através da IDE Arduino baixar biblioteca ZIP.

https://github.com/willdurand/EspWiFi

https://github.com/Caerbannog/esphttpcliet

Essas são as três bibliotecas que iniciam o programa:

#include <JsonListener.h>
#include <ESPWiFi.h>
#include <ESPHTTPClient.h>

Essas são as três bibliotecas que iniciam o programa:

#include <JsonListener.h>
#include <ESPWiFi.h>
#include <ESPHTTPClient.h>

Luiz você enviou os links incorretamente.

O Link correto :

https://github.com/willdurand/EspWiFi

Essa biblioteca é muito antiga, tem 6 anos. Não é uma biblioteca certificada pelo Arduino. 

Baixei o arquivo zipado EspWiFi-master.zip.

E instalei com o gerenciador de Bibliotecas do Arduino. 

Compilei com sucesso, o sketch de exemplo:

https://github.com/willdurand/EspWiFi/tree/master/examples/client

Tente fazer o mesmo e nos informe. 

Você esta fazendo algo errado....

Teste uma biblioteca de cada vez.

Você não informou qual o programa que esta testando. 

Comentário de José Gustavo Abreu Murta em 10 julho 2016 às 13:21Excluir comentário

Instalação de Bibliotecas Arduino  zipadas:

Muitas vezes quando vamos usar um dispositivo ou módulo para Arduino, é necessário a instalação de um Biblioteca com os programas dedicados para o mesmo. 

A grande parte das Bibliotecas são disponibilizadas pelo fabricante ou desenvolvedor de um dispositivo para Arduino. Atualmente, estão usando o site GitHub para arquivar essas bibliotecas. 

A grande vantagem do GitHub é a padronização e a facilidade de acesso aos arquivos, aos fontes e aos exemplos. E tudo documentado. 

https://github.com/

Vou exemplificar a instalação de um biblioteca acessando o GitHub.  Por exemplo , se você deseja montar esse sensor DHT de temperatura e umidade, seguindo o tutorial da Adafruit, vai achar uma nova biblioteca para o mesmo. 

https://learn.adafruit.com/dht

Podem existir outras bibliotecas para esse mesmo tipo de sensor.

Mas esse é o  link da biblioteca Adafruit para o sensor DHT  :

https://github.com/adafruit/DHT-sensor-library

Para fazer o download de todos aquivos da Biblioteca, clique no campo Clone or Download

Baixe o arquivado zipado no seu computador - Download ZIP. 

Não precisa descompactar os arquivados zipados ! A própria IDE do Arduino já faz isso para a gente.

Abra a IDE do Arduino. Clique em Sketch, Incluir Biblioteca e depois Adicionar biblioteca.ZIP.

Quando aparecer a janela para selecionar o arquivo zipado, escolha a pasta onde fez o download e clique no arquivo da biblioteca. Assim que o arquivo zipado for instalado, feche e abra novamente a IDE do Arduino. 

Só assim , a biblioteca e os exemplos poderão ser acessados.  Para certificar que a Biblioteca foi instalada corretamente, clique em Sketch, Incluir Biblioteca e veja que agora aparece a opção na lista de Bibliotecas :

DHT sensor Library !

O esquema e de um Kit de uma estação meteorológica experimental, com o seguinte programa:

#include <JsonListener.h>
#include <ESPWiFi.h>
#include <ESPHTTPClient.h>
// time
#include <time.h> // time() ctime()
#include <sys/time.h> // struct timeval
#include <coredecls.h> // settimeofday_cb()

#include "SSD1306Wire.h"
#include "OLEDDisplayUi.h"
#include "Wire.h"
#include "OpenWeatherMap.h"
#include "OpenWeatherMapForecast.h"
#include "WeatherStationFonts.h"
#include "WeatherStationImages.h"
#include <ESP8266WiFi.h>

#include <Adafruit_BMP085.h>

/***************************
* WIFI Settings
**************************/
const char* WIFI_SSID = "Red_River 2";
const char* WIFI_PWD = "4832637157";

/***************************
* Begin DHT11 Settings
**************************/
WiFiClient client;
const char *host = "api.thingspeak.com"; //IP address of the thingspeak server
const char *api_key ="6F21LYFFCYATUDUS"; //Your own thingspeak api_key
const int httpPort = 80;
#define pin 14 // ESP8266-12E D5 read emperature and Humidity data
int temp = 0; //temperature
int humi = 0; //humidity
void readTemperatureHumidity();
void uploadTemperatureHumidity();
long readTime = 0;
long uploadTime = 0;

/***************************
* Begin Atmosphere and Light Sensor Settings
**************************/
void readLight();
void readAtmosphere();
Adafruit_BMP085 bmp;
const int Light_ADDR = 0b0100011; // address:0x23
const int Atom_ADDR = 0b1110111; // address:0x77
int tempLight = 0;
int tempAtom = 0;

/***************************
* Begin Settings
**************************/
#define TZ 2 // (utc+) TZ in hours
#define DST_MN 60 // use 60mn for summer time in some countries

// Setup
const int UPDATE_INTERVAL_SECS = 20 * 60; // Update every 20 minutes
// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c;
#if defined(ESP8266)
//const int SDA_PIN = D1;
//const int SDC_PIN = D2;

const int SDA_PIN = D3;
const int SDC_PIN = D4;
#else
//const int SDA_PIN = GPIO5;
//const int SDC_PIN = GPIO4

const int SDA_PIN = GPIO0;
const int SDC_PIN = GPIO2
#endif


// OpenWeatherMap Settings
// Sign up here to get an API key:
// https://docs.thingpulse.com/how-tos/openweathermap-key/
const boolean IS_METRIC = true;
// Add your own thingpulse ID
String OPEN_WEATHER_MAP_APP_ID = "ed121a12e29d5b9d0e15a68de9a6f88e";
String OPEN_WEATHER_MAP_LOCATION = "Zurich,CH";

// Pick a language code from this list:
// Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el,
// English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl,
// Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr,
// Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl,
// Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk,
// Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi,
// Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.

String OPEN_WEATHER_MAP_LANGUAGE = "en";
const uint8_t MAX_FORECASTS = 4;

// Adjust according to your language
const String WDAY_NAMES[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
const String MONTH_NAMES[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};

/***************************
* End Settings
**************************/
// Initialize the oled display for address 0x3c
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
OLEDDisplayUi ui( &display );

OpenWeatherMapCurrentData currentWeather;
OpenWeatherMapCurrent currentWeatherClient;

OpenWeatherMapForecastData forecasts[MAX_FORECASTS];
OpenWeatherMapForecast forecastClient;

#define TZ_MN ((TZ)*60)
#define TZ_SEC ((TZ)*3600)
#define DST_SEC ((DST_MN)*60)
time_t now;

// flag changed in the ticker function every 10 minutes
bool readyForWeatherUpdate = false;
String lastUpdate = "--";
long timeSinceLastWUpdate = 0;
//declaring prototypes
void drawProgress(OLEDDisplay *display, int percentage, String label);
void updateData(OLEDDisplay *display);
void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex);
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
void setReadyForWeatherUpdate();


// Add frames
// this array keeps function pointers to all frames
// frames are the single views that slide from right to left
FrameCallback frames[] = { drawDateTime, drawCurrentWeather, drawForecast };
int numberOfFrames = 3;

OverlayCallback overlays[] = { drawHeaderOverlay };
int numberOfOverlays = 1;

void setup() {
Serial.begin(115200);

Wire.begin(0,2);

Wire.beginTransmission(Atom_ADDR);
//initialize Atmosphere sensor
if (!bmp.begin()) {
Serial.println("Could not find BMP180 or BMP085 sensor at 0x77");
}else{
Serial.println("Find BMP180 or BMP085 sensor at 0x77");
}
Wire.endTransmission();

//initialize light sensor
Wire.beginTransmission(Light_ADDR);
Wire.write(0b00000001);
Wire.endTransmission();

// initialize dispaly
display.init();
display.clear();
display.display();

//display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setContrast(255);

WiFi.begin(WIFI_SSID, WIFI_PWD);

int counter = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
display.clear();
display.drawString(64, 10, "Connecting to WiFi");
display.drawXbm(46, 30, 8, 8, counter % 3 == 0 ? activeSymbole : inactiveSymbole);
display.drawXbm(60, 30, 8, 8, counter % 3 == 1 ? activeSymbole : inactiveSymbole);
display.drawXbm(74, 30, 8, 8, counter % 3 == 2 ? activeSymbole : inactiveSymbole);
display.display();

counter++;
}
// Get time from network time service
configTime(TZ_SEC, DST_SEC, "pool.ntp.org");
ui.setTargetFPS(30);
ui.setActiveSymbol(activeSymbole);
ui.setInactiveSymbol(inactiveSymbole);
// You can change this to
// TOP, LEFT, BOTTOM, RIGHT
ui.setIndicatorPosition(BOTTOM);
// Defines where the first frame is located in the bar.
ui.setIndicatorDirection(LEFT_RIGHT);
// You can change the transition that is used
// SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN
ui.setFrameAnimation(SLIDE_LEFT);
ui.setFrames(frames, numberOfFrames);
ui.setOverlays(overlays, numberOfOverlays);
// Inital UI takes care of initalising the display too.
ui.init();
Serial.println("");
updateData(&display);
while (!client.connect(host, httpPort)) {
Serial.println("Connection Failed");
}

}

void loop() {
//Read Temperature Humidity every 5 seconds
if(millis() - readTime > 5000){
readTemperatureHumidity();
readLight();
readAtmosphere();
readTime = millis();
}
//Upload Temperature Humidity every 60 seconds
if(millis() - uploadTime > 60000){
uploadTemperatureHumidity();
uploadTime = millis();
}

if (millis() - timeSinceLastWUpdate > (1000L*UPDATE_INTERVAL_SECS)) {
setReadyForWeatherUpdate();
timeSinceLastWUpdate = millis();
}

if (readyForWeatherUpdate && ui.getUiState()->frameState == FIXED) {
updateData(&display);
}

int remainingTimeBudget = ui.update();

if (remainingTimeBudget > 0) {
// You can do some work here
// Don't do stuff if you are below your
// time budget.
delay(remainingTimeBudget);
}
}

void drawProgress(OLEDDisplay *display, int percentage, String label) {
display->clear();
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
display->drawString(64, 10, label);
display->drawProgressBar(2, 28, 124, 10, percentage);
display->display();
}

void updateData(OLEDDisplay *display) {
drawProgress(display, 10, "Updating time...");
drawProgress(display, 30, "Updating weather...");
currentWeatherClient.setMetric(IS_METRIC);
currentWeatherClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
currentWeatherClient.updateCurrent(&currentWeather, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION);
drawProgress(display, 50, "Updating forecasts...");
forecastClient.setMetric(IS_METRIC);
forecastClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
uint8_t allowedHours[] = {12};
forecastClient.setAllowedHours(allowedHours, sizeof(allowedHours));
forecastClient.updateForecasts(forecasts, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION, MAX_FORECASTS);
readyForWeatherUpdate = false;
drawProgress(display, 100, "Done...");
delay(1000);
}

void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
now = time(nullptr);
struct tm* timeInfo;
timeInfo = localtime(&now);
char buff[16];


display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
String date = WDAY_NAMES[timeInfo->tm_wday];

sprintf_P(buff, PSTR("%s, %02d/%02d/%04d"), WDAY_NAMES[timeInfo->tm_wday].c_str(), timeInfo->tm_mday, timeInfo->tm_mon+1, timeInfo->tm_year + 1900);
display->drawString(64 + x, 5 + y, String(buff));
display->setFont(ArialMT_Plain_24);

sprintf_P(buff, PSTR("%02d:%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec);
display->drawString(64 + x, 15 + y, String(buff));
display->setTextAlignment(TEXT_ALIGN_LEFT);
}

void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
display->setFont(ArialMT_Plain_10);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(64 + x, 38 + y, currentWeather.description);

display->setFont(ArialMT_Plain_24);
display->setTextAlignment(TEXT_ALIGN_LEFT);
String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F");
display->drawString(60 + x, 5 + y, temp);

display->setFont(Meteocons_Plain_36);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->drawString(32 + x, 0 + y, currentWeather.iconMeteoCon);
}


void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
drawForecastDetails(display, x, y, 0);
drawForecastDetails(display, x + 44, y, 1);
drawForecastDetails(display, x + 88, y, 2);
}

void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex) {
time_t observationTimestamp = forecasts[dayIndex].observationTime;
struct tm* timeInfo;
timeInfo = localtime(&observationTimestamp);
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
display->drawString(x + 20, y, WDAY_NAMES[timeInfo->tm_wday]);

display->setFont(Meteocons_Plain_21);
display->drawString(x + 20, y + 12, forecasts[dayIndex].iconMeteoCon);
String temp = String(forecasts[dayIndex].temp, 0) + (IS_METRIC ? "°C" : "°F");
display->setFont(ArialMT_Plain_10);
display->drawString(x + 20, y + 34, temp);
display->setTextAlignment(TEXT_ALIGN_LEFT);
}

void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
now = time(nullptr);
struct tm* timeInfo;
timeInfo = localtime(&now);
char buff[14];
sprintf_P(buff, PSTR("%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min);

display->setColor(WHITE);
display->setFont(ArialMT_Plain_10);
display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 54, String(buff));
display->setTextAlignment(TEXT_ALIGN_RIGHT);
String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F");
display->drawString(128, 54, temp);
display->drawHorizontalLine(0, 52, 128);
}

void setReadyForWeatherUpdate() {
Serial.println("Setting readyForUpdate to true");
readyForWeatherUpdate = true;
}

//read temperature humidity data
void readTemperatureHumidity(){
int j;
unsigned int loopCnt;
int chr[40] = {0};
unsigned long time1;
bgn:
delay(2000);
//Set interface mode 2 to: output
//Output low level 20ms (>18ms)
//Output high level 40μs
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
delay(20);
digitalWrite(pin, HIGH);
delayMicroseconds(40);
digitalWrite(pin, LOW);
//Set interface mode 2: input
pinMode(pin, INPUT);
//High level response signal
loopCnt = 10000;
while (digitalRead(pin) != HIGH){
if (loopCnt-- == 0){
//If don't return to high level for a long time, output a prompt and start over
Serial.println("HIGH");
goto bgn;
}
}
//Low level response signal
loopCnt = 30000;
while (digitalRead(pin) != LOW){
if (loopCnt-- == 0){
//If don't return low for a long time, output a prompt and start over
Serial.println("LOW");
goto bgn;
}
}
//Start reading the value of bit1-40
for (int i = 0; i < 40; i++){
while (digitalRead(pin) == LOW){}
//When the high level occurs, write down the time "time"
time1 = micros();
while (digitalRead(pin) == HIGH){}
//When there is a low level, write down the time and subtract the time just saved
//If the value obtained is greater than 50μs, it is ‘1’, otherwise it is ‘0’
//And save it in an array
if (micros() - time1 > 50){
chr[i] = 1;
} else {
chr[i] = 0;
}
}

//Humidity, 8-bit bit, converted to a value
humi = chr[0] * 128 + chr[1] * 64 + chr[2] * 32 + chr[3] * 16 + chr[4] * 8 + chr[5] * 4 + chr[6] * 2 + chr[7];
//Temperature, 8-bit bit, converted to a value
temp = chr[16] * 128 + chr[17] * 64 + chr[18] * 32 + chr[19] * 16 + chr[20] * 8 + chr[21] * 4 + chr[22] * 2 + chr[23];

Serial.print("temp:");
Serial.print(temp);
Serial.print(" humi:");
Serial.println(humi);

}

void readLight(){
// reset
Wire.beginTransmission(Light_ADDR);
Wire.write(0b00000111);
Wire.endTransmission();

Wire.beginTransmission(Light_ADDR);
Wire.write(0b00100000);
Wire.endTransmission();
// typical read delay 120ms
delay(120);
Wire.requestFrom(Light_ADDR, 2); // 2byte every time
for (tempLight = 0; Wire.available() >= 1; ) {
char c = Wire.read();
tempLight = (tempLight 8) + (c & 0xFF);
}
tempLight = tempLight / 1.2;
Serial.print("light: ");
Serial.println(tempLight);
}


void readAtmosphere(){
tempAtom = bmp.readPressure();
Serial.print("Pressure = ");
Serial.print(tempAtom);
Serial.println(" Pascal");
}

//upload temperature humidity data to thinkspak.com
void uploadTemperatureHumidity(){
if(!client.connect(host, httpPort)){
Serial.println("connection failed");
return;
}
// Three values(field1 field2 field3 field4) have been set in thingspeak.com
client.print(String("GET ") + "/update?api_key="+api_key+"&field1="+temp+"&field2="+humi + "&field3="+tempLight+"&field4="+tempAtom+" HTTP/1.1\r\n" +"Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
}

Luiz, favor informar o link de onde conseguiu esse projeto. 

Esse Sketch utiliza mais de 10 Bibliotecas! Você instalou todas? 

E esta estranho pois tem duas bibliotecas WIFI! Isso poderá gerar conflitos. 

 Bom dia este é um kit do site Ali Express. Vou procura-lo novamente!

Eis o endereço, https//github.com/GJKJ/WSKS

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço