ciao ragazzi. ho arduino 2009+ arduino ethernet schield. dovrei fare un programma che mi dia tramite web in locale una pagina dove posso dare diversi commandi ed arduino produce delle sucite. ho visto che tiny web server fà proprio quello che serve a me. questa è la pagina dove lo ho trovato:
http://www.webweavertech.com/ovidiu/weblog/archives/000484.html
però non sò come inserirlo su arduino. uso ubuntu per programmare arduino e il file.sh dà diversi errori. come lo carico questo su arduino?
scarica la libreria da GitHub - ovidiucp/TinyWebServer: Small web server for Arduino, fits in 10KB ROM, less than 512 bytes RAM e segui le istruzioni. Senza vedere che gli errori che genera l'ide anche i gurù del forum avranno difficolta ad aiutarti..
e quali sono le isstruzioni? io cerco di far partile un file .sh ma mi da errore. mi potresti dire le istruzioni esatte dall' inzio? grazie.
nessuno mi sà aiutare?
uso windows non ti so aiutare più di tanto. Le varie librerie vanno messe in \arduino\libraries. Nel caso di tinywebserver sono 2 file: TinyWebServer.cpp e TinyWebServer.h (poi c'è la directory degli esempi).
Se hai copiato tutto nel posto giusto in arduino file/example puoi caricare tutti gli esempi e fare dei test..
Ricordati anche di copiare le altre librerie sd e flash
To make use of the TinyWebServer library, you need to include the following your sketch:
#include <Ethernet.h>
#include <Flash.h>
#include <SD.h>
#include <TinyWebServer.h>
e ora mi devo prepare che la suocera mi aspetta per il pranzo di Pasqua...
grazie mille.. ci sono riuscito.il mio errore era quello di non mettere la libreria flash. adesso ho un altro piccolo problema però. il collegamento al modem della internet shield non funziona quando scollego la presa usb di arduino 2009 dal computer. come mai?
marcobiondo13:
il collegamento al modem della internet shield non funziona quando scollego la presa usb di arduino 2009 dal computer. come mai?
Il collegamento USB funge anche da alimentazione o hai un alimentatore separato?
Arduino da spento non funziona. ]
Felice Pasqua.
Paolo.
no ho anche alimentatore separato. arduino rimane acceso le luci di power rimangono accese però viene disabilitato il collegamento ethernet l-rx della scheda ethernet non lampeggiano più. come mai? buona pasqua a tutti voi...
per modem intendi router / switch?
Il led del link con il router si accende? controlla bene cavi, indirizzo di rete etc...
cosa dovrei controllare?
up
dovresti controllare quello che ti ho scritto. In ogni caso non sappiamo che router hai, se usi un cavo cross (con router/hub non ne hai bisogno), se hai cambiato l'indirizzo ip del tinywebserver con la tua stessa sottorete etc..
come vedi le variabili che non conosciamo sono tante, dovresti dircele tu perché noi possiamo capire quello che succede, altrimenti è un inutile scambiarsi di messaggi con prove che poi ti fanno perdere solo tempo
Leggendo il post mi chiedo che alimentatori stai usando dato che alimentato con l'usb funziona ma se lo stacchi no.
Prova un alimentatore da 12V continui.
Ciao..
presumendo che usa un alimentatore esterno fa presto a provarne un altro. A volte per dei test, uso il carica del cellulare da 5v.
lo collego tramite cavo ethernet normale. ad un router della tp-link. l' alimentatore è un 9 volt esterno visto che con il 12 volt scaldava troppo. l' indirizzo di tiny web server lo ho cambiato infatto si colega in maniera regolare. quali altri apsetti devo controllare?
ho risolto. era l' alimentatore esterno. adesso ho rpovato con un altro e tutto ok. adesso un altra domanda:
usando questo codice:
// -*- c++ -*-
//
// Copyright 2010 Ovidiu Predescu <ovidiu@gmail.com>
// Date: December 2010
// Updated: 08-JAN-2012 for Arduno IDE 1.0 by <Hardcore@hardcoreforensics.com>
//
#include <pins_arduino.h>
#include <SPI.h>
#include <Ethernet.h>
#include <Flash.h>
#include <SD.h>
#include <TinyWebServer.h>
/****************VALUES YOU CHANGE*************/
// The LED attached to PIN X on an Arduino board.
const int LEDPIN = 7;
// pin 4 is the SPI select pin for the SDcard
const int SD_CS = 4;
// pin 10 is the SPI select pin for the Ethernet
const int ETHER_CS = 10;
// Don't forget to modify the IP to an available one on your home network
byte ip[] = { 192, 168, 5, 177 };
/*********************************************/
static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// The initial state of the LED
int ledState = LOW;
void setLedEnabled(boolean state) {
ledState = state;
digitalWrite(LEDPIN, ledState);
}
inline boolean getLedState() { return ledState; }
boolean file_handler(TinyWebServer& web_server);
boolean blink_led_handler(TinyWebServer& web_server);
boolean led_status_handler(TinyWebServer& web_server);
boolean index_handler(TinyWebServer& web_server);
TinyWebServer::PathHandler handlers[] = {
// Work around Arduino's IDE preprocessor bug in handling /* inside
// strings.
//
// `put_handler' is defined in TinyWebServer
{"/", TinyWebServer::GET, &index_handler },
{"/upload/" "*", TinyWebServer::PUT, &TinyWebPutHandler::put_handler },
{"/blinkled", TinyWebServer::POST, &blink_led_handler },
{"/ledstatus" "*", TinyWebServer::GET, &led_status_handler },
{"/" "*", TinyWebServer::GET, &file_handler },
{NULL},
};
const char* headers[] = {
"Content-Length",
NULL
};
TinyWebServer web = TinyWebServer(handlers, headers);
boolean has_filesystem = true;
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
void send_file_name(TinyWebServer& web_server, const char* filename) {
if (!filename) {
web_server.send_error_code(404);
web_server << F("Could not parse URL");
} else {
TinyWebServer::MimeType mime_type
= TinyWebServer::get_mime_type_from_filename(filename);
web_server.send_error_code(200);
web_server.send_content_type(mime_type);
web_server.end_headers();
if (file.open(&root, filename, O_READ)) {
Serial << F("Read file "); Serial.println(filename);
web_server.send_file(file);
file.close();
} else {
web_server << F("Could not find file: ") << filename << "\n";
}
}
}
boolean file_handler(TinyWebServer& web_server) {
char* filename = TinyWebServer::get_file_from_path(web_server.get_path());
send_file_name(web_server, filename);
free(filename);
return true;
}
boolean blink_led_handler(TinyWebServer& web_server) {
web_server.send_error_code(200);
web_server.send_content_type("text/plain");
web_server.end_headers();
// Reverse the state of the LED.
setLedEnabled(!getLedState());
Client& client = web_server.get_client();
if (client.available()) {
char ch = (char)client.read();
if (ch == '0') {
setLedEnabled(false);
} else if (ch == '1') {
setLedEnabled(true);
}
}
return true;
}
boolean led_status_handler(TinyWebServer& web_server) {
web_server.send_error_code(200);
web_server.send_content_type("text/plain");
web_server.end_headers();
Client& client = web_server.get_client();
client.println(getLedState(), DEC);
return true;
}
boolean index_handler(TinyWebServer& web_server) {
send_file_name(web_server, "INDEX.HTM");
return true;
}
void file_uploader_handler(TinyWebServer& web_server,
TinyWebPutHandler::PutAction action,
char* buffer, int size) {
static uint32_t start_time;
static uint32_t total_size;
switch (action) {
case TinyWebPutHandler::START:
start_time = millis();
total_size = 0;
if (!file.isOpen()) {
// File is not opened, create it. First obtain the desired name
// from the request path.
char* fname = web_server.get_file_from_path(web_server.get_path());
if (fname) {
Serial << F("Creating ") << fname << "\n";
file.open(&root, fname, O_CREAT | O_WRITE | O_TRUNC);
free(fname);
}
}
break;
case TinyWebPutHandler::WRITE:
if (file.isOpen()) {
file.write(buffer, size);
total_size += size;
}
break;
case TinyWebPutHandler::END:
file.sync();
Serial << F("Wrote ") << file.fileSize() << F(" bytes in ")
<< millis() - start_time << F(" millis (received ")
<< total_size << F(" bytes)\n");
file.close();
}
}
void setup() {
Serial.begin(115200);
Serial << F("Free RAM: ") << FreeRam() << "\n";
pinMode(LEDPIN, OUTPUT);
setLedEnabled(false);
pinMode(SS_PIN, OUTPUT); // set the SS pin as an output
// (necessary to keep the board as
// master and not SPI slave)
digitalWrite(SS_PIN, HIGH); // and ensure SS is high
// Ensure we are in a consistent state after power-up or a reset
// button These pins are standard for the Arduino w5100 Rev 3
// ethernet board They may need to be re-jigged for different boards
pinMode(ETHER_CS, OUTPUT); // Set the CS pin as an output
digitalWrite(ETHER_CS, HIGH); // Turn off the W5100 chip! (wait for
// configuration)
pinMode(SD_CS, OUTPUT); // Set the SDcard CS pin as an output
digitalWrite(SD_CS, HIGH); // Turn off the SD card! (wait for
// configuration)
// initialize the SD card.
Serial << F("Setting up SD card...\n");
// Pass over the speed and Chip select for the SD card
if (!card.init(SPI_FULL_SPEED, SD_CS)) {
Serial << F("card failed\n");
has_filesystem = false;
}
// initialize a FAT volume.
if (!volume.init(&card)) {
Serial << F("vol.init failed!\n");
has_filesystem = false;
}
if (!root.openRoot(&volume)) {
Serial << F("openRoot failed");
has_filesystem = false;
}
if (has_filesystem) {
// Assign our function to `upload_handler_fn'.
TinyWebPutHandler::put_handler_fn = file_uploader_handler;
}
// Initialize the Ethernet.
Serial << F("Setting up the Ethernet card...\n");
Ethernet.begin(mac, ip);
// Start the web server.
Serial << F("Web server starting...\n");
web.begin();
Serial << F("Ready to accept HTTP requests.\n");
}
void loop() {
if (has_filesystem) {
web.process();
}
}
posso fare una pagina web con 4 comandi attraverso il click di 4 immagini che facciamo andare a livello alto ( attiva) le porte digitali di arduino?
si lo puoi fare, è tutta una questione di crearti una pagina web con le 4 immagini .png un po' di css e jquery POST e GET, far poi riconoscere i messaggi ad arduino ed eseguire quello che vuoi, tutto dentro la SD card. Se hai un pò di dimestichezza con javascript e html non è difficile altrimenti lo diventa.
qui c'e' quello che cerchi Arduino Forum
ciao
per non far rimanere il tasto schiacciato quindi quando il mouse lo schiaccia arduino accende il led e quando mollo non lo accende più cosa dovrei fare? che file dovrei modificare?
marco ma di cosa stai parlando?
per esempio se devo far accendere il led uno schiaccio e rimane acceso fino a quando non lo schiaccio di nuovo che torna in off. volendo è possibile che il tasto rimanga in on solo mentre clicco sul tasto con il mouse? e poi come mollo il mouse torna automaticamente su off? così mi sono spiegato? grazie comunque per le risposte di voi tutti...