I have made a wix website but, I do not have the IP address of the website. Is it possible if I could connect the ethernet shield to the wix website?
Yes, create a client object and you can use the webaddress (the name) or the IP address. Both will work.
Thanks for your reply.
Could I ask is it that I have to use the webclient code and use the
char server[] = "www.google.com";
uncomment the line
IPAddress server(192,123,1,4); // Google
But, am I able to send data to the website? and how am I going to do it?
Currently, I am using web server for the sending and client as the receiving.
I do not know how to use client as the sending and receiving.
Thank you very much.
When you want to read data from a website, that is typical a client in the Arduino.
When you run a webpage on the Arduino, that is a server.
When you send data to an external website using GET or POST, the object EthernetClient is used. The Arduino is the client. See the WebClient Tutorial.
That tutorial uses "www.google.com" for the name of the server to connect to, no use of IPaddress server.
I don't know wix.com. Do they have special things for uploading data ? I use only ThingSpeak.com They have examples for the Arduino.
Thanks for your reply and help.
Could I ask how to send data to webserver using webclient?
I meant there is a shield with the webserver code and another is using webclient.
I know it is a little weird since usually webserver is for sending and webclient for receiving.
But, I wanted to have 3 ethernet shield to work together with 1 for sending, 1 for receiving and 1 for both.
Cause there is 2 shield reading sensors and 1 shield receiving the value and display. The 1 shield that is reading sensor also have to display the value of the another shield that is reading.
Is it possible to do it?
Thanks in advance.
This is for a webpage, that has PHP : Arduino Playground - WebClient
But you don't have an external website with PHP.
To send data between Arduino board via ethernet, you can use UDP.
It works okay for sensor data, but a UDP package might get lost.
The UDP functions are at the lower-right of that page. The reference of the functions have often short examples.
The functions parsePacket() and available() on one side and beginPacket() and write() on the other side (along with the other functions begin(), endPacket() and so on of course).
Thanks a lot.
But could I check with you with the UDP sendreceivestring code:
/*
UDPSendReceive.pde:
This sketch receives UDP message strings, prints them to the serial port
and sends an "acknowledge" string back to the sender
A Processing sketch is included at the end of file that can be used to send
and received messages for testing with a computer.
created 21 Aug 2010
by Michael Margolis
This code is in the public domain.
*/
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
unsigned int localPort = 8888; // local port to listen on
// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged"; // a string to send back
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
Serial.begin(9600);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remote = Udp.remoteIP();
for (int i =0; i < 4; i++)
{
Serial.print(remote[i], DEC);
if (i < 3)
{
Serial.print(".");
}
}
Serial.print(", port ");
Serial.println(Udp.remotePort());
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
Serial.println("Contents:");
Serial.println(packetBuffer);
// send a reply, to the IP address and port that sent us the packet we received
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}
delay(10);
}
import hypermedia.net.*;
UDP udp; // define the UDP object
void setup() {
udp = new UDP( this, 6000 ); // create a new datagram connection on port 6000
//udp.log( true ); // <-- printout the connection activity
udp.listen( true ); // and wait for incoming message
}
void draw()
{
}
void keyPressed() {
String ip = "192.168.1.177"; // the remote IP address
int port = 8888; // the destination port
udp.send("Hello World", 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();
}
I try uploading to my board. But I keep getting expected '.' or '... ' before 'data'. I try finding which part i didn't comment out or any missing part. But, I couldn't find it.
And could I ask what would actually being displayed out? I try other code and could not see what is actually being display. There is not acknowledge reply from either side.
Really thanks for your help.
You uncommented the code at the bottom, but that is not Arduino code.
Use the example as it is and it will compile.
The compiler gets confused, it says : "error: expected ',' or '...' before 'data'", but it should say : "I dont understand the import hypermedia.net.* and I also don't understand the code after that".
So you are trying to communicate between Arduino boards via Ethernet ? And wix.com is not yet in the picture ?
Oops, I don't have two shields with W5100, my bad. I can't test UDP communication between them.