Go Down

Topic: Coffee pot (Read 653 times) previous topic - next topic

sinicy

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: [Select]
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: [Select]
#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.

PaulS

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

0AlphaOmega

s'il vous plaît donner plus de détails
For whom does the clock pulse? It pulses for you!

MarcGondran

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

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up