hello everyone
I am using a board called Robotdyn uno wifi .
i am using ESP8266 to read two json data from two diferent url and then m printing this on the Serial monitor.
i am able to read the json data and sent it on serial monitor successfully.
ESP8266 code
/**
* BasicHTTPClient.ino
*
* Created on: 24.05.2015
*
*/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
int i=0;
const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
DynamicJsonBuffer jsonBuffer(bufferSize);
void setup()
{
USE_SERIAL.begin(115200);
for(uint8_t t = 4; t > 0; t--)
{
delay(1000);
}
WiFi.begin("DIGISOL","edot2018");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
}
void loop()
{
HTTPClient http,http2;
http.begin("http://192.168.1.12/FlightStats/api/Flight/GetArrivingFlightsStatus/"); //HTTP
http2.begin("http://192.168.1.12/FlightStats/api/Flight/GetDepartingFlightsStatus/");
//start connection and send HTTP header
int httpCode = http.GET();
int httpCode2 = http2.GET();
// httpCode will be negative on error
if(httpCode == 200 )
{
// HTTP header has been send and Server response header has been handled
//USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
//USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode2);
String myString = http.getString();
String myString2 = http2.getString();
JsonObject& root = jsonBuffer.parseObject(myString);
const char* description = root["Description"];
JsonObject& root1 = jsonBuffer.parseObject(myString2);
const char* description2 = root1["Description"];
USE_SERIAL.println(description);
delay(500);
USE_SERIAL.println(description2);
}
else
{
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
delay(10000);
}
Then using atmega 832p i am reading this data sent by the ESP8266 through serial monitor and then displaying it on to the display.
the data is not receiving correctly from the serial monitor, some of the character from the String are missing or interchanged.
atmega code
#include "font8x8_basic.h"
#include "font8x8_extended.h"
#include "font8x16_basic.h"
#include <Time.h>
#include <Wire.h>
#define SERIAL Serial
#define COLUMNS 16
#define HEIGHT 16
String message4,message5;
int m2Size,m5Size,len = 0,cycled = 0;
int count = 0;
void setup()
{
SERIAL.begin(115200);
delay(1000);
sei();//allow interrupts
}
void loop()
{
if(SERIAL.available() > 0)
{
ATSTART();
draw();
}
else if (cycled == 1)
{
count=0;
draw();
}
else
{
ATSTART();
draw();
}
//cli();
delay(1000);
}
void ATSTART()
{
while(SERIAL.available() == 0){}
message4 = SERIAL.readString();
Serial.read();
m2Size = message4.length();
m2Size = m2Size - 2 ;
while(SERIAL.available() == 0){}
message5 = SERIAL.readString();
Serial.read();
m5Size = message5.length();
m5Size = m5Size - 2 ;
//Serial.println(m2Size);
//Serial.println(message4);
if(m2Size >= m5Size)
{
len = m2Size;
}
else
{
len = m5Size;
}
}
void draw()
{
drawChar(0,0,'A',0,false);
drawChar(8,0,'R',0,false);
drawChar(16,0,'R',0,false);
drawChar(0,9,'D',0,false);
drawChar(8,9,'E',0,false);
drawChar(16,9,'P',0,false);
while(count <= len)
{
if(count <= m2Size)
{
drawChar(120,1,message4[count],0,false);
}
if(count <= m5Size)
{
drawChar(120,8,message5[count],0,false);
}
count = count + 1;
for (byte i=0; i<8; i++)
{
delay(100);
moveLeft(1,0,15);
};
}
cycled = 1;
}
can anyone plz help me with this.
Since this board is new there is no proper explanation on how this stuff works.
i anyhow reached so far with my project using this board.