Esp8266

So my HowTo in a nutshell.

I bought ESP8266-07 modules from AliExpress for a whole $2 each shipped. ESP8266 serial WIFI model ESP 07 Authenticity Guaranteed ESP 07S|Integrated Circuits| - AliExpress

To use them, you must provide a 3.3V supply between VCC and GND, attach the EN pin to VCC, and GPIO15 to GND.

To program, you must pull GPIO0 low, and momenterally put RST low to get into flashing mode.

You should also have an FTDI RS232-3V3 cable or some other USB to Serial converter with 3.3V logic.

Wire up the RX to TX and TX to RX plus GND from the RS232 cable to your ESP8266. If you have 3.3V on there, you can use it to power up your ESP, but I recommend an external supply with your programming jumpers.

Now download the Arduino software, and drop this in the additional boards field under preferences. http://arduino.esp8266.com/stable/package_esp8266com_index.json.

After doing this, if you go under tools, board manager, there will be an option to install the esp8266 stuff. This will allow you to select the ESP8266 as a programming target and program it like an Arduino. Aces!!

Now select the Generic ESP8266 with 64K SPIFFS and 115200 baud.

To check that you’ve selected the correct Open the Serial monitor, set it to 74880, as this is what my ESP8266-07 defaults to, and tap the reset low, or toggle the EN pin. You should see some bootloader text.

Now, I recommend you flash this sketch:

//Note that for the  ESP-07, the blue led is on GPIO2

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 2 as an output.
  pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(2, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(2, LOW);    // turn the LED off by making the voltage LOW
  delay(2000);              // wait for a second
}

This will flash the blue led. Compile for ESP8266, and upload. If you have issues, remember that GPIO15, and GPIO0 must be low during programming, EN high, and you need to pull RST low momentarily to get the right mode.

If your blue LED is flashing (you might need to reset again. remove the jumper low to GPIO0), you have success.

Now go into the dashboard and create, as @ats1080s says, ANY arduino device, copy and paste your token, ssid, and password into this sketch:

#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#include "CayenneDefines.h"
#include "BlynkSimpleEsp8266.h"
#include "CayenneWiFiClient.h"

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "<your_token>";
// Your network name and password.
char ssid[] = "<your_ssid>";
char password[] = "<your_pwd>";

void setup()
{
  // initialize digital pin 2 as an output.
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  Cayenne.begin(token, ssid, password);
}

void loop()
{
  Cayenne.run();
}

// This function will be called every time a Dashboard widget writes a value to Virtual Pin 2.
CAYENNE_IN(V2)
{
  CAYENNE_LOG("Got a value: %s", getValue.asStr());
  int i = getValue.asInt();
  
  if (i == 0)
  {
    digitalWrite(2, LOW);
  }
  else
  {
    digitalWrite(2, HIGH);
  }  
}

After resetting, you can go into the serial monitor. It should now show you stuff at 9600 baud. Watch it connect to your network and the dashboard.

Now add a virtual button 2, to turn your LED on and off, or just use the digital 2.

And that’s all there is too it.

Cheers,

Craig

12 Likes