Power line Communication Project Guidance

ThottiKuttapan:
The thing is the data sheet doesnot specify anything about how to make work with arduino.They only documented how to connect with some unknown microcontroller.I have seen this device used with arduino.But as i said code is not available anywhere in the internet.

Take a closer look at the datasheet. You can use transparent mode or custom operating mode. I'd suggest the custom mode. In your code, build your packet, determine the number of bytes to send and output that to the modules RX pin. After sending the data length you can output your data one byte after the other. The module should send that over the powerline. The datasheet has some example C codes at the very end ...

I read the c programing,But i dont know how to relate/transform that to arduino readable format.

ThottiKuttapan:
I read the c programing,But i

...didn't post it here.

its at the bottom of the data sheet.I thought instead of that program i had a chance to get it right,if i post the code with arduinojson

Once more, the json doesn't have anything to do with the powerline communication. I'd best if you get it to work with basic datatypes. Then you can serialize/deserialize this to/from json later.

okke .i will research more.

I am doing a smart meter project using power line communication.For that i use kq-130f module as plcc module.It has tx and rx pin to which we send serial data and recieve it at other end.But when i send my data through basic serial.println() function it didnt work.When i looked into data sheet,they prefer using UART,MOBUS protocols,which i dont have any idea about.
Arduio mega-------->kq130f--------------->powerline--------->kq130f------->arduino uno

i want to sent serial data(sensor values) from mega to uno like this.
I am attaching datasheet along my topic.I want to know how to make this module work.There is somekind of program for another microcontroller at the end of datasheet which i have no idea about.So help is appreciated.

20140619104969976997.zh-CN.en.pdf (557 KB)

that looks like a neat device, can you listen in on power line transmission messages, like wireshark for high voltage power?
the 7 pin looks to need a data carrier
"7P-TX: TTL level, a data carrier, then the microcontroller RXD"

the above line makes me think you need a transport protocol in between the output and your microcontroller. rs-485, rs-232, something similar, below i found the key point, the microcontroller is a RS232 interface, the screenshots are a chinese version of 'Putty' connecting to the device and reading the output.

"KQ-130F power line carrier data transceiver module after the
microcomputer of FIG. 9 pin RS232 serial debugging assistant connection
test pattern: "

"This module interface baud 9600bps, please use the user module 9600BPS
asynchronous communication, the format of a start bit, 8 data bits, 1 stop bit
format."

okke. Pardon me ,I am not good enough to understand protocols.And is it necessary to add a Rs232 interface bw arduino and KQ130F module.
So if i have to transmit data b/w the two arduino modules using kq130f how should i program it.

My project is PLCC for smart meter networks.Project works like this.I have designed a energy meter using arduino and i am transmitting that data through powerline using powerline carrier module to another arduino uno and display it on computer.I have developed everything but failed to make my plcc module work.So i thought about purchasing a plcc module online and bought kq130f.(datasheet attached).But the thing is that this doesnt detect basic serial communication like println() functions.So i am not able to transmit data through the module. I cant understand how to make the module work from the data sheet.I just need to transmit a serial string data containg my sensor values through
arduino------>kq130f--------->power line--------->kq130f---------->arduino.
So how can i sent data through this module??Help is much appreciated.
androidwifi.ino is the program i developed till now.But the serial.println(text) method is not working.

20140619104969976997.zh-CN.en.pdf (557 KB)

Android_wifi.ino (2.46 KB)

Take a look at https://www.arduino.cc/en/Reference/softwareSerial, it could help..
Also the following could help:

  • Share wiring diagram
  • You can't use 1 pin for serial communication you need Tx and Rx
  • Take a look at Serial.read() and Serial.write()

Module says it supports asynchronous transmission with start bit and stop bit.How can i do that

Asynchronous transmission with (one) start bit and (one) stop bit (and no parity) is the way Arduino Serial works, so no problem with that.

In your KQ-130F module datasheet, you can see that the pin MODE (pin 8 ) sets the mode of operation.

If MODE is HIGH or unconnected, the mode of operation is Transparent.
If MODE is LOW, the mode of operation is Custom.

In the Transparent mode (MODE = HIGH or unconnected) the module simply echoes on TX pin (pin 7) the bytes received on RX pin (pin 6), but the datasheet warns that in this mode the noise on AC line can generate random bytes at receiving end.

For example, if you transmit the bytes

5A 5A 5A 34 56 78 12 45 67,

the receiving module can receive

FE FD EF 5A 5A 5A 34 56 78 12 45 67 85 DE EF

where the bytes

FE FD EF

at the start and

DE EF

at the end are random bytes generated by noise.

If you use this mode of operation, you need some protocol to skip random bytes.

The Custom mode of operation (MODE = LOW) uses the first byte as data length.

So, in this mode, if you want to transmit the 2 bytes

34 52

you must write the sequence

02 34 52

where the first byte (02) is the length of data bytes.

To summarize, if you use Transparent mode to send a string, very likely the receiving end will read a different string due to random bytes generated by AC line.

On the other hand, if you use Custom mode, you need to send the length of the string before sending the actual string, and in the receiving end you must read the first byte as string length, and then read the string bytes.

Here my tentative blocking routines for writing and reading strings in Custom mode

// you can change MAX_LEN to any value < 250
#define MAX_LEN 80
#define IO_FAILURE 0 // write or read operation failure
#define IO_SUCCESS 1 // write or read operation success

int writeStringCustomMode(String &txt)
{
  int len = txt.length();
  
  if (len > MAX_LEN)
    return IO_FAILURE;
        
  Serial1.write(len);
  
  Serial1.write(txt.c_str(),len);
  
  Serial1.flush();
  
  return IO_SUCCESS;
} 
  

char bufString[MAX_LEN + 1];

// read from Serial1 and save the string in the bufString buffer

int readByte()
{
    while(Serial1.available() < 1)
       ;

    return Serial1.read();
}

int readStringCustomMode()
{
  int len, ch;
  
  len = Serial1.read();
    
  bool discardInput = len > MAX_LEN;
  
  for(int i=0; i<len; i++)
  {
    ch = readByte();
    
    if (!discardInput)
      bufString[i] = ch;    
  }
    
  if (!discardInput)  
    bufString[len] = 0;
  else
    bufString[0] = 0; 
  
  return discardInput ? IO_FAILURE : IO_SUCCESS;        
}

before using readStringCustomMode() check if Serial1.available() > 0

okke,I will attach my program with out including the kq-130f module part at transmitter and receiver end of arduino.Can u please explain to me how i should change that inorder to get correct output.
i used serial.println() to print string,but it didnt work.

Android_wifi.ino (2.46 KB)

receivecrct.ino (420 Bytes)

I attach your code modified by me, try it.

Notes:

  1. Check that none of the pins assigned to LCD is assigned to Serial1 too.
  2. Connect to ground the MODE pin of transmitting and receiving KQ-130F modules, to select Custom mode of operation.
  3. The module KQ-130F needs approx. 1 second to transmit 10 bytes; if your string is for example 40 bytes
    long, you must wait at least 4 seconds before sending another string, otherwise transmitting buffer will
    overflow.
  4. If you modify MAX_LEN, set the same value in receiving and transmitting code.

Android_wifi.ino (2.95 KB)

receivecrct.ino (1.05 KB)

The device appears to use perfectly standard, TTL level RS232 protocol. Connect as shown in the posted manual. Leave the MODE pin open, and initialize the Arduino serial interface with

Serial.begin(9600);

To continue using the serial port on an Uno for program upload, you will need to use a software serial library to communicate with the device (altSoftSerial, neoSWserial, or softwareSerial).

1. Your connection between UNO and KQ130f could be like this:
uartw.png

2. The Codes

#include<SoftwareSerial.h>
SoftwareSerial SUART(2, 3);  //SRX= DPin-2, STX = DPin-3

void setup()
{
   Serial.begin(9600);
   SUART.begin(9600);

}

void loop()
{
    //send commands from the InputBox of Serial Monitor as needed as per KQ's Manual
    //To receive data from KQ, execute codes like --
    {
        byte n = SUART.available();
        if (n !=0)
        {
             //data has come from KQ; receive, store, and process as needed
        }
     }
}

uartw.png

Thanks for ur help,u r really amazing.i have a stupid doubt.
the text look like this
1001,241,5.46,20.00, so string length will be 19 right.

@ThottiKuiittapan the "Gigs and Collaborations" forum section is only for use when you want to pay someone money for assistance with your project. Are you willing to pay the people helping you here?

@ThottiKuttapan, stop cross-posting. Threads merged.

Twice.

Thrice.