From d1217e142263b0751d3597a3088fb8f723ad4017 Mon Sep 17 00:00:00 2001 From: zombodotcom Date: Thu, 19 Apr 2018 09:21:51 -0600 Subject: [PATCH 1/4] Add files via upload --- ZomboISS-ESP32/ZomboISS-ESP32.ino | 244 ++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 ZomboISS-ESP32/ZomboISS-ESP32.ino diff --git a/ZomboISS-ESP32/ZomboISS-ESP32.ino b/ZomboISS-ESP32/ZomboISS-ESP32.ino new file mode 100644 index 0000000..7fe5a3a --- /dev/null +++ b/ZomboISS-ESP32/ZomboISS-ESP32.ino @@ -0,0 +1,244 @@ +/* Copyright (c) 2018 LeRoy Miller + * + * This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program. If not, see + */ + +#include +#include +#include //https://github.com/bblanchon/ArduinoJson +#include "SSD1306.h" //https://github.com/squix78/esp8266-oled-ssd1306 +#include +#include +#include + +#include + + +//#define Serial Serial + +WiFiMulti wifiMulti; +//Find your Latitude and Longitude here +//https://www.latlong.net/ +float mylat = 39.50;//middle of america +float mylon = -98.35;//middle of america +float isslat, isslon; +int distance, number, count; +String payload; +String name[10], craft[10],risetime[5]; +float duration[5]; + +const String iss = "http://api.open-notify.org/iss-now.json"; +const String ppl = "http://api.open-notify.org/astros.json"; +String pas = "http://api.open-notify.org/iss-pass.json?"; + +SSD1306 display(0x3c, 5, 4); + +void setup() { + Serial.begin(115200); + for(uint8_t t = 4; t > 0; t--) { + Serial.printf("[SETUP] WAIT %d...\n", t); + Serial.flush(); + delay(1000); + } + + wifiMulti.addAP("SSID", "PASSWORD"); +// WiFiManager wifiManager; + display.init(); + + display.flipScreenVertically(); + display.setFont(ArialMT_Plain_10); +// WiFiManager wifiManager; +// wifiManager.autoConnect("AutoConnectAP"); + pas = pas + "lat=" + (String)mylat+"&lon="+ (String)mylon; + Serial.println(pas); +} + +void loop() { + + getJson(iss); + //Serial.println(payload); //Print the response payload + decodeLocJson(); + getDistance(); + issLocOLEDDisplay(); + issLocSerialDisplay(); + delay(5000); + + + getJson(pas); + decodePassJson(); + displayPassSerial(); + displayPassOLED(); + delay(5000); + + getJson(ppl); + decodePeopleJson(); + displayPeopleSerial(); + displayPeopleOLED(); + delay(5000); //Send a request every 30 seconds + +} +void issLocOLEDDisplay() { + display.clear(); + display.drawString(0,0,"The ISS is currently at: "); + char temp[15]; + sprintf(temp, "%d.%02d,%d.%02d",(int)isslat,abs((int)(isslat*100)%100),(int)isslon,abs((int)(isslon*100)%100)); + display.drawString(25,15,temp); + char temp1[30]; + sprintf(temp1, "ISS is about %d miles", distance); + display.drawString(0,27,temp1); + display.drawString(30,38, "from you."); + display.drawString(12,51, "And moving fast!!"); + display.display(); +} + +void issLocSerialDisplay() { + Serial.print("The ISS is currently at "); + Serial.print(isslat, 4); Serial.print(","); Serial.println(isslon,4); + Serial.print("The ISS is about "); Serial.print(distance); Serial.println(" miles from you now.\nAnd moving fast!"); + +} + +void getJson(String url) { + + if (wifiMulti.run() == WL_CONNECTED) { //Check WiFi connection status + HTTPClient http; //Declare an object of class HTTPClient + http.begin(url); //Specify request destination + int httpCode = http.GET(); //Send the request + if (httpCode > 0) { //Check the returning code + payload = http.getString(); //Get the request response payload + + } + + http.end(); //Close connection + + } + + +} + +void decodeLocJson() { + StaticJsonBuffer<512> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(payload); + if (!root.success()) { + Serial.println("parseObject() failed"); + return; + } + isslat=root["iss_position"]["latitude"]; + isslon=root["iss_position"]["longitude"]; +} + +void getDistance() { + float theta, dist, miles; + theta = mylon - isslon; + dist = sin(deg2rad(mylat)) * sin(deg2rad(isslat)) + cos(deg2rad(mylat)) * cos(deg2rad(isslat)) * cos(deg2rad(theta)); + dist = acos(dist); + dist = rad2deg(dist); + miles = dist * 60 * 1.1515; + distance = miles; +} + +float deg2rad(float n) { + float radian = (n * 71)/4068; + return radian; +} + +float rad2deg(float n) { + float degree = (n*4068)/71; + return degree; +} + +void decodePeopleJson() { + DynamicJsonBuffer jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(payload); + if (!root.success()) { + Serial.println("parseObject() failed"); + return; + } + number = root["number"]; + if (number > 10) {number = 10;} + for (int i=0;i 5) {number = 5;} //Display the 1st 5 Astros on OLED + for (int i=0;i 5) {count = 5;} + for (int i=0;i Date: Thu, 19 Apr 2018 10:30:16 -0600 Subject: [PATCH 2/4] Update ZomboISS-ESP32.ino --- ZomboISS-ESP32/ZomboISS-ESP32.ino | 486 +++++++++++++++--------------- 1 file changed, 243 insertions(+), 243 deletions(-) diff --git a/ZomboISS-ESP32/ZomboISS-ESP32.ino b/ZomboISS-ESP32/ZomboISS-ESP32.ino index 7fe5a3a..f6de862 100644 --- a/ZomboISS-ESP32/ZomboISS-ESP32.ino +++ b/ZomboISS-ESP32/ZomboISS-ESP32.ino @@ -1,244 +1,244 @@ -/* Copyright (c) 2018 LeRoy Miller - * - * This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see - */ - -#include -#include -#include //https://github.com/bblanchon/ArduinoJson -#include "SSD1306.h" //https://github.com/squix78/esp8266-oled-ssd1306 -#include -#include -#include - -#include - - -//#define Serial Serial - -WiFiMulti wifiMulti; -//Find your Latitude and Longitude here -//https://www.latlong.net/ -float mylat = 39.50;//middle of america -float mylon = -98.35;//middle of america -float isslat, isslon; -int distance, number, count; -String payload; -String name[10], craft[10],risetime[5]; -float duration[5]; - -const String iss = "http://api.open-notify.org/iss-now.json"; -const String ppl = "http://api.open-notify.org/astros.json"; -String pas = "http://api.open-notify.org/iss-pass.json?"; - -SSD1306 display(0x3c, 5, 4); - -void setup() { - Serial.begin(115200); - for(uint8_t t = 4; t > 0; t--) { - Serial.printf("[SETUP] WAIT %d...\n", t); - Serial.flush(); - delay(1000); - } - - wifiMulti.addAP("SSID", "PASSWORD"); -// WiFiManager wifiManager; - display.init(); - - display.flipScreenVertically(); - display.setFont(ArialMT_Plain_10); -// WiFiManager wifiManager; -// wifiManager.autoConnect("AutoConnectAP"); - pas = pas + "lat=" + (String)mylat+"&lon="+ (String)mylon; - Serial.println(pas); -} - -void loop() { - - getJson(iss); - //Serial.println(payload); //Print the response payload - decodeLocJson(); - getDistance(); - issLocOLEDDisplay(); - issLocSerialDisplay(); - delay(5000); - - - getJson(pas); - decodePassJson(); - displayPassSerial(); - displayPassOLED(); - delay(5000); - - getJson(ppl); - decodePeopleJson(); - displayPeopleSerial(); - displayPeopleOLED(); - delay(5000); //Send a request every 30 seconds - -} -void issLocOLEDDisplay() { - display.clear(); - display.drawString(0,0,"The ISS is currently at: "); - char temp[15]; - sprintf(temp, "%d.%02d,%d.%02d",(int)isslat,abs((int)(isslat*100)%100),(int)isslon,abs((int)(isslon*100)%100)); - display.drawString(25,15,temp); - char temp1[30]; - sprintf(temp1, "ISS is about %d miles", distance); - display.drawString(0,27,temp1); - display.drawString(30,38, "from you."); - display.drawString(12,51, "And moving fast!!"); - display.display(); -} - -void issLocSerialDisplay() { - Serial.print("The ISS is currently at "); - Serial.print(isslat, 4); Serial.print(","); Serial.println(isslon,4); - Serial.print("The ISS is about "); Serial.print(distance); Serial.println(" miles from you now.\nAnd moving fast!"); - -} - -void getJson(String url) { - - if (wifiMulti.run() == WL_CONNECTED) { //Check WiFi connection status - HTTPClient http; //Declare an object of class HTTPClient - http.begin(url); //Specify request destination - int httpCode = http.GET(); //Send the request - if (httpCode > 0) { //Check the returning code - payload = http.getString(); //Get the request response payload - - } - - http.end(); //Close connection - - } - - -} - -void decodeLocJson() { - StaticJsonBuffer<512> jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(payload); - if (!root.success()) { - Serial.println("parseObject() failed"); - return; - } - isslat=root["iss_position"]["latitude"]; - isslon=root["iss_position"]["longitude"]; -} - -void getDistance() { - float theta, dist, miles; - theta = mylon - isslon; - dist = sin(deg2rad(mylat)) * sin(deg2rad(isslat)) + cos(deg2rad(mylat)) * cos(deg2rad(isslat)) * cos(deg2rad(theta)); - dist = acos(dist); - dist = rad2deg(dist); - miles = dist * 60 * 1.1515; - distance = miles; -} - -float deg2rad(float n) { - float radian = (n * 71)/4068; - return radian; -} - -float rad2deg(float n) { - float degree = (n*4068)/71; - return degree; -} - -void decodePeopleJson() { - DynamicJsonBuffer jsonBuffer; - JsonObject& root = jsonBuffer.parseObject(payload); - if (!root.success()) { - Serial.println("parseObject() failed"); - return; - } - number = root["number"]; - if (number > 10) {number = 10;} - for (int i=0;i 5) {number = 5;} //Display the 1st 5 Astros on OLED - for (int i=0;i 5) {count = 5;} - for (int i=0;i + */ + +#include +#include +#include //https://github.com/bblanchon/ArduinoJson +#include "SSD1306.h" //https://github.com/squix78/esp8266-oled-ssd1306 +#include +#include +#include + +#include + + +//#define Serial Serial + +WiFiMulti wifiMulti; +//Find your Latitude and Longitude here +//https://www.latlong.net/ +float mylat = 40.573922; +float mylon = -105.083303; +float isslat, isslon; +int distance, number, count; +String payload; +String name[10], craft[10],risetime[5]; +float duration[5]; + +const String iss = "http://api.open-notify.org/iss-now.json"; +const String ppl = "http://api.open-notify.org/astros.json"; +String pas = "http://api.open-notify.org/iss-pass.json?"; + +SSD1306 display(0x3c, 5, 4); + +void setup() { + Serial.begin(115200); + for(uint8_t t = 4; t > 0; t--) { + Serial.printf("[SETUP] WAIT %d...\n", t); + Serial.flush(); + delay(1000); + } + + wifiMulti.addAP("Zombo", "thepromisedlan"); +// WiFiManager wifiManager; + display.init(); + + display.flipScreenVertically(); + display.setFont(ArialMT_Plain_10); +// WiFiManager wifiManager; +// wifiManager.autoConnect("AutoConnectAP"); + pas = pas + "lat=" + (String)mylat+"&lon="+ (String)mylon; + Serial.println(pas); +} + +void loop() { + + getJson(iss); + //Serial.println(payload); //Print the response payload + decodeLocJson(); + getDistance(); + issLocOLEDDisplay(); + issLocSerialDisplay(); + delay(5000); + + + getJson(pas); + decodePassJson(); + displayPassSerial(); + displayPassOLED(); + delay(5000); + + getJson(ppl); + decodePeopleJson(); + displayPeopleSerial(); + displayPeopleOLED(); + delay(5000); //Send a request every 30 seconds + +} +void issLocOLEDDisplay() { + display.clear(); + display.drawString(0,0,"The ISS is currently at: "); + char temp[15]; + sprintf(temp, "%d.%02d,%d.%02d",(int)isslat,abs((int)(isslat*100)%100),(int)isslon,abs((int)(isslon*100)%100)); + display.drawString(25,15,temp); + char temp1[30]; + sprintf(temp1, "ISS is about %d miles", distance); + display.drawString(0,27,temp1); + display.drawString(30,38, "from you."); + display.drawString(12,51, "And moving fast!!"); + display.display(); +} + +void issLocSerialDisplay() { + Serial.print("The ISS is currently at "); + Serial.print(isslat, 4); Serial.print(","); Serial.println(isslon,4); + Serial.print("The ISS is about "); Serial.print(distance); Serial.println(" miles from you now.\nAnd moving fast!"); + +} + +void getJson(String url) { + + if (wifiMulti.run() == WL_CONNECTED) { //Check WiFi connection status + HTTPClient http; //Declare an object of class HTTPClient + http.begin(url); //Specify request destination + int httpCode = http.GET(); //Send the request + if (httpCode > 0) { //Check the returning code + payload = http.getString(); //Get the request response payload + + } + + http.end(); //Close connection + + } + + +} + +void decodeLocJson() { + StaticJsonBuffer<512> jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(payload); + if (!root.success()) { + Serial.println("parseObject() failed"); + return; + } + isslat=root["iss_position"]["latitude"]; + isslon=root["iss_position"]["longitude"]; +} + +void getDistance() { + float theta, dist, miles; + theta = mylon - isslon; + dist = sin(deg2rad(mylat)) * sin(deg2rad(isslat)) + cos(deg2rad(mylat)) * cos(deg2rad(isslat)) * cos(deg2rad(theta)); + dist = acos(dist); + dist = rad2deg(dist); + miles = dist * 60 * 1.1515; + distance = miles; +} + +float deg2rad(float n) { + float radian = (n * 71)/4068; + return radian; +} + +float rad2deg(float n) { + float degree = (n*4068)/71; + return degree; +} + +void decodePeopleJson() { + DynamicJsonBuffer jsonBuffer; + JsonObject& root = jsonBuffer.parseObject(payload); + if (!root.success()) { + Serial.println("parseObject() failed"); + return; + } + number = root["number"]; + if (number > 10) {number = 10;} + for (int i=0;i 5) {number = 5;} //Display the 1st 5 Astros on OLED + for (int i=0;i 5) {count = 5;} + for (int i=0;i Date: Thu, 19 Apr 2018 10:30:51 -0600 Subject: [PATCH 3/4] Update ZomboISS-ESP32.ino --- ZomboISS-ESP32/ZomboISS-ESP32.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZomboISS-ESP32/ZomboISS-ESP32.ino b/ZomboISS-ESP32/ZomboISS-ESP32.ino index f6de862..1deb709 100644 --- a/ZomboISS-ESP32/ZomboISS-ESP32.ino +++ b/ZomboISS-ESP32/ZomboISS-ESP32.ino @@ -50,7 +50,7 @@ void setup() { delay(1000); } - wifiMulti.addAP("Zombo", "thepromisedlan"); + wifiMulti.addAP("SSID", "Password"); // WiFiManager wifiManager; display.init(); From 2960ff5225d94012244d16402a07d68da024c674 Mon Sep 17 00:00:00 2001 From: zombodotcom Date: Thu, 19 Apr 2018 10:33:18 -0600 Subject: [PATCH 4/4] Update ZomboISS-ESP32.ino --- ZomboISS-ESP32/ZomboISS-ESP32.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZomboISS-ESP32/ZomboISS-ESP32.ino b/ZomboISS-ESP32/ZomboISS-ESP32.ino index 1deb709..7030624 100644 --- a/ZomboISS-ESP32/ZomboISS-ESP32.ino +++ b/ZomboISS-ESP32/ZomboISS-ESP32.ino @@ -50,7 +50,7 @@ void setup() { delay(1000); } - wifiMulti.addAP("SSID", "Password"); + wifiMulti.addAP("SSID", "PASS"); // WiFiManager wifiManager; display.init();