Communication over wireless Lan with Arduino

edited January 2014 in Arduino

Hi, I am working on a weather station with Arduino. Up till now my Arduino Uno is via USB connected with my computer. It is working fine with the Firmata software on the Arduino. But I want to connect the Arduino over Wlan, because I cannot use a cable from my garden to my house! From the Arduino site everything is solved. I can connect with the arduino over a telnet process "telnet address port". When I send a character I get a string with the light intensity, temperature and air pressure. But if I try it from Processing with the source:

import hypermedia.net.*;

 import hypermedia.net.*;

 UDP udp;  // define the UDP object


 void setup() {
 udp = new UDP( this, 6000 );   // create a new datagram connection on port 8888
 udp.log( true );                        // <-- printout the connection activity
 udp.listen( true );                    // and wait for incoming message  
 }

 void draw()
 {
 }

 void keyPressed() {
   String ip       = "192.168.2.109"; // the remote IP address
   int port        = 8888;        // the destination port

   println("s gesendet an . " + ip + ":" + port);
   udp.send("s\n", ip, port );   // the message to send

 }

 void receive( byte[] data ) {          // <-- default handler
   //void receive( byte[] data, String ip, int port ) {   // <-- extended handler

   for(int i=0; i < data.length; i++) 
     print(char(data[i]));  
   println();   
 }

After I pressed a key the message is sent:

UPD session started
bound socket to host:null, port:6000
sent packet -> address:192.168.2.109, port:8888 length:2

But I do not get any response. The Arduino does not get any character, because a LED would show that something arrived. When I stop the Processing program I get a message:

close socket < port:6000 address:null

I am wondering about the host and the address "null". What is wrong on my program?

Answers

  • Answer ✓

    Moved topic & reformatted code: see sticky post To newcomers in this forum: read attentively these instructions

  • Answer ✓

    it work correctly

    try with arduino example and modify the line

        status = WiFi.begin(ssid);
        with:
        status = WiFi.begin(ssid,pass);
    

    http://arduino.cc/en/Tutorial/WiFiSendReceiveUDPString

  • My Arduino program works fine, but my Processing program has difficulties. with a telnet session i send a keystroke and the Arduino program answers with the right information, but when I send a signal from the Processing program I get no response. So I think the problem is in the Processing program and not in the Arduino site!

  • edited January 2014

    hi vdhart, i dont know your setup and that udp library, but i'm pretty sure that telnet uses a tcp connection. so if your arduino responds to the telnet command i guess it is listening for a tcp connection, so i don't think the library will work with the arduino.

    you could try the processing tcp client.

  • I solved the problem. I do not use UDP anymore, but a server client communication and it works fine!

Sign In or Register to comment.