ciao a tutti,
non riesco poprio a farla funzionare questa shield wifi.... vi posto il tentativo (non funzionante) che mi sta dando delle belle rogne...
questa è la shield
questo il codice
#include <WiServer.h>
#include <ShiftRegLCD.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68 //set rtc
#define ONE_WIRE_BUS 4 //Define the pin of the DS18B20
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
altri int.... tolti per fare spazio
int blue = 3; // blue LEDs connected to digital pin 3 (pwm)
int white = 9; // white LEDs connected to digital pin 11 (pwm)
int ledlcd = A0; // led lcd connected to analog pin 0
int livellob = A1;
int livellom = A2;
int livelloa = A3;
ShiftRegLCD srlcd(7, 8, 6, 2);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| RTC 1307 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
byte decToBcd(byte val) // Convert normal decimal numbers to binary coded decimal
{
return ( (val/10*16) + (val%10) );
}
byte bcdToDec(byte val) // Convert binary coded decimal to normal decimal numbers
{
return ( (val/16*10) + (val%16) );
}
etc etc...
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ONESECOND --> OPERAZIONI CICLICHE RIPETUTE OGNI SECONDO|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void onesecond() //function that runs once per second while program is running
{
byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
srlcd.setCursor(0, 0);
srlcd.print(hour, DEC);
srlcd.print(":");
if (minute < 10) {
srlcd.print("0");
}
srlcd.print(minute, DEC);
srlcd.setCursor(8, 0);
if (dayOfMonth < 10) {
srlcd.print("0");
}
srlcd.print(dayOfMonth, DEC);
srlcd.print("/");
if (month < 10){
srlcd.print("0");
}
srlcd.print(month, DEC);
srlcd.print("/");
srlcd.print(year, DEC);
srlcd.setCursor(13, 3);
if (digitalRead(livellob) == LOW){
srlcd.write(1);
}
else {
srlcd.write(0);
}
srlcd.setCursor(14, 3);
if (digitalRead(livellom) == LOW){
srlcd.write(1);
}
else {
srlcd.write(0);
}
srlcd.setCursor(15, 3);
if (digitalRead(livelloa) == LOW){
srlcd.write(1);
}
else {
srlcd.write(0);
}
// lcd.print(":");
//if (second < 10) {
// lcd.print("0");
// }
// lcd.print(second, DEC);
// lcd.print(" ");
WiServer.server_task();
// delay(10);
delay(1000);
}
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| WIFI CONFIGURAZIONE|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,120}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"Cisco Home 2,4 gHz"}; // max 32 bytes
unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"15342985dresa"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys//
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
// Check if the requested URL matches "/"
if (strcmp(URL, "/") == 0) {
// Use WiServer's print and println functions to write out the page content
WiServer.print("<html>");
WiServer.print("Hello World!");
WiServer.print("</html>");
// URL was recognized
return true;
}
// URL not found
return false;
}
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| S E T U P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void setup() {
// pinMode(ledPin1, OUTPUT); // set the digital pin as output:
// pinMode(ledPin2, OUTPUT); // set the digital pin as output:
pinMode(ledlcd, OUTPUT); // Set analog pin 0 as a output
pinMode(livellob, INPUT);
pinMode(livellom, INPUT);
pinMode(livelloa, INPUT);
digitalWrite(livellob, HIGH);
digitalWrite(livellom, HIGH);
digitalWrite(livelloa, HIGH);
// pinMode(fuge, OUTPUT); // Set analog pin 1 as a output
// pinMode(moon, OUTPUT); // Set analog pin 3 as a output
sensors.begin(); // Start up the DS18B20 Temp library
// wifi//
// Initialize WiServer and have it use the sendMyPage function to serve pages
WiServer.init(sendMyPage);
// Enable Serial output and ask WiServer to generate log messages (optional)
//Serial.begin(57600);
// WiServer.enableVerboseMode(true);
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| SETUP DISPLAY |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| L O O P |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
void loop()
{
onesecond();
// relay2();
// relay1();
// Run WiServer
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| FUNZIONI DIMMING|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| LOOP CRESCENTE|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| LOOP MANTENIMENTO|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| LOOP DECRESCENTE|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
//*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| N O T T E |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
} // END LOOP
il risultato che ottengo è questo:
una volta caricato il programma arduino non da segni di vita per circa 30 secondi, dopodiché parte ma le sonde di temperatura non le legge ed il wifi non si aggancia alla rete nonostante sia a 2 metri dal router...
Forse non vanno uniti in questo modo i due programmi?
Ciao a tutti
Luca