Problem establishing serial communication with Kq-330 Power line communication modem

gtavi66654
Posts: 1
Joined: Fri Feb 26, 2021 3:01 pm

Problem establishing serial communication with Kq-330 Power line communication modem

Postby gtavi66654 » Fri Feb 26, 2021 3:45 pm

Guys i am trying to use an esp32 with KQ-330 power line communication mode to send a signal over the power line to turn a bunb on and off continuously .
my circuit is really simple:-
Esp32 --> Kq-330(transmit)-----Power line-----Kq-330(receive)-->arduino uno-->relay-->bulb(on/off)

The problem:-
I unable to establish a successful serial communication with the Kq-330 module with the esp32 on the transmission side.
To check whether the Kq-330 module was working fine i used a simple usb to ttl converter with a serial communication terminal emulator(9600bps,8bit 1 stop bit no parity)(Name:- tera term software)
to send serial data to the KQ-330 module and it worked like a charm.


But serial communication doesn't seem to work with esp32, i followed all the specification given in the specs sheet(9600bps, 8bit 1 stop bit).The datasheet for KQ-330 is attached

As for the connection:
1. the 5v of KQ-330 is connected to Vin of ESP-32 ,
2. gnd of KQ-330 to gnd of ESP-32
3.RX of KQ-330 to TX of ESP 32
Since the project works with serial terminal and usb converter i guess there is no problem on the arduino (reveiving) side. And the esp32 is also fine, as i checked it by sending and receiving the data between the usart1 and usart2 of esp32 and it was working
The code of both the ends is given below

ESP32 CODE FOR TRANSMISSION:
  1. HardwareSerial Sender(1);   // Define a Serial port instance called 'Sender' using serial port 1
  2.  
  3.  
  4.  
  5. void setup() {
  6.  
  7.   Serial.begin(9600);                                             // Define and start serial monitor
  8.   Sender.begin(9600, SERIAL_8N1, 13, 12); // Define and start Sender serial port
  9. }
  10.  
  11. void loop() {
  12.       Sender.write("t");                            // command to turn bulb on
  13. delay(500);                          
  14.   Sender.write("o");                                // command to turn bulb off
  15.   delay(500);
  16. }
ARDUINO UNO CODE RECEIVING END(ignore the lcd code):-
  1. #include <LiquidCrystal.h>
  2. // initialize the library by associating any needed LCD interface pin
  3. // with the arduino pin number it is connected to
  4. LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)
  5. int ADC1_PIN = A4;
  6. int ADC1_VAL;
  7. int ADC2_PIN = A2;
  8. int ADC2_VAL;
  9. int ADC3_PIN = A3;
  10. int ADC3_VAL;
  11. int ADC4_PIN = A1;
  12. int ADC4_VAL;
  13. int ADC5_PIN = A0;
  14. int ADC5_VAL;
  15.  
  16.  
  17.  
  18. void setup() {
  19.   // set up the LCD's number of columns and rows:
  20.   lcd.begin(16, 2);
  21.   Serial.begin(9600);
  22.   // Print a message to the LCD.
  23.   pinMode(7,OUTPUT);
  24. pinMode(6,OUTPUT);
  25.   lcd.print("  WELCOME  ");
  26.   delay(1000);
  27.   lcd.clear();
  28.   lcd.setCursor(0, 0);
  29.   lcd.print("  POWER LINE   ");
  30.   lcd.setCursor(0, 1);
  31.   lcd.print(" COMMUNICATION ");
  32.   delay(1000);
  33.   digitalWrite(7,HIGH);
  34.   digitalWrite(6,HIGH);
  35.    lcd.clear();
  36. }
  37.  
  38. void loop() {
  39.   String readString;
  40. String Q;
  41.  
  42.  
  43.  while (Serial.available()){
  44.   delay(10);
  45.   if(Serial.available()>0){
  46.   char c = Serial.read();
  47.    if (isControl(c)){
  48.   break;
  49.   }
  50.   readString += c;    
  51.   }
  52.  }
  53.  
  54. Q = readString;
  55.   lcd.setCursor(0, 0);
  56.   lcd.print(" HOME ");
  57.   lcd.setCursor(0, 1);
  58.   lcd.print(" AUTOMATION ");
  59.   delay(10);
  60. if (Q=="o"){
  61.   digitalWrite(6,HIGH);
  62.  }
  63.  
  64. if (Q=="t"){
  65.   digitalWrite(6,LOW);
  66. }
  67. }
Attachments
KQ330.pdf
KQ-330 datasheet
(556.77 KiB) Downloaded 412 times

ESP_Sprite
Posts: 9594
Joined: Thu Nov 26, 2015 4:08 am

Re: Problem establishing serial communication with Kq-330 Power line communication modem

Postby ESP_Sprite » Mon Mar 01, 2021 3:15 am

The datasheet is quite unclear about the voltage requirements on the serial lines aside from 'TTL level'. Perhaps it expects a 0V/5V serial signal instead of the 3.3V the ESP32 outputs?

Who is online

Users browsing this forum: Bing [Bot] and 58 guests