Note that there are some explanatory texts on larger screens.

plurals
  1. POSend Arduino data via a Wi-Fi shield to a specific IP address on the LAN
    primarykey
    data
    text
    <p>I'm attempting to send sensor data from an <a href="http://arduino.cc/en/Main/ArduinoBoardUno">Arduino Uno</a> via a <a href="http://www.robotshop.com/cuhead-wifi-shield-v2-0-arduino-3.html">Copperhead Wi-Fi shield</a> to a specific IP address and port on a LAN.</p> <p>I can get the Copperhead Wi-Fi Server example <a href="http://www.arduino.cc/en/Tutorial/Sketch">sketch</a> to work (pasted below). However, I'm not interested in responding to server requests via HTML. All I'm interested in is setting up a socket-like connection and sending data via TCP or UDP to IP address 192.168.0.3, port 1234.</p> <p>I'm sure there is an easy solution to this, but as I am new to Arduino and my attempts to find a solution have been unsuccessful.</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;WiServer.h&gt; #define WIRELESS_MODE_INFRA 1 #define WIRELESS_MODE_ADHOC 2 // Wireless configuration parameters ---------------------------------------- unsigned char local_ip[] = {192,168,0,2}; // IP address of WiShield unsigned char gateway_ip[] = {192,168,0,1}; // router or gateway IP address unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network const prog_char ssid[] PROGMEM = {"WiFi_AP"}; // max 32 bytes unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2 // WPA/WPA2 passphrase const prog_char security_passphrase[] PROGMEM = {"12345678"}; // max 64 characters // WEP 128-bit keys // sample HEX keys prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3 }; // Setup the wireless mode // Infrastructure - connect to AP // Adhoc - connect to another Wi-Fi device unsigned char wireless_mode = WIRELESS_MODE_INFRA; unsigned char ssid_len; unsigned char security_passphrase_len; // End of wireless configuration parameters ---------------------------------------- // This is our page serving function that generates web pages boolean sendMyPage(char* URL) { // Check if the requested URL matches "/" if (strcmp(URL, "/") == 0) { // Use WiServer's print and println functions to write out the page content WiServer.print("&lt;html&gt;"); WiServer.print("Hello World"); WiServer.print("&lt;/html&gt;"); // URL was recognized return true; } // URL not found return false; } void setup() { // Initialize WiServer and have it use the sendMyPage function to serve pages WiServer.init(sendMyPage); // Enable Serial output and ask WiServer to generate log messages (optional) Serial.begin(57600); WiServer.enableVerboseMode(true); } void loop(){ // Run WiServer WiServer.server_task(); delay(10); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload