Post links and attach files for documentation here, also chat about these docs freely

User avatar
By adoher2000
#69497 At the moment I am trying to send 15 bytes from the PIC16F877A (RC6 TxD) to a module ESP8266 to pin 4 (RxD) but the data does not arrive, I performed several tests and I do not get the data to arrive.

For pin 25 of PIC16F877A send "L01Z01C01P01B61" like this:

The pin 25 of the PIC, is connected pin 11 of the MAX232 and pin 14 to the pin 2 of an industrial server SENA LS100 and this sends the data to an IP and port, the socket server, reads the data and stores it in a table in MySQL , very good.

I perform the above procedure, but I change the industrial server SENA LS100 by the module ESP8266, the pin 4 of the RxD module to ping 14 of the MAX232 and the data does not reach the database ..

If I execute the procedure, by CMD "type dato1.txt 1> COM4:" connecting the serial port pin 2 with 14 MAX232 and pin 3 with 13 MAX232 and the module ESP8266 pin 4 RxD with the pin 12 MAX232 the data reaches the base of data.

But when I connect the pin 25 of the PIC16F877A to pin 4 RxD of the module the data does not reach the database.
Codigo en PIC16F877A

#include <16F877a.h>
#use delay(clock=4M)
#fuses XT,NOWDT,HS,NOPROTECT,NOLVP,NODEBUG,NOBROWNOUT,PUT
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7,parity=N,bits=8)

#Byte PORTB = 0X06
#Byte PORTC = 0X07

#Byte TRISB = 0X86
#Byte TRISC = 0X87

#Bit RB0 = PORTB.0

#Bit RC5 = PORTC.5

int1 zb0=0;

void main(VOID) {
port_b_pullups(FALSE);
TRISB=0B11111111;

TRISC=0B00000000;
RC5=1;
CICLO:
IF(RB0==1){IF(zb0==0){zb0=1;printf("%s","L01Z01C01P01B01");}} delay_ms(5); IF(RB0==0){IF(zb0==1){zb0=0;printf("%s","L01Z01C01P01B02");}};
GOTO CICLO;
}
Codigo en modulo ESP8266-01

#include <SoftwareSerial.h>
SoftwareSerial SerialESP8266(4,5); // RX, TX
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

ESP8266WiFiMulti WiFiMulti;

String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
boolean newData = false;

void setup() {
// initialize serial:
Serial.begin(9600);
delay(10);
// reserve 15 bytes for the inputString:
inputString.reserve(15);

// We start by connecting to a WiFi network
WiFiMulti.addAP("dlink", "");

//Serial.println();
//Serial.print("Wait for WiFi... ");
//Serial.print("1 IP : ");
//Serial.println(WiFi.localIP());

while(WiFiMulti.run() != WL_CONNECTED) {
Serial.print("2 IP : ");
Serial.println(WiFi.localIP());
delay(500);
}

//Serial.println("");
//Serial.println("WiFi connected");
//Serial.println("IP address: ");
//Serial.println(WiFi.localIP());

delay(500);

}
//Fin Setup

void loop() {
// print the string when a newline arrives:
//Serial.print(" Dios ");
while (Serial.available() > 0 ) {
//Serial.print(" Dato available() > 0 ");
// get the new byte:
//char inChar = (char)Serial.read();
char inChar = Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') { stringComplete = true;Serial.print(" Evento "); }
}

if (stringComplete) {
//Serial.println(inputString);
//Serial.print("Recibio RxD\n");
//Codigo copia ejemplo ClienteBasic
const uint16_t port = 1961;
const char * host = "192.168.0.100"; // ip or dns

//Serial.print("connecting to ");
//Serial.println(host);

// Use WiFiClient class to create TCP connections
WiFiClient client;

if (!client.connect(host, port)) {
Serial.println("connection failed");
Serial.println("wait 3 sec...");
delay(3000);
return;
}
//http://forum.arduino.cc/index.php?topic=409456.0
//Serial.print(buffer);

// This will send the request to the server
// "Send this data to server"
client.print(inputString);

//read back one line from server
String line = client.readStringUntil('\r');
client.println(line);

//Serial.println("closing connection");
client.stop();

//Serial.println("wait 5 sec...");
//delay(5000);

//Fin codigo copia
// clear the string:
inputString = "";
stringComplete = false;

}
//Serial.print("Loop\n");
}
//Fin Loop

I am very grateful for the support you can give me.
User avatar
By adoher2000
#69652 Thanks a lot, based on the above, run the test, connect the ESP8266 module with FTDI to the Arduino IDE, and using serial monitor, I send the 15 bytes and arrive at the server, so RxD does not show fault. The max232 feed it with 3.3V.

Even if I connect the pin 25 TxD of the PIC 16F877a to the pin 4 RxD of the module, the data does not arrive to the database.

Thank you very much and for your support.
User avatar
By adoher2000
#69691
jankop wrote:Pin 14 of MAX232 is high voltage pin! Its voltage is about 10V and is bipolar! Rx input of ESP8266 is 3,3V only. Your ESP8266 it may be damaged.
jankop wrote:Pin 14 of MAX232 is high voltage pin! Its voltage is about 10V and is bipolar! Rx input of ESP8266 is 3,3V only. Your ESP8266 it may be damaged.



Can communicate with PIC16F877a pin25 TxD with Module ESP8266 pin 4