There have been some posts about this in the past, but not a answer.
Has anyone successfully hooked up their arduino to a bubble API endpoint? How did it go? I would like to do this with the ESP8266 Wifi development board.
If so, would you care to share screenshots. If not, would anyone like to work with me on a guide that could benefit the forum?
I have worked on this before but with a NucleoBoard to other endpoints not Bubble using the ESP8266.I will give it a try when I get time to see if it will hit successfully and if it does then definately it will with your Arduino Board. Using the ThingsNetwork also woked as an alternative when using LoRa Network
Select Detect Data for for parameter definition
3)Click on “Detect data” and copy URL to the Arduino Code as is in the tutorial link I provided
Initiate Arduino to send data and have bubble capture the data
Use data sent to create a thing etc
This is a rough Idea and I think it should work if the code provided in the link above actually work and hits an endpoint. I will gladly help out if need be but will need collaboration since I do not have an arduino Kit.
I managed to make a very basic connection via https to an app. Here is the script i used, which is a generic one from Arduino IDEthat i modified slightly:
/*
HTTP over TLS (HTTPS) example sketch
This example demonstrates how to use
WiFiClientSecure class to access HTTPS API.
We fetch and display the status of
esp8266/Arduino project continuous integration
build.
Limitations:
only RSA certificates
no support of Perfect Forward Secrecy (PFS)
TLSv1.2 is supported since version 2.4.0-rc1
Created by Ivan Grokhotkov, 2015.
This example is in public domain.
*/
#define USING_AXTLS
#include <ESP8266WiFi.h>
// force use of AxTLS (BearSSL is now default)
#include <WiFiClientSecureAxTLS.h>
using namespace axTLS;
#ifndef STASSID
#define STASSID ""
#define STAPSK ""
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "esp8266nodemcu.bubbleapps.io";
const int httpsPort = 443;
void setup() {
Serial.begin(9600);
Serial.println();
Serial.print("connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Use WiFiClientSecure class to create TLS connection
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
WiFiClientSecure client;
#pragma GCC diagnostic pop
Serial.print("connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
return;
}
String url = "/version-test/api/1.1/wf/esp8266";
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("POST ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Authorization: Bearer 756490c40b8f6585a297c98b4d7385dd\r\n" +
"key1: test " + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n"
);
Serial.println("request sent");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
String line = client.readStringUntil('\n');
if (line.startsWith("{\"state\":\"success\"")) {
Serial.println("esp8266/Arduino CI successfull!");
} else {
Serial.println("esp8266/Arduino CI has failed");
}
Serial.println("reply was:");
Serial.println("==========");
Serial.println(line);
Serial.println("==========");
Serial.println("closing connection");
}
void loop() {
}
I created an app just for testing, and it actually works. I hooked it up to the endpoint like you said and send an email whenever there is a post request:
Remember for Bubble to capture the body fields you will need to use “detect request data” on parameter definition and then click on button “Detect data” . A pop up will appear with a link to paste to your arduino code.
Make one https request to the server and bubble will capture the data fields
i tried out the link you sent, but couldnt get the request to work, i am stuck with the code i posted above. According to bubble documentation data needs to be sent in json format:
However, i dont see a description on how to send it when it is for a workflow post request? Should i be like when you create a new thing or the format used to create a bulk upload?
Also, i dont know how to include the data in the post request in the code above in json format.