 
 void loop() {
   if (readyForWeatherUpdate && display.getFrameState() == display.FRAME_STATE_FIX) {
+    gettemperature();       // read sensor  
+
+    
     readyForWeatherUpdate = false;
-    weather.setUnits("si");
-    weather.updateWeatherData(forecastApiKey, latitude, longitude);  
+    weather.setUnits("us");
+    weather.updateWeatherData(forecastApiKey, latitude, longitude);
+
+    
   }
   display.clear();
   display.nextFrameTick();


void setReadyForWeatherUpdate() {
  readyForWeatherUpdate = true;  
}

void drawFrame1(int x, int y) {
   display.setFontScale2x2(false);
   display.drawString(65 + x, 8 + y, "Now");
   display.drawXbm(x+7,y+7, 50, 50, getIconFromString(weather.getCurrentIcon()));
   display.setFontScale2x2(true);
   display.drawString(64+ x, 20 + y, String(weather.getCurrentTemp()) + "C"); 
}

const char* getIconFromString(String icon) {


#include <Wire.h>
#include <Ticker.h>

#include "ssd1306_i2c.h"
#include "icons.h"
#include <ESP8266WiFi.h>
#include "WeatherClient.h"

#define DHTTYPE DHT22
#define DHTPIN  4

// Initialize DHT sensor 
// NOTE: For working with a faster than ATmega328p 16 MHz Arduino chip, like an ESP8266,
// you need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// This is for the ESP8266 processor on ESP-01 
DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266
float humidity, temp_f;  // Values read from sensor
unsigned long previousMillis = 0;        // will store last temp was read
const long interval = 2000;              // interval at which to read sensor

// Initialize the oled display for address 0x3c
// sda-pin=0 and sdc-pin=2
SSD1306 display(0x3c, 0, 2);
WeatherClient weather;
Ticker ticker;

// this array keeps function pointers to all frames
// frames are the single views that slide from right to left
void (*frameCallbacks[4])(int x, int y) = {drawFrame1, drawFrame2, drawFrame3, drawFrame4};

// how many frames are there?
int frameCount = 4;
// on frame is currently displayed
int currentFrame = 0;

// your network SSID (name)
char ssid[] = "AdyShan";
// your network password
char pass[] = "aditya1tannu2";  

// Go to forecast.io and register for an API KEY
String forecastApiKey = "51a65846eba22ea29bf003366702ef20";

// Coordinates of the place you want
// weather information for
double latitude = 34.4274;
double longitude = -118.5458;

// flag changed in the ticker function every 10 minutes
bool readyForWeatherUpdate = true;

void setup() {

  dht.begin();           // initialize temperature sensor

  
  // initialize dispaly
  display.init();
  // set the drawing functions
  display.setFrameCallbacks(4, frameCallbacks);
  // how many ticks does a slide of frame take?
  display.setFrameTransitionTicks(10);

