Hi,
We've tryed to make a coffee pot controled by arduinio and the ethernet shield. We've made a python script and an arduino program.Something does'nt work but we do not know what !!! Could you help us ?
This is the python's script:
import socket
print "~ Client WebCafé ~"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.1.55", 80))
q = 0
while q != 3:
print "- Commande cafetière -"
print "(1) Allumer la cefetière"
print "(2) Eteindre la cafetière"
print "(3) Quitte le programme."
q = int(raw_input())
if q == 1:
print "Allumage de la cafetière ..."
s.send('1')
continue
if q == 2:
print "Extinction de la cafetière ..."
s.send('2')
print "a+ !"
s.close()
And here is the arduino program:
#include <SPI.h>
#include <Ethernet.h>
const int relais=13; //declaration constante de broche. Pour le test, on la met sur la 13 qi contient nativement une led
/* Détails technique de la connexion ethernet */
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192,168,1,55 };
byte gateway[] = {
192,168,1, 1 };
// Attachement d'un objet "server" sur le port 1337
EthernetServer server(80);
void setup()
{
// Configuration de la ethernet shield et du server
Ethernet.begin(mac, ip, gateway);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
pinMode(relais, OUTPUT); //met la broche en sortie
digitalWrite(relais, LOW); // ecrire le relais comme NO
}
void loop()
{
EthernetClient client = server.available();
if (client && client.connected())
{
Serial.println("nouveau client connecté");
char c = client.read();
Serial.write(c);
if (client.available() > 0)
{
switch(client.read())
{
case '1': // turn on the coffe pot
digitalWrite(relais, HIGH);
Serial.println("coffe pot is now working")
case '2': // shut down the coffe pot
digitalWrite(relais, LOW);
break;
}
}
}
}
Excuse me for mistakes, I am french but I prefer post this in english.