fix winc1500 demo, works great with feather

This commit is contained in:
ladyada 2016-08-09 17:00:01 -04:00
parent 4b57d0ddcb
commit fe3aebdad8

View File

@ -18,6 +18,7 @@
#define WINC_CS 8 #define WINC_CS 8
#define WINC_IRQ 7 #define WINC_IRQ 7
#define WINC_RST 4 #define WINC_RST 4
#define WINC_EN 2 // or, tie EN to VCC
Adafruit_WINC1500 WiFi(WINC_CS, WINC_IRQ, WINC_RST); Adafruit_WINC1500 WiFi(WINC_CS, WINC_IRQ, WINC_RST);
@ -31,25 +32,15 @@ int status = WL_IDLE_STATUS;
#define AIO_SERVER "io.adafruit.com" #define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 #define AIO_SERVERPORT 1883
#define AIO_USERNAME "adafruit2" #define AIO_USERNAME "adafruitiousername"
#define AIO_KEY "3e148db54389a8b7c3efa9ddd2cd388317bcbf58" #define AIO_KEY "adafruitiokey"
/************ Global State (you don't need to change this!) ******************/ /************ Global State (you don't need to change this!) ******************/
//Set up the wifi client //Set up the wifi client
Adafruit_WINC1500Client client; Adafruit_WINC1500Client client;
// Store the MQTT server, client ID, username, and password in flash memory. Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
// This is required for using the Adafruit MQTT library.
const char MQTT_SERVER[] PROGMEM = AIO_SERVER;
// Set a unique MQTT client ID using the AIO key + the date and time the sketch
// was compiled (so this should be unique across multiple devices for a user,
// alternatively you can manually set this to a GUID or other random value).
const char MQTT_CLIENTID[] PROGMEM = __TIME__ AIO_USERNAME;
const char MQTT_USERNAME[] PROGMEM = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM = AIO_KEY;
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);
// You don't need to change anything below this line! // You don't need to change anything below this line!
#define halt(s) { Serial.println(F( s )); while(1); } #define halt(s) { Serial.println(F( s )); while(1); }
@ -58,18 +49,21 @@ Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, M
// Setup a feed called 'photocell' for publishing. // Setup a feed called 'photocell' for publishing.
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname> // Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
const char PHOTOCELL_FEED[] PROGMEM = AIO_USERNAME "/feeds/photocell"; Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/photocell");
Adafruit_MQTT_Publish photocell = Adafruit_MQTT_Publish(&mqtt, PHOTOCELL_FEED);
// Setup a feed called 'onoff' for subscribing to changes. // Setup a feed called 'onoff' for subscribing to changes.
const char ONOFF_FEED[] PROGMEM = AIO_USERNAME "/feeds/onoff"; Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff");
Adafruit_MQTT_Subscribe onoffbutton = Adafruit_MQTT_Subscribe(&mqtt, ONOFF_FEED);
/*************************** Sketch Code ************************************/ /*************************** Sketch Code ************************************/
#define LEDPIN 13 #define LEDPIN 13
void setup() { void setup() {
#ifdef WINC_EN
pinMode(WINC_EN, OUTPUT);
digitalWrite(WINC_EN, HIGH);
#endif
while (!Serial); while (!Serial);
Serial.begin(115200); Serial.begin(115200);
@ -160,4 +154,4 @@ void MQTT_connect() {
delay(5000); // wait 5 seconds delay(5000); // wait 5 seconds
} }
Serial.println("MQTT Connected!"); Serial.println("MQTT Connected!");
} }