Hello,
i have a problem with the ethernet and the easyvr Shield.
Separately the shield work's fine.
When i stack modules together, i can't obtain a ip address.....
did you have a idea ?
/*
Web client
This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 18 Dec 2009
by David A. Mellis
*/
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "SoftwareSerial.h"
SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
#include "WProgram.h"
#include "NewSoftSerial.h"
NewSoftSerial port(12,13);
#endif
#include <SPI.h>
#include <Ethernet.h>
#include "EasyVR.h"
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0x90, 0xA2, 0xDA, 0x08, 0x00, 0xBF };
IPAddress server(192,168,2,114); // Google
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
EasyVR easyvr(port);
EasyVRBridge bridge;
uint32_t mask = 0;
int8_t group = 0;
uint8_t train = 0;
char name[32];
void setup() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// give the Ethernet shield a second to initialize:
delay(1000);
// bridge mode?
if (bridge.check()) {
cli();
bridge.loop(0, 1, 12, 13);
}
if (!easyvr.detect()) {
Serial.println("EasyVR not detected!");
for (;;);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println("EasyVR detected!");
easyvr.setTimeout(5);
easyvr.setLanguage(EasyVR::FRENCH);
int16_t count = 0;
if (easyvr.getGroupMask(mask)) // get trained user names and passwords
{
uint32_t msk = mask;
for (group = 0; group <= EasyVR::PASSWORD; ++group, msk >>= 1)
{
if (!(msk & 1)) continue;
if (group == EasyVR::TRIGGER)
Serial.print("Trigger: ");
else if (group == EasyVR::PASSWORD)
Serial.print("Password: ");
else
{
Serial.print("Group ");
Serial.print(group);
Serial.print(": ");
}
count = easyvr.getCommandCount(group);
Serial.println(count);
for (int8_t idx = 0; idx < count; ++idx)
{
if (easyvr.dumpCommand(group, idx, name, train))
{
Serial.print(idx);
Serial.print(" = ");
Serial.print(name);
Serial.print(", Trained ");
Serial.print(train, DEC);
if (!easyvr.isConflict())
Serial.println(" times, OK");
else
{
int8_t confl = easyvr.getWord();
if (confl >= 0)
Serial.print(" times, Similar to Word ");
else
{
confl = easyvr.getCommand();
Serial.print(" times, Similar to Command ");
}
Serial.println(confl);
}
}
}
}
}
}
void loop()
{
int idx_cmd;
int idx_pwd;
easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
Serial.println("Say a name in Group 1");
easyvr.recognizeCommand(1); // recognise command in group 1
while (!easyvr.hasFinished()); // wait for user name
easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
idx_cmd = easyvr.getCommand(); // get recognised command
if (idx_cmd >= 0)
{
Serial.print("Command: ");
if (easyvr.dumpCommand(1, idx_cmd, name, train))
Serial.println(name);
else
Serial.println();
/*
Serial.println("Say the password");
easyvr.recognizeCommand(EasyVR::PASSWORD); // set group 16
while (!easyvr.hasFinished()); // wait for password
*/
easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
Serial.println("Say command");
easyvr.recognizeCommand(1); // set group 16
while (!easyvr.hasFinished()); // wait for password
/*
idx_pwd = easyvr.getCommand(); // get recognised password
if (idx_pwd >= 0)
{
Serial.print("Password: ");
if (easyvr.dumpCommand(EasyVR::PASSWORD, idx_pwd, name, train))
{
Serial.print(" = ");
Serial.println(name);
}
else
Serial.println();
if ( idx_pwd == idx_cmd) // index of username and password are the same, access granted
{
Serial.println("Access granted");
}
else // index of username and password differ, access is denied
{
Serial.println("Access denied");
}
}
*/
int16_t err = easyvr.getError();
if (easyvr.isTimeout() || (err >= 0)) // password timeout, access is denied
{
Serial.println("Error, try again...");
}
}
else
{
if (easyvr.isTimeout())
Serial.println("Timed out, try again...");
int16_t err = easyvr.getError();
if (err >= 0)
{
Serial.print("Error ");
Serial.println(err, HEX);
}
}
/*
//Read input
if (val == 0) {
connectWS("off");
} else if (val == 1) {
connectWS("on");
}
*/
}
String connectWS(char* action){
//port 80 is typical of a www page
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /index.php?action=" + (String)action + " HTTP/1.0");
client.println("Connection: close");
client.println();
disconnectWS();
}
}
String disconnectWS() {
delay(10);
Serial.println("disconnecting.");
Serial.flush();
client.stop();
}