Hello
I'm a beginner with arduino yun and would like to know if it is possible to use arduino yun to send and get data from a web api hosted on an internet server?
For example, currently my project reads the values from a scale when a request is received (htttp://ip-arduino-yun/arduino/scale). I would like to make the arduino send continuously the values read from the scale to an api.
Any examples or tips?
#include <Bridge.h>
#include <BridgeServer.h>
#include <BridgeClient.h>
BridgeServer server;
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin(); //pode ficar bloqueado por até 2 segundos
digitalWrite(13, HIGH);
server.listenOnLocalhost();
server.begin();
}
void loop() {
BridgeClient client = server.accept();
if (client) {
process(client);
client.stop();
}
}
void process(BridgeClient client) {
String command = client.readStringUntil('&');
if (command == "scale") {
readScale(client);
}
}
void readScale(BridgeClient client) {
client.println("Scale: 350g");
}