Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [AC] WiFi.config(IP=0.0.0.0, Gateway=0.0.0.0, Subnetmask=0.0.0.0,
- DNS1=0.0.0.0, DNS2=0.0.0.0) [AC] DHCP client(STARTED)
- [AC] WiFi.begin()
- [AC] Connecting........[AC] established IP:192.168.1.139
- [AC] http server started
- Wifi connected: 192.168.1.139
- Connected to endpoint
- Daily:13.37
- Monthly:1111
- 4
- 13.37
- 4
- 1111
- 4
- 13.37
- 4
- 1111
- 4
- 13.37
- 4
- 1111
- 4
- 13.37
- 4
- 1111
- 2
- h
- 0
- 2
- h
- 0
- 2
- h
- void fetchJSONandPutValues(){
- HTTPClient http; //Object of class HTTPClient
- http.begin(projectURL);
- int httpCode = http.GET();
- //Check the returning code
- if (httpCode > 0) {
- //Parsing
- const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(8) + 370;
- DynamicJsonBuffer jsonBuffer(bufferSize);
- JsonObject& root = jsonBuffer.parseObject(http.getString());
- // Parameters
- daily = root["daily"];
- monthly = root["monthly"];
- // Output to serial monitor
- Serial.print("Daily:");
- Serial.println(daily);
- Serial.print("Monthly:");
- Serial.println(monthly);
- finalDaily = (char *) daily;
- finalMonthly = (char *) monthly;
- }
- http.end(); //Close connection
- //setLCDValues(daily);
- }
- void setLCDValues(char * value){
- int charsInValue = strlen(value);
- boolean decimalPoint = false;
- int numLEDElements = charsInValue;
- char cleanedValue[8] ;
- //look for point position
- int positionPoint = 999;
- for (int i = 0; i < charsInValue; i++){
- if (value[i] == '.')
- {
- positionPoint = i;
- numLEDElements -= 1;
- break;
- }
- }
- int j = 0 ;
- for (int i = 0; i < charsInValue; i++){
- if (value[i] != '.')
- {
- cleanedValue[j] = value[i];
- j++;
- }
- }
- Serial.println(numLEDElements);
- for (int i = 0; i < numLEDElements; i++){
- if ( i == positionPoint -1 )
- {
- ledDisplay.setChar(0, numLEDElements -1 - i, cleanedValue[i], true);
- }
- else
- {
- ledDisplay.setChar(0, numLEDElements -1 - i, cleanedValue[i], false);
- }
- }
- }
- currentMillis = millis();
- if (currentMillis - previousMillis >= interval){
- previousMillis = currentMillis;
- if (showDaily)
- {
- setLCDValues(finalDaily);
- showDaily = false;
- Serial.println(daily);
- }
- else
- {
- setLCDValues(finalMonthly);
- showDaily = true;
- Serial.println(monthly);
- }
- }
Add Comment
Please, Sign In to add comment