Hello.
I'm fairly new on arduino world and trying to create projects.
I'm trying to make a ethereum price display. Got arduino uno, esp8266 module and an lcd display.
I can connect esp8266 to wifi but can't get http. https://api.binance.com/api/v1/ticker/price?symbol=ETHBUSD trying to extract this website, it was looking very easy at the start but couldn't handle it.
Can anyone help me
Sure - supply ALL the information we need to help. HINT : Code, what Arduino you have, how is it connected to the internet etc
I have arduino uno (clone), esp8266 module (i guess it's also clone) and an lcd screen (don't know the model)
I've tried this code lately. It works until loop, and connects to internet via wifi router. But can't connect to website and says connection failed.
I just want to pull those texts on https://api.binance.com/api/v1/ticker/price?symbol=ETHBUSD and project on lcd screen.
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <SoftwareSerial.h>
int HTTP_PORT = "";
String HTTP_METHOD = "GET";
char HOST_NAME[] = "api.binance.com"; // hostname of web server:
String PATH_NAME = "/api/v1/ticker/price?symbol=ETHBUSD";
String agAdi = "Xiaomi"; //Ağımızın adını buraya yazıyoruz.
String agSifresi = "5327608856A!"; //Ağımızın şifresini buraya yazıyoruz.
int rxPin = 10; //ESP8266 RX pini
int txPin = 11; //ESP8266 TX pini
WiFiClient client;
SoftwareSerial esp(rxPin, txPin); //Seri haberleşme pin ayarlarını yapıyoruz.
void setup() {
Serial.begin(9600); //Seri port ile haberleşmemizi başlatıyoruz.
Serial.println("Started");
esp.begin(115200); //ESP8266 ile seri haberleşmeyi başlatıyoruz.
esp.println("AT"); //AT komutu ile modül kontrolünü yapıyoruz.
Serial.println("AT Yollandı");
while(!esp.find("OK")){ //Modül hazır olana kadar bekliyoruz.
esp.println("AT");
Serial.println("ESP8266 Bulunamadı.");
}
Serial.println("OK Komutu Alındı");
esp.println("AT+CWMODE=1"); //ESP8266 modülünü client olarak ayarlıyoruz.
while(!esp.find("OK")){ //Ayar yapılana kadar bekliyoruz.
esp.println("AT+CWMODE=1");
Serial.println("Ayar Yapılıyor....");
}
Serial.println("Client olarak ayarlandı");
Serial.println("Aga Baglaniliyor...");
esp.println("AT+CWJAP=\""+agAdi+"\",\""+agSifresi+"\""); //Ağımıza bağlanıyoruz.
while(!esp.find("OK")); //Ağa bağlanana kadar bekliyoruz.
Serial.println("Aga Baglandi.");
delay(1000);
}
void loop() {
if(client.connect(HOST_NAME, HTTP_PORT)) {
Serial.println("Connected to server");
} else {
Serial.println("connection failed");
}
client.println(HTTP_METHOD + " " + PATH_NAME + " HTTP/1.1");
client.println("Host: " + String(HOST_NAME));
client.println("Connection: close");
client.println(); // end HTTP request header
}
Can you hit the site with your ESP? Is the problem parsing what it sends you?
no, i cant reach site i guess.
it returns as "connection failed" after this "if(client.connect(HOST_NAME, HTTP_PORT))"
also i'm not sure should i provide a port, tried port 80 but no luck.
I think the WiFi library is expecting a WiFi Shield and not a ESP8266 connected via serial. I think you have to look up how to send AT commands to the ESP8266 to connect to a web server and send a GET request.
you are requesting from a https server while expexting a http website. You're gonna need to switch to insecure client mode (include the wifiClientSecure library and use client.setInsecure() ). You could also try to figure out how to set up a secure client properly, but i have not been able to do that.
addition: take care with sending personal information via an unsecured connection!
thanks for all help. i gave up.
I think arduino isn't for me
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.