Bitbull Tech Notes - home of free minds ...

Getting started with ESP8266 ESP01 and Arduino IDE 1.6

Hi there

Today I started programming the tiny low cost chip ESP8266.
First I ordered some ESP-01 variants to get my Arduino Projects communicating wireless.
By waiting for delivery I started reading about the chip-set, and it is amazing what you can do with it!

ESP-01 Variant has the following specifications:
It’s running at 80MHz
32KBytes of instruction RAM
96KBytes of data RAM
64KBytes boot ROM
It has a Winbond W25Q40BVNIG SPI flash with 1024kB Flash (old blue version has 512kB)
It’s a RISC architecture
The core is a 106micro Diamond Standard core (LX3) made by Tensilica
2 GPIO Pins
http://www.addicore.com/ESP8266-ESP-01-p/130.htm

As far as I know you can program it with the following code/IDE:

I tested programming it with Arduino IDE and it worked like a charm out of the box:

  • Integrate ESP8266 Boards into Arduino IDE
    https://github.com/esp8266/Arduino
  • Tools > Board > Generic ESP8266 Module
  • File > Examples > ESP2866WebServer > AdvancedWebserver
  • Edit SSID and WPA_Secret
  • Connect Serial Console (to get IP when booting)
  • Compile and Upload

All you need is:

 

 

 

 

Pseudo Clock with millis()

Hi,
I needed a clock like function for plant watering and growing light.
But I did not need to have accurate time, so I decided to program this clock.
And hey ... it does work like a charm!

#include <EEPROM.h>

// ---------- GLOBAL VARS ----------  ---------- ---------- ----------
unsigned long currentMillis;

// ---------- EEPROM SPACE FOR BOOT PERSISTENT VARS ----------
#define timeHourEE     1
#define timeMinEE       2 

// ---------- PSEUDO CLOCK VARS ----------  ---------- ---------- ----------
int timeHour = EEPROM.read(timeHourEE);
int timeMin  = EEPROM.read(timeMinEE);
unsigned long timeShift = 0;
unsigned long previousMillisTime = 0;
unsigned long currentMillisTime = 0;

void setup() {    
  // ---------- GLOBAL SETUP ----------
  Serial.begin(9600);
  // ---------- WAIT FOR HUMAN TO SETTLE UP SERIAL CONSOLE ----------
  delay( 2000 );
  Serial.println(F("INFO: Arduino is online")); 
}

void loop(){ 

  // ---------- PSEUDO CLOCK ----------  ----------  ---------- 
  currentMillisTime=millis();
  if(currentMillisTime - previousMillisTime >= 60000UL ) {   // is last check more than 1min ago
    timeShift = (currentMillisTime - previousMillisTime) / 60000UL ; // how many minutes are gone?
    previousMillisTime = previousMillisTime + ( timeShift * 59900UL ) ;  // adjust last check time stamp (adjust clock speed here)
    timeMin = timeMin + (int)timeShift;
    EEPROM.write(timeMinEE, timeMin);
    Serial.print(F("DEBUG: ")); 
    Serial.print(timeHour); 
    Serial.print(F(":")); 
    Serial.println(timeMin);
    if (timeMin >= 60) {
      timeHour++; 
      if (timeHour >= 24) { 
        timeHour = 0; 
      }
      EEPROM.write(timeHourEE, timeHour);
      timeMin = timeMin - 60;
    }
  }
}

 

 

Home