Splunk Dev

Arduino with Splunk

macalamela
Engager

hello, we are trying to use splunk with arduino by wifi (esp8266). We utilized the port 8088 and this code but don´t recognize this port and send to port 443.

But we have some problems and we can't connect they both together. Can you have some example by how we can connect that?

We try using this code:

/*  Medidor de temperatura com LM35, ESP8266 e Thingspeak
 *  
 *  Envia a temperatura lida pelo sensor LM35 e envia para a internet 
 *  com o auxilio da platarforma de Cloud do Thingspeak.
 *  
 *  library modified 23 Mar 2016 on Arduino IDE 1.6.7
 *  by Cléber Werlang (http://iot4nerds.wordpress.com/)
 */

#include               // Biblioteca do ESP8266
#include "Limits.h"

String apiKey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";   //Coloque a API do ThingSpeak entre as aspas
const char* ssid = "Renato iPhone 5s";            //Coloque a ssid do Wifi entre as aspas.
const char* password = "xxxxxxxxxxx";       //Coloque a senha do Wifi entre as aspas.
const char* server = "nnn,nnn,nn,172";


const int sensorTemp = A0; //Pino analógico que o sensor de temperatura está conectado.
int valorSensorTemp = 0;  //usada para ler o valor do sensor de temperatura.
int menorValorTemp  = INT_MAX; //usada para armazenar o menor valor da temperatura.



WiFiClient client;

void setup() {
  Serial.begin(115200);
  delay(10);

  WiFi.begin(ssid, password);

  Serial.println();
  Serial.println();
  Serial.print("Conectando em ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("Conectado!");

}

void loop() {

  Serial.println("Lendo temperatura!");


 //Para evitar as grandes variações de leitura do componente 
  //LM35 são feitas 8 leitura é o menor valor lido prevalece.  
  menorValorTemp  = INT_MAX; //Inicializando com o maior valor int possível
  for (int i = 1; i <= 8; i++) {
    //Lendo o valor do sensor de temperatura.
    valorSensorTemp = analogRead(sensorTemp);   

    //Transformando valor lido no sensor de temperatura em graus celsius aproximados.
    valorSensorTemp *= 0.54 ; 

    //Mantendo sempre a menor temperatura lida
    if (valorSensorTemp < menorValorTemp) {
      menorValorTemp = valorSensorTemp;
    }

   delay(150); 
  }   


    String postStr = apiKey;
           postStr +="&field1=";
           postStr += String(menorValorTemp);
           postStr += "\r\n\r\n";

     client.connect("https://nnn,nnn,nn,172",8088);
     client.println("POST /1/inputs/http?index=<arduino>&sourcetype=arduino&host=arduino");
     client.println("Authorization: Splunk <xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>");
     /client.print("Authorization: Splunk "+apiKey);/
      client.print(postStr.length());
     client.println("Content-Type: text/plain");
     client.println("Connection: close");
     client.println("");
     client.println(postStr);

     Serial.println("");
     Serial.print("Temperatura: ");        //Imprime a temperatura na Serial.
     Serial.print(menorValorTemp);                  
     Serial.println("C");
     Serial.println("Enviando para o ThingSpeak");

  client.stop();                     
  delay(14000);                           // thingspeak tem um delay de 14 segundos para os updates.
  Serial.println("Enviado!");
  Serial.println("");
}
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi,
Have you tried using the WiFiClientSecure instead of WiFiClient? It is quite a while since ive looked at this sort of thing, however this could be part of the issue. This is assuming your receiver is indeed HTTPS.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

@macalamela, I edited your question to mask your IP address, API key, and password. These items should not be published in a public forum like this one.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...