Pages: [1]   Go Down
Author Topic: Coffee pot  (Read 499 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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:
Code:
#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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code you posted does something. You want it to do something. What either of those somethings is only you know.
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

s'il vous plaît donner plus de détails
Logged

For whom does the clock pulse? It pulses for you!

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Every thing is on this website http://somecafe.perso.sfr.fr/ but it's in french. We execute the python script on a distant client witch send 1 or 2. The Arduino ( server ) switch the 13 pin on if 1 and off if 2 !!!
PS: I'm a Coauthor
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
2. The Arduino ( server ) switch the 13 pin on if 1 and off if 2 !!!

Using pin 13 could conflict with the ethernet shield operation.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: