Hello,
Is it possible to stream data using a ESP8266 Module directly to the API Link?
Im using the following code.
#include <ArduinoJson.h> #include <ESP8266HTTPClient.h> #include <ESP8266WiFi.h> void setup() { Serial.begin(115200); //Serial connection WiFi.begin("DiAlOg-1", "dialog456@"); //WiFi connection while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion delay(500); Serial.println("Waiting for connection"); } } void loop() { if(WiFi.status()== WL_CONNECTED){ //Check WiFi connection status HTTPClient http; //Declare object of class HTTPClient const size_t bufferSize = JSON_ARRAY_SIZE(1) + JSON_OBJECT_SIZE(2); DynamicJsonBuffer jsonBuffer(bufferSize); JsonArray& root = jsonBuffer.createArray(); JsonObject& root_0 = root.createNestedObject(); root_0["Value1"] = 100; root_0["Value2"] = 200; char JSONmessageBuffer[300]; root.prettyPrintTo(JSONmessageBuffer, sizeof(JSONmessageBuffer)); Serial.println(JSONmessageBuffer); http.begin("https://api.powerbi.com/beta/852c5799-8134-4f15-9d38-eba4296cc76f/datasets/6014dfc1-93f3-42bb-8ae8-7ec52b051bc8/rows?key=kcW8AI0bvDrT%2BukEOZSFfRxh39HqH0z8hNNPqMqB2PlzlAXvwtw8S9CLCnga3g4tiz2vSonttPDHKfbmNkEUYA%3D%3D"); http.addHeader("Content-Type", "application/json"); int httpCode = http.POST(JSONmessageBuffer); http.end(); //Close connection }else{ Serial.println("Error in WiFi connection"); } delay(1000); //Send a request every 30 seconds }
And this is the serial Output:
[ { "Value1": 100, "Value2": 200 } ] [ { "Value1": 100, "Value2": 200 } ]
It doesn't show any value in the dashboard.. Should this work? What am i doing wrong?
I followed the following tutorial, but instead of the Raspberry Pi, Im using a ESP8266.
https://www.youtube.com/watch?v=0YIBHfgasok
(see 30:50)
Your help is much appreciated. thank you.