Control LED of W5100S-EVB-Pico using Beebotte Cloud
This content is an example of controlling the Built-in LED of W5100S-EVB-PICO in Beebotte cloud.

Beebotte - Beebotte
x 1




// ...
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network.
// gateway and subnet are optional:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, xxx, xxx, xxx);
IPAddress myDns(xxx, xxx, xxx, xxx);
IPAddress gateway(xxx, xxx, xxx, xxx);
IPAddress subnet(xxx, xxx, xxx, xxx);
// ...
void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
Ethernet.init(17); // WI/Znet W5100S-EVB-Pico W5500-EVB-Pico W6100-EVB-Pico
// ...
}




#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#define LEDPIN 25 // Built-in LED pin of W5100S-EVB-Pico.
#define BBT "mqtt.beebotte.com" // Domain name of Beebotte MQTT service
#define TOKEN "token_xxxxxxxxxxxxxxxx" // Set your channel token here
#define CHANNEL "W5100SEVBPico" // Replace with your channel name
#define LED_RESOURCE "led"
// Network configration
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(xxx, xxx, xxx, xxx);
IPAddress myDns(xxx, xxx, xxx, xxx);
IPAddress gateway(xxx, xxx, xxx, xxx);
IPAddress subnet(xxx, xxx, xxx, xxx);
EthernetClient ethClient;
PubSubClient client(ethClient);
// will be called every time a message is received
void onMessage(char* topic, byte* payload, unsigned int length) {
// decode the JSON payload
StaticJsonDocument<256> doc;
// Test if parsing succeeded
auto error = deserializeJson(doc, payload);
if (error) {
Serial.print(F("deserializeJson() failed with code "));
Serial.println(error.c_str());
return;
}
// led resource is a boolean read it accordingly
bool data = doc["data"];
// Set the led pin to high or low
if (data == 0) {
digitalWrite(LEDPIN, LOW);
} else if (data == 1) {
digitalWrite(LEDPIN, HIGH);
}
// digitalWrite(LEDPIN, data ? HIGH : LOW);
}

