Hi guys , i have a big problem ,i am working on a project getting data from wunderground ,and displayin on a LCD screen,then operating neopixel rbg led link.So according tthe data on the screen my adafruit ring will change its color.
My problem :I can get data from wunderground and see on the serial monitor while operating esp8266.
But when i upload arduino code ,ESP8266 does not work and give no response.I can not see any data on the serial monitor else LCD ![]()
ESP-Code:
#include <ESP8266WiFi.h> //ESP8266 Library
#include <ESP8266HTTPClient.h> //ESP8266 Library
#include <ArduinoJson.h> //For phrasing JSON file download from GitHub - bblanchon/ArduinoJson: 📟 JSON library for Arduino and embedded C++. Simple and efficient.
const char* ssid = ""; //Enter your Wi-Fi SSID
const char password = "*******"; //Enter you Wi-Fi Password
String payload; //To store the JSON object as string
void setup () {
Serial.begin(9600); //initialise serial monitor to send data to Arduino
WiFi.begin(ssid, password); //connect to the network specified above
while (WiFi.status() != WL_CONNECTED) { //Wait till Wi-Fi is connected
delay(1000);
Serial.print("Connecting.."); //Print Connecting.. till connection is established
}
}
void loop() {
if (WiFi.status() == WL_CONNECTED) { //If Wi-Fi connected successfully
HTTPClient http; //start a HTTPClinet as http
//####DO NOT USE THE SAME API as below
http.begin("http://api.wunderground.com/api/b0d5d26a4589cad4/conditions/q/IN/Chennai.json"); //Enter your API
int httpCode = http.GET(); //pass a ge t request
if (httpCode > 0) { //Check the returning code
// payload = http.getString(); // Store the value on varibale Payload for debugging
// Serial.println(payload); //Print the payload for debugging otherwise comment both lines
/*Phrasing Data using the JSON librarey / //Use Redirecting… to get the phrasing values for your JSON string
const size_t bufferSize = JSON_OBJECT_SIZE(0) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(2) + 2JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(8) + JSON_OBJECT_SIZE(12) + JSON_OBJECT_SIZE(56) + 2180;
DynamicJsonBuffer jsonBuffer(bufferSize);
JsonObject& root = jsonBuffer.parseObject(http.getString());
/End of Phrasing Data/
//Address the value sin to desired variables
JsonObject& current_observation = root["current_observation"]; //under current_observation
JsonObject& current_observation_observation_location = current_observation["observation_location"]; //under observation_location
const char* current_observation_station_id = current_observation["station_id"]; // "ICHENNAI1" //get the location detials
const char* current_observation_local_time_rfc822 = current_observation["local_time_rfc822"]; //Local time //get the local time
const char* current_observation_temperature_string = current_observation["temperature_string"]; // "90.7 F (32.6 C)" //get the temperature value
const char* current_observation_relative_humidity = current_observation["relative_humidity"]; // "73%" //get the humidity value
//Print the variables thorugh serial monitor
Serial.print (current_observation_station_id); //send the location details to Arduino
delay(100); //stability delay
Serial.print (current_observation_local_time_rfc822); //send the local time details to Arduino
delay(100); //stability delay
Serial.print (current_observation_temperature_string); //send the temperature details to Arduino
delay(100); //stability delay
Serial.print (current_observation_relative_humidity); //send the humidity details to Arduino
delay(100); //stability delay
}
http.end(); //Close http connection
}
delay(10000); //send values to Arduino every 30 sec.
}
ARDUINO UNO Code:
#include <SoftwareSerial.h>
#include <LiquidCrystal.h> //Header file for LCD from LiquidCrystal - Arduino Reference
//const int rs = 8, en = 9, d4 = 10, d5 = 11, d6 = 12, d7 = 13; //Pins to which LCD is connected
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String local_time;
String local_date;
String temperature;
String Humidity;
String payload;
SoftwareSerial ESP_Serial(1,0); //Tx,Rx
void setup() {
lcd.begin(16, 2); //We are using a 16*2 LCD display
lcd.print(" Arduino & ESP"); //Display a intro message
Serial.begin(115200);
ESP_Serial.begin(9600);
delay(2000);
lcd.clear();
}
void loop() {
while (ESP_Serial.available() > 0)
{
payload = ESP_Serial.readString();
local_date = payload.substring(14, 20);
local_time = payload.substring(26, 31);
temperature = payload.substring(48, 54);
Humidity = payload.substring(55, 60);
delay(10);
Serial.println(payload);
Serial.println(local_time);
Serial.println(local_date);
Serial.println(temperature);
Serial.println(Humidity);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(local_date);
lcd.setCursor(8, 0);
lcd.print(local_time);
lcd.setCursor(1, 1);
lcd.print(temperature);
lcd.setCursor(10, 1);
lcd.print(Humidity);
}
}