code: [select]
buongiorno ho un arduino 2560 con wiznet 5100, vorrei comandare un rele da web server.
riesco vedere la pagina via web e anche comandi per accendere e spegnere il relè, ma quando schiaccio dice off ma in verita non si accende e manco si spegne come posso fare? ho usato questo:
http://ismanettoneblog.altervista.org/blog/lezione-14-come-accendere-lampada-remoto-arduino/
questo è il mio codice:
#include <time.h>
#include <ds3232rtc.h>
#include <pcf8574_hd44780_i2c.h>
#include <wire.h>
#include <onewire.h>
#include <dallastemperature.h>
#include <wire.h>
#include <rtclib.h>
#include <spi.h>
#include <ethernet.h>
// enter mac address , ip address controller below.
// ip address dependent on local network:
byte mac[] = {0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed};
ipaddress ip( 192,168,1,6 );
ipaddress gateway( 192,168,1,1 );
ipaddress subnet( 255,255,255,0 );
ethernetserver server(80);
pcf8574_hd44780_i2c lcd(0x3f, 20, 4);
int oraalba = 9;
int minalba = 10;
long albas;
int durataalbas = 720;
int oratramonto = 17;
int mintramonto = 10;
long tramontos;
int duratatramontos = 720;
long nows;
int delayr = 0;
int delayg = 120;
int delayb = 240;
int delayuv = 360;
int delayw = 360;
int pinr = 2;
int ping = 3;
int pinb = 4;
int pinw = 5;
int pinuv = 6;
//rele
float rele1 = 35;
float rele2 = 37;
int rele3 = 39;
int rele4 = 41;
int rele5 = 43;
int rele6 = 45;
char buffer1[20];
char buffer2[20];
float riscaldatore = 22.0; // allerta temperatura acqua bassa
float alertacqua = 27.0; // ventola tangenziale
float alertplafo = 44.0; // alerta plafoniera temperatura troppo alta
float tempsoglia = 38.0; //temperatura ventole plafo
#define one_wire_bus 7
onewire onewire(one_wire_bus);
dallastemperature sensors(&onewire);
deviceaddress tmp_address;
float temp0=0;
float temp1=0;
int numberofdevices;
#define ventola 35
#define tang 37
#define skim 39
#define pump 41
#define notte 43
#define risc 45
void setup()
{
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
setsyncprovider(rtc.get); // function time rtc
if(timestatus() != timeset)
serial.println("unable sync rtc");
else
serial.println("rtc has set system time");
lcd.init(); // lcd initialization
lcd.backlight( ); // backlight on
lcd.clear(); // clear display
numberofdevices = 1;
// start ethernet connection , server:
ethernet.begin(mac, ip);
server.begin();
serial.print("server @ ");
serial.println(ethernet.localip());
wire.begin();
sensors.begin();
pinmode(pinr, output);
pinmode(ping, output);
pinmode(pinb, output);
pinmode(pinw, output);
pinmode(pinuv, output);
pinmode(rele1, output);
pinmode(rele2, output);
pinmode(rele3, output);
pinmode(rele4, output);
pinmode(rele5, output);
pinmode(ventola, output);
pinmode(tang, output);
pinmode(risc, output);
pinmode(skim, output);
pinmode(pump, output);
pinmode(notte, output);
digitalwrite( rele1, low);
digitalwrite( rele2, low);
digitalwrite( rele3, low );
digitalwrite( rele4, low );
digitalwrite(rele5, low);
delay(3000);
}
#include <time.h>
#include <ds3232rtc.h>
#include <pcf8574_hd44780_i2c.h>
#include <wire.h>
#include <onewire.h>
#include <dallastemperature.h>
#include <wire.h>
#include <rtclib.h>
#include <spi.h>
#include <ethernet.h>
// enter mac address , ip address controller below.
// ip address dependent on local network:
byte mac[] = {0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed};
ipaddress ip( 192,168,1,6 );
ipaddress gateway( 192,168,1,1 );
ipaddress subnet( 255,255,255,0 );
ethernetserver server(80);
pcf8574_hd44780_i2c lcd(0x3f, 20, 4);
int oraalba = 9;
int minalba = 10;
long albas;
int durataalbas = 720;
int oratramonto = 17;
int mintramonto = 10;
long tramontos;
int duratatramontos = 720;
long nows;
int delayr = 0;
int delayg = 120;
int delayb = 240;
int delayuv = 360;
int delayw = 360;
int pinr = 2;
int ping = 3;
int pinb = 4;
int pinw = 5;
int pinuv = 6;
//rele
float rele1 = 35;
float rele2 = 37;
int rele3 = 39;
int rele4 = 41;
int rele5 = 43;
int rele6 = 45;
char buffer1[20];
char buffer2[20];
float riscaldatore = 22.0; // allerta temperatura acqua bassa
float alertacqua = 27.0; // ventola tangenziale
float alertplafo = 44.0; // alerta plafoniera temperatura troppo alta
float tempsoglia = 38.0; //temperatura ventole plafo
#define one_wire_bus 7
onewire onewire(one_wire_bus);
dallastemperature sensors(&onewire);
deviceaddress tmp_address;
float temp0=0;
float temp1=0;
int numberofdevices;
#define ventola 35
#define tang 37
#define skim 39
#define pump 41
#define notte 43
#define risc 45
void setup()
{
serial.begin(9600);
while (!serial) {
; // wait serial port connect. needed leonardo only
}
setsyncprovider(rtc.get); // function time rtc
if(timestatus() != timeset)
serial.println("unable sync rtc");
else
serial.println("rtc has set system time");
lcd.init(); // lcd initialization
lcd.backlight( ); // backlight on
lcd.clear(); // clear display
numberofdevices = 1;
// start ethernet connection , server:
ethernet.begin(mac, ip);
server.begin();
serial.print("server @ ");
serial.println(ethernet.localip());
wire.begin();
sensors.begin();
pinmode(pinr, output);
pinmode(ping, output);
pinmode(pinb, output);
pinmode(pinw, output);
pinmode(pinuv, output);
pinmode(rele1, output);
pinmode(rele2, output);
pinmode(rele3, output);
pinmode(rele4, output);
pinmode(rele5, output);
pinmode(ventola, output);
pinmode(tang, output);
pinmode(risc, output);
pinmode(skim, output);
pinmode(pump, output);
pinmode(notte, output);
digitalwrite( rele1, low);
digitalwrite( rele2, low);
digitalwrite( rele3, low );
digitalwrite( rele4, low );
digitalwrite(rele5, low);
delay(3000);
}
void loop()
{
if (millis() > 500000)
{
digitalwrite(skim, high);
}
//ethernet
// listen incoming clients
ethernetclient client = server.available();
if (client) {
serial.println("new client");
// http request ends blank line
boolean currentlineisblank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
serial.print(c);
// if you've gotten end of line (received newline
// character) , line blank, http request has ended,
// can send reply
if (c == '\n')
// send standard http response header
client.println("http/1.1 200 ok");
client.println("arduino");
client.println();
client.println("<meta charset=utf-8>"); // serve per inserire caretteri speciali
client.println("<!doctype html>");
client.println("<html>");
client.println("<head> <title>arduino</title> </head>"); // viene creato il titolo
client.println("<body> <h1> benvenuto nel webserver arduino </h1>"); // viene inserito del testo
client.println("<h3> attraverso questa pagina è possibile accendere e spegnere un led </h3>");
client.println("</body>");
client.println("</html>");
break;
}
if (c == '\n') {
currentlineisblank = true;
}
else if (c != '\r') {
currentlineisblank = false;
}
}
}
client.print(now.day(), dec);
client.print('/');
client.print(now.month(), dec);
client.print('/');
client.print(now.year(), dec);
client.print(' ');
client.print(now.hour(), dec);
client.print(':');
client.print(now.minute(), dec);
client.println(" ");
client.print("pagina di marco");
client.println(" ");
client.print("acqua");
client.println(" ");
client.print(temp0);
client.println(" ");
client.println("plafo");
client.print(temp1);
ma cosa diavolo hai postato ??
ci sono, pare, due programmi, 2 setup, linee che seguono l'ultima graffa messe cavolo.
e poi dicci quali sono sensori collegati.
hai una arduino leonardo ? no, parli di mega2650, allora perchè lasci questo pezzo, c'e' pure scritto.
ci sono, pare, due programmi, 2 setup, linee che seguono l'ultima graffa messe cavolo.
e poi dicci quali sono sensori collegati.
hai una arduino leonardo ? no, parli di mega2650, allora perchè lasci questo pezzo, c'e' pure scritto.
code: [select]
while (!serial) {
; // wait serial port connect. needed leonardo only
}
Arduino Forum > International > Italiano > Software (Moderator: leo72) > aiuto come commandare un rele da web server arduino
arduino
Comments
Post a Comment