EasyManua.ls Logo

sparkfun ESP8266 - Page 18

sparkfun ESP8266
33 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Arduino's Library Manager. Go to the Sketch > Include Library > Manage Libraries..., then
search for "Phant" to find the library. Install the latest version (or at least 2.2.0).
Or you can grab the Phant library from our phant-arduino repository, and follow along with
our Installing an Arduino Library for help installing the library.
Copy the code below, or download the example sketch.
Before uploading your code to the Thing, make sure you modify
the WiFiSSD and WiFiPSK variables, setting them to the SSID and password of your WiFi
network. The rest of the sketch should just work.
COPY CODE
// Include the ESP8266 WiFi library. (Works a lot like the// Arduino WiFi library.)#include <ESP8266WiFi.h>//
Include the SparkFun Phant library.#include <Phant.h>
//////////////////////// WiFi Definitions ////////////////////////const char WiFiSSID[] = "WiFi_Network";
const char WiFiPSK[] = "WiFi_Password";
/////////////////////// Pin Definitions ///////////////////////const int LED_PIN = 5; // Thing's onboard, green LEDconst int
ANALOG_PIN = A0; // The only analog pin on the Thingconst int DIGITAL_PIN = 12; // Digital pin to be read
////////////////// Phant Keys //////////////////const char PhantHost[] = "data.sparkfun.com";
const char PublicKey[] = "wpvZ9pE1qbFJAjaGd3bn";
const char PrivateKey[] = "wzeB1z0xWNt1YJX27xdg";
/////////////////// Post Timing ///////////////////const unsigned long postRate = 30000;
unsigned long lastPost = 0;
void setup()
{
initHardware();
connectWiFi();
digitalWrite(LED_PIN, HIGH);
}

Other manuals for sparkfun ESP8266