Sure, here is the simple code I use to test the connection from the PI, send the string I need through net cat “nc” and receive it at the “received” char variable.
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#ifndef UNIT_TEST
#include <Arduino.h>
#include <stdlib.h>
#endif
#include <IRremoteESP8266.h>
#include <IRsend.h>
#define RAWBUF 300
#define _GAP 50000
IRsend irsend(14);
//
// Configuration:
#define WIFI_NAME “HomeOffice”
#define WIFI_PASSWORD “T5c3p1da…”
#define SERVER_PORT 5000
#define SERVER_NAME “ucsirsala10”
#define PI_ADDRESS “192.168.0.150”
//
WiFiServer server(SERVER_PORT);
//
void setup() {
Serial.begin(115200);
delay(10);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_NAME);
WiFi.begin(WIFI_NAME, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);
// Start the server
server.begin();
Serial.println(“Server started”);
// Print the IP address
Serial.println(WiFi.localIP());
// Setup mDNS responder.
if (!MDNS.begin(SERVER_NAME)) {
Serial.println(“Error setting up MDNS responder!”);
while(1) {
delay(1000);
}
}
}
//
void loop() {
WiFiClient client = server.available();
if (!client) {
}
#define RECEIVED_SIZE 1800
char received[RECEIVED_SIZE] = {0};
if (client.readBytesUntil(’\n’, received, RECEIVED_SIZE-1) == 0) {
client.println(“ERROR: Timeout!”);
client.flush();
return;
}
Serial.print("Received: ");
Serial.println(received); // this is where I get the string I mentioned - I send it via net cat command
//
//
uint16_t caron24[200] = {4400,4300,550,1600,550,550,550,1600,550,1600,550,550,550,500,550,1650,500,550,550,550,550,1600,550,550,550,550,500,1650,550,1600,550,550,500,1650,550,1600,550,550,550,1600,550,1600,550,1600,550,1600,550,1650,500,1650,550,550,500,1650,500,550,550,550,550,550,500,600,500,550,550,550,500,550,550,1650,500,550,550,550,550,550,500,550,550,550,550,550,500,1650,550,500,550,1650,550,1600,550,1600,550,1600,550,1600,550,1600,550,5200,4400,4300,550,1600,550,550,500,1650,550,1600,550,550,550,500,550,1650,500,550,550,550,550,1600,550,550,550,500,600,1600,550,1600,550,500,600,1600,550,1600,550,550,550,1600,550,1600,550,1600,600,1550,600,1600,500,1650,550,500,550,1650,500,550,550,550,550,550,550,500,600,500,550,550,500,550,550,1600,600,500,550,550,550,500,600,500,550,550,550,500,600,1600,550,500,600,1600,550,1600,550,1600,550,1600,550,1600,600,1550,550,};
//irsend.sendRaw(caron24,200,38);
//
delay(200);
//
client.flush();
}
====================================
The net cat comand is formed as follows:
‘echo ’ + IRCommandFinal + ’ |’ + ’ nc ’ + sensorID + ’ 5000’
====================================
I printed the output I received and attached the file here.
What I want is use the " receive" char in the:
irsend.sendRaw(caron24,200,38);
Thanks!
serial print output.txt (949 Bytes)