Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

send analogic information with RN 171-EK

Status
Not open for further replies.

ings

Member level 4
Joined
Sep 8, 2014
Messages
78
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
988
hello, i successed to send hello message from RN171 EK to my PC (java code ) and with cable (pc and RN171) but now i want to program my card to send any information every 10s and withot using any cable so i m trying with this configuration in teraterm
Code:
<4.00> Joining wifi now..
Associated!
DHCP: Start
DHCP in 4319ms, lease=86400s
IF=UP
DHCP=ON
IP=192.168.1.5:2000
NM=255.255.255.0
GW=192.168.1.1
set ip protocol 1
AOK
<4.00> set ip host 192.168.1.4
AOK
<4.00> set ip remote 999
AOK
<4.00> set ip local 2000
AOK
set sys auto 10 // Automatically connect every 10 seconds
set option format 7 // Send the header and sampled binary data converted to ASCII
set q sensor 0xFF // Set the sensor mask to sample all channels
save // Save the configuration to the config file
reboot // Reboot so that the settings take effect
and when i put the battery i dont receive any information
can you help me plz
thanks
 

how did you send the hello message from RN 171 to pc?i want to know the steps
 

find attached a MPLAB project for an Explorer 16 which enables keyboard commands to be transmitted to a TCP server via a RN171 and also will transmit ADC readings from the potentiometer when CTRL/A is hit

the console terminal output was
Code:
PIC24 to RN171 test
CMD
join
Auto-Assoc ssid chan=1 mode=MIXED SCAN OK
<4.00> Joining ssid now..
Associated!
DHCP: Start
DHCP in 1855ms, lease=86400s
IF=UP
DHCP=ON
IP=192.168.1.64:2000
NM=255.255.255.0
GW=192.168.1.254
set ip protocol 8
AOK
<4.00> open 192.168.1.65 20000
Connect to 192.168.1.65:20000
<4.00> *OPEN*CTRL/A hit - transmit ADC data to RN171
transmitting adc = 52
transmitting adc = 52
transmitting adc = 52
transmitting adc = 52
transmitting adc = 440
transmitting adc = 645
transmitting adc = 799
transmitting adc = 260

the output of the Java TCP server program was
Code:
TCP server on IP address 192.168.1.65 port 20000
TCP server starting: IP address PC/192.168.1.65 port 20000
Client connect from IP address /192.168.1.64 port 57303
*HELLO*transmitting ADC values
adc = 52
adc = 52
adc = 52
adc = 52
adc = 440
adc = 645
adc = 799
adc = 260

the Java server code is
Code:
// server which waits for messages from a client
import java.io.*;
import java.util.*;
import java.net.*;


public class TCPserver extends Thread
{
        private ServerSocket   serverSocket;
        InputStream br=null;
        OutputStream pw=null;
        int receivePort;                // port to receive  from
        boolean threadRunning = true;   // flag to terminate thread

        TCPserver(int receivePort)    // constructor to receive on port receivePort
    {
                this.receivePort = receivePort;
    }

        // terminate the thread by setting flag
        public void stopTCPserver()
        {
                threadRunning = false;
        }

        public void run()                // thread run method, receives and buffers datagrams
        {
          Socket socket=null;
          try
              {
              while (threadRunning)
              {
                  System.out.println("TCP server starting: IP address " 
                       + InetAddress.getLocalHost().toString() + " port " + receivePort );
                  serverSocket = new ServerSocket(receivePort);
                  socket = serverSocket.accept(); // Wait for client to connect.
                  System.out.println("Client connect from IP address " + socket.getInetAddress()
                                  + " port " + socket.getPort());
                  br  =  socket.getInputStream();
                  pw = socket.getOutputStream() ;
                  while(threadRunning)
                    try
                    {
                      int code = br.read();
                      //System.out.println( "Server received byte: '" + code + "' char " + (char) code);
                      if(code==13) System.out.println();                // newline
                      else System.out.print( (char) code);
                    }
                    catch (Exception se) {System.err.println("done"); break;}
                  serverSocket.close();
                }
              }
          catch (Exception se) {System.err.println("run() " + se); }
     
          System.exit(1);                                                 // exit on failure
        }


public static void main(String args[])
{
     int receivePort=20000;                                 // port to receive datagrams on
     try
        {
        System.out.println("TCP server on IP address " + InetAddress.getLocalHost().getHostAddress() + " port " + receivePort);
        TCPserver frameInput = new TCPserver(receivePort);    // create server to receive messages
        frameInput.start();                                   // and start it
        }
      catch (Exception se) {System.err.println("main() " + se); }
 }

}
 

Attachments

  • Explorer16_UARTs.zip
    16.5 KB · Views: 106
Last edited:
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
thanks for your response but in my case i don't use the EXplrer16; i would like just to use the RN-171-EK;It is possible to detct the analogic value just with RN171-EK or it is ncessary too usee the explorer 16
 

thanks for your response but in my case i don't use the EXplrer16; i would like just to use the RN-171-EK;It is possible to detct the analogic value just with RN171-EK or it is ncessary too usee the explorer 16

to read the RN171 sensors you can use UDP broadcast
Code:
<4.00> join
Auto-Assoc ssid chan=1 mode=MIXED SCAN OK
<4.00> Joining SSID now..
Associated!
DHCP: Start
DHCP in 1966ms, lease=86400s
IF=UP
DHCP=ON
IP=192.168.1.64:2000
NM=255.255.255.0
GW=192.168.1.254
Listen on 2000

<4.00> set q s 0x0c		sample sensors 2 and 3
AOK
<4.00> set b a 192.168.1.65	set broadcast address
AOK
<4.00> set b p 999		set broadcast port
AOK
<4.00> set b i 7		set broadcast interval 1 packet every 8 seconds
AOK
on my RN171 pictail sensors 2 and 3 are connected to switches which can ground the inputs

when I run the UDP sever I get
Code:
UDP server on IP address 192.168.1.65 port 999

From IP /192.168.1.64 UDP string received - length 110
battery volts 2796
Sensors  0 0 0 0 0 3 0 12 0 0 0 0 0 0 0 0 0 0
Sensor 2 = 48 Sensor 3 = 192
 UDP data 'X*5(V|*******H****Time NOT SET**wifly-EZX Ver 4.00.1, Apr 19testRN171----------------------*:'


From IP /192.168.1.64 UDP string received - length 110
battery volts 2796
Sensors  0 0 0 0 0 9 62 23 0 0 0 0 0 0 0 0 0 0
Sensor 2 = 144 Sensor 3 = 254320
 UDP data 'X*5(V|************Time NOT SET**wifly-EZX Ver 4.00.1, Apr 19testRN171----------------------*:'


From IP /192.168.1.64 UDP string received - length 110
battery volts 2797
Sensors  0 0 0 0 62 20 63 14 0 0 0 0 0 0 0 0 0 0
Sensor 2 = 254272 Sensor 3 = 258272
 UDP data 'X*5(V|************Time NOT SET**wifly-EZX Ver 4.00.1, Apr 19testRN171----------------------*:'
I display the battery voltage, the raw snsors bytes and the values of sensor 2 and 3 (16 bit value received as two bytes)
there are three datagrams shown
1. both sensors grounded
2. sensor 2 grounded
3. both sensors floating

the UDP server code is
Code:
// simple server waiting for datagrams and extracting ans displaying string

import java.io.*;
import java.util.*;
import java.net.*;

public class UDPserver extends Thread
{
public static void main(String args[])
{
   try
        {
        // get machine IP address - two methods
        int receivePort=999, i;                                                                                        // port to receive datagrams from
        //Socket soc = new Socket("192.168.1.1", 80);
        //System.out.println("UDP server on IP address " + soc.getLocalAddress().getHostAddress() + " port " + receivePort);
        //soc.close();
        System.out.println("UDP sevrer on IP address " + InetAddress.getLocalHost().getHostAddress() + " port " + receivePort);
        InetAddress remoteIPaddress;                                    // IP address of remote host
        int remotePort;                                                 // port on remote host to send frames too
        byte[] buffer = new byte[65507];                                // array to put datagrams in
        DatagramPacket dp = new DatagramPacket(buffer, buffer.length);  // create packet for datagrams
              // open DatagramSocket to receive and a DatagramePacket to hold the datagrams
              DatagramSocket ds = new DatagramSocket(receivePort);
              // loop forever reading datagrams from the DatagramSocket
              while (true)
                {
                 ds.receive(dp);                                         // wait for next datagram
                 byte[] data = dp.getData();                             // get datagram contents
                 System.out.println("\nFrom IP " + dp.getAddress() +" UDP string received - length " + dp.getLength() );
                 // display battery voltage
                 System.out.println("battery volts " + ((data[14]<<8) +data[15]) );
                 // print the sensor bytes - 16 bytes array index starting at 93 (not 94) 
                 System.out.print("Sensors ");
                 for  (i=93;i<=dp.getLength();i++)
                    System.out.print(" " + ((data[i])));
                 // print sensor 2 and 3 values
                 System.out.println("\nSensor 2 = " +  (((data[97]<<8) +data[98])<<4) + " Sensor 3 = " +  (((data[99]<<8) +data[100])<<4));
                 // print datagram contents (replace none printing characters with *)
                 for  (i=0;i<dp.getLength();i++)
                     if(data[i]<32) data[i]='*';
                 String s = new String(data, 0, 93);         // create a string from the data
                 System.out.println(" UDP data '" + s + "'\n");
                }
              }
        catch (IOException se) {System.err.println("error " + se);}
        System.exit(1);                                                 // exit on failure
}
}
the UDP datagram packet is 110 bytes long with the sensors data in array index 93 to 109 (not 94 to 110 as specified in the RN171 WiFi manual)
**broken link removed**
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
thanks for your response but in my case i don't use the EXplrer16; i would like just to use the RN-171-EK;It is possible to detct the analogic value just with RN171-EK or it is ncessary too usee the explorer 16

to read the RN171 sensors you can use the TCP HTTP broadcast facility
Code:
join
Auto-Assoc SSID chan=1 mode=MIXED SCAN OK
<4.00> Joining SSID now..
Associated!
DHCP: Start
DHCP in 1691ms, lease=86400s
IF=UP
DHCP=ON
IP=192.168.1.64:2000
NM=255.255.255.0
GW=192.168.1.254
Listen on 2000
set ip h 192.168.1.65	set TCP server IP
AOK
<4.00> set ip r 80	set TCP server port for HTTP
AOK
<4.00> set i p 18	enable TCP and HTTP client mode
AOK
<4.00> set o f 7	append sensor data to HTTP
AOK
<4.00> set b i 7	set broadcast 1 packet every 8 seconds
AOK
<4.00> open		open TCP client connection
<4.00> *OPEN*
on my RN171 pictail sensors 2 and 3 are connected to switches which can ground the inputs

when I run the TCP server i get
Code:
ready to receive TCP  from socket 80
TCP server starting: IP address bb-TOSH/192.168.1.65 port 80
TCP Client connect from IP address /192.168.1.64 port 20472

TCP data '*HELLO*0D11000000003DFC000C0000000000000000 HTTP/1.0
Host: dns1
'
sensor 2 0x3DFC sensor 3 0x00C0
sensor 2 15868 sensor 3 192

TCP data '*HELLO*0D11000000000007000D0000000000000000 HTTP/1.0
Host: dns1
'
sensor 2 0x0007 sensor 3 0x00D0
sensor 2 7 sensor 3 208

TCP data '*HELLO*0D11000000003E243F110000000000000000 HTTP/1.0
Host: dns1
'
sensor 2 0x3E24 sensor 3 0xF110
sensor 2 15908 sensor 3 61712
there are three readings shown
1. sensor 3 grounded
2. both sensors grounded
3. both sensors floating

the TCP server code
Code:
// TCP server which waits for messages from a client
import java.io.*;
import java.util.*;
import java.net.*;


public class TCPserver extends Thread
{
        private ServerSocket   serverSocket;
        InputStream br=null;
        OutputStream pw=null;
        int receivePort;                // port to receive  from
        boolean threadRunning = true;   // flag to terminate thread

        TCPserver(int receivePort)    // constructor to receive datagrams on port receivePort
    {
                this.receivePort = receivePort;
    }

        // terminate the thread by setting flag
        public void stopTCPserver()
        {
                threadRunning = false;
        }

        public void run()                // thread run method, receives and buffers datagrams
        {
          Socket socket=null;
          int frame=0;
          try
              {
              while (threadRunning)
              {
                  System.out.println("TCP server starting: IP address " 
                       + InetAddress.getLocalHost().toString() + " port " + receivePort );
                  serverSocket = new ServerSocket(receivePort);
                  socket = serverSocket.accept(); // Wait for client to connect.
                  System.out.println("TCP Client connect from IP address " + socket.getInetAddress()
                                  + " port " + socket.getPort());
                  br  = ( ( socket.getInputStream() ) );
                  pw = ( socket.getOutputStream() );
                  while(threadRunning)
                  try
                    {
                    // read TCP packet into byte array and convert to a string
                    byte data[]=new byte[10000];
                    int length = br.read(data);
                    String s = new String(data, 0, length);         // create a string from the data   
                    System.out.println("\nTCP data '" + s +"'");
                    // find start of data, e.g. *HELLO*
                    int hello = s.indexOf("*HELLO*");
                    // and extract the hexadecimal string for sensors 2 and 3
                    String sensor2 = s.substring(hello+19, hello+23);
                    String sensor3 = s.substring(hello+24, hello+28);
                    System.out.println("sensor 2 0x" + sensor2 + " sensor 3 0x" + sensor3 );
                    // convert the hexadecimal values to integer and display
                    System.out.println("sensor 2 " + Integer.parseInt(sensor2, 16) 
                          + " sensor 3 " + Integer.parseInt(sensor3, 16) );
                   }
                    catch (Exception se) {System.err.println("error " + se); break;}
                    serverSocket.close();
                }
              }
          catch (Exception se) {System.err.println("run() " + se); }
     
          System.exit(1);                                                 // exit on failure
        }


public static void main(String args[])
{
        int receivePort=80;//10000;//999;//20000;             // port to receive 
        TCPserver frameInput = new TCPserver(receivePort);    // create server to receive messages
        frameInput.start();                                   // and start it
        System.out.println("ready to receive TCP  from socket " + receivePort);
        }

}
the data starts with *HELLO* with sensors 2 and 3 at offset 19 and 24 respectively
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
can you pllz explain me this line
TCP data '*HELLO*0D11000000003DFC000C0000000000000000 HTTP/1.0
Host: dns1
thanks in advance
 

the TCP packet data
Code:
*HELLO*0D11000000003DFC000C0000000000000000 HTTP/1.0
Host: dns1
1. starts at index 0 with *HELLO*
2. followed by 4 characters 0D11 which I think is the GPIO pins (I have not found any documentation on this)
3. followed by the 8 analogue sensor values represented by 4 characters each

the sensors 2 and 3 (which on the RN171 pictail are connected to switches which can ground the inputs) are therefore at offsets in the string 19 and 24 respectively
The strings representing the hexadecimal values of sensor 2 and 3 can be extracted using java method String.subString()
Code:
           String sensor2 = s.substring(hello+19, hello+23);
                    String sensor3 = s.substring(hello+24, hello+28);
and the integer parsed using Integer.parseInt()
Code:
                    System.out.println("sensor 2 " + Integer.parseInt(sensor2, 16) 
                          + " sensor 3 " + Integer.parseInt(sensor3, 16) );
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
So if i want to send just hello messsage it is possible to do this

- - - Updated - - -

because in my case i haven't any sensor and i want just to test the transmission of a hello message
 

So if i want to send just hello messsage it is possible to do this

- - - Updated - - -

because in my case i haven't any sensor and i want just to test the transmission of a hello message
yes, set up the TCP as the example in earlier post, e.g.
Code:
set ip h 192.168.1.65	set TCP server IP
AOK
<4.00> set ip r 80	set TCP server port for HTTP
AOK
<4.00> set i p 18	enable TCP and HTTP client mode
AOK
<4.00> set o f 7	append sensor data to HTTP
AOK
<4.00> set b i 7	set broadcast 1 packet every 8 seconds
AOK
<4.00> open		open TCP client connection
<4.00> *OPEN*
and you should receive the TCP packets - the sensor data will be 0's or possibly random if the inputs are floating
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
in your case
192.168.1.65 is the adress of the receiver (TCP Server )?
192.168.1.64 is the ip of your wireless network?

- - - Updated - - -

i have a problem with my rn171 because sometimes it dont' succed to detect and join the wireless network ; is it the problem in all RN171 or it is possible to solve this problem
thanks in advance
 

in your case
192.168.1.65 is the adress of the receiver (TCP Server )?
192.168.1.64 is the ip of your wireless network?
yes

i have a problem with my rn171 because sometimes it dont' succed to detect and join the wireless network ; is it the problem in all RN171 or it is possible to solve this problem
thanks in advance
I had problems connecting to my main WiFi router which was a distance of about 10 metres from the RN171 board - I think the power output of the RN171 was too low for reliable communication
using another WiFi router close to the RN171 worked OK
if you do a scan one of the displayed parameters indicates the signal level
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
in my case i have receives this data witout using any sensor
*HELLO**HELLO*1D17CF29CF2907F23D2307C107FD30773092 HTTP/1.0
Host: dns1

*HELLO*1D17CF29CF2907F53D2906BE07FD307D3088 HTTP/1.0
Host: dns1

*HELLO*1D17CF29CF2907F53D2309D407FC307C3093 HTTP/1.0
Host: dns1

*HELLO*1D17CF29CF2907F33D2507B907FE307B3094 HTTP/1.0
Host: dns1


so it is present the transmssion of hello message and
1D17CF29CF2907F33D2507B907FE307B3094 present the data in sensor
thanks in advace
 

i have a problem just in the Tcp mode ; when i configure with cable it work and when i put the battry it don't work and it display me this messgae in tera term
<4.00> open
<4.00> *OPEN**CLOS**CLOS*
another question about RN171; the default of RN171 is about the connexion in wifi and the detection of an acess point
 

in my case i have receives this data witout using any sensor
*HELLO*1D17CF29CF2907F33D2507B907FE307B3094 HTTP/1.0
Host: dns1

so it is present the transmssion of hello message and
1D17CF29CF2907F33D2507B907FE307B3094 present the data in sensor
thanks in advace
in my case I only have sensors 2 and 3 connected so my setting for the set q sensor command was
Code:
set q s 0x0c		sample sensors 2 and 3
the other sensor values are transmitted as 0's, e.g.
Code:
TCP data '*HELLO*0D11000000003DFC000C0000000000000000 HTTP/1.0
Host: dns1

looking at your data its appears the default is to transmit all the sesnor values in broadcast, e.g. set up so
Code:
set q s 0xFF		sample all sensors
and you get
Code:
*HELLO*1D17CF29CF2907F33D2507B907FE307B3094 HTTP/1.0
     Host: dns1
if the inputs are floating you get ransom data - can you apply known values to some input (be careful I seem to remember the maximum input is 1.5volts)

- - - Updated - - -

i have a problem just in the Tcp mode ; when i configure with cable it work and when i put the battry it don't work and it display me this messgae in tera term
<4.00> open
<4.00> *OPEN**CLOS**CLOS*
another question about RN171; the default of RN171 is about the connexion in wifi and the detection of an acess point
it looks like the TCP connection is opening OK and then immediatly closing
possibly when working from battery the current drain when transmitting to too large, the battery volts drop and the RN171 resets?
what does the server say?
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
the rn171 don't reset and the tcp server play me error connection
so when i m trying with putting the battery and the cable in same time and when the configuration seting is finish i discnnect the cable:; and it work
if i put the cable and battery in the same time it work via the baterry or with the cable
 

the rn171 don't reset and the tcp server play me error connection
so when i m trying with putting the battery and the cable in same time and when the configuration seting is finish i discnnect the cable:; and it work
if i put the cable and battery in the same time it work via the baterry or with the cable

not sure what your problem is?
have you set up the configuration and saved it to the configuration file using the save command

in particular set autojoin
set wlan join 1

so on power up the RN171 will join the network, open the TCP and start broadcasting?
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
another question about RN171-EK;
i would like to know if i put the battery and the usb cable in the same time, so the RN171 will take power via the PC or via the2 battery
 

another question about RN171-EK;
i would like to know if i put the battery and the usb cable in the same time, so the RN171 will take power via the PC or via the2 battery

looking at the RN131/171 evaluation kit users guide
https://ww1.microchip.com/downloads/en/DeviceDoc/DS50002183A.pdf

3.1.1 Powering the Module
The RN131/RN171 Evaluation Board is powered using the USB cable or through the battery pack, which holds two AAA batteries. However, RN131 Evaluation Board can also be powered using air-wiring.
Note: The RN171 module can also be powered through the USB cable while a battery pack is installed.


also look at the schematic
https://ww1.microchip.com/downloads/en/DeviceDoc/rn-171p-ek_rev2_sch_r.PDF
 
  • Like
Reactions: ings

    ings

    Points: 2
    Helpful Answer Positive Rating
please it is possible to calculate the value of CRC
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top