Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MbedJSONValue HTTPClient TFT_fonts SPI_TFT_ILI9341 mbed-rtos picojsontest NTPClient SDFileSystem EthernetInterface DHT Stepper_Motor_X27168
Diff: main.cpp
- Revision:
- 4:1eea5edaffc4
- Parent:
- 1:f9a4cbb4af0d
--- a/main.cpp Mon Apr 29 01:03:45 2019 +0000
+++ b/main.cpp Wed May 01 04:11:18 2019 +0000
@@ -9,11 +9,18 @@
#include "SDFileSystem.h"
#include <MbedJSONValue.h>
#include <string>
+#include "StepperMotor_X27168.h"
//IMPORTANT YOU NEED TO SET THE API KEY for thingspeak look for "your key here"
//TAKE CARE URL doesn't excced buffer size
//sd card
// SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCLK, SSEL
//Ethernet Interface
+
+DigitalOut communicate(p30); ///Pull low until ready to go
+DigitalOut motor3(p23);
+StepperMotor_X27168 smotor3(p24,p25,p22,p21);
+
+
EthernetInterface eth;
//NTP service for date and Time used to set boards RTC
NTPClient ntp;
@@ -32,8 +39,28 @@
MbedJSONValue v;
+volatile char c = '\0'; // Initialized to the NULL character
+volatile int check = 0;
+Serial device(p28,p27); //9-10 11u; 28-27 1768
+void onCharReceived()
+{
+ c = device.getc();
+ check = 1;
+}
+
int main()
{
+ communicate = 0;
+ pc.printf("\r\nWeather Reporter\n");
+
+// while (1) {
+// wait(.1);
+// }
+// check = 0;
+
+// device.attach(&onCharReceived);
+
+
int ret=0;
@@ -56,9 +83,12 @@
mac = eth.getMACAddress();
pc.printf("MAC: %s\r\n", mac);
TCPSocketConnection sock;
+
sock.connect("api.openweathermap.org", 80);
+ wait(5);
char http_cmd[] = "GET /data/2.5/weather?q=Atlanta,US&APPID=a1c3afc7f18b7ef578cef48d5163cda6 HTTP/1.0\r\n\r\n";
if (!sock.is_connected()){
+ pc.printf("This not working");
return -1;
}
sock.send_all(http_cmd, sizeof(http_cmd)-1);
@@ -75,13 +105,14 @@
sock.close();
eth.disconnect();
+
float forecastHumidity=0;
// float temperature=-100;
float forcastTemp=0;
float forcastDescription = 0;
// float forcastPressure;
- wait(10);
+ wait(2);
pc.printf("\r\nDHT Test program");
pc.printf("\r\n******************\r\n");
wait(1); // wait 1 second for device stable status
@@ -147,14 +178,29 @@
std::time_t result = time(NULL);
// std::cout << std::asctime(std::localtime(&result))
- printf("\n\nCurrent Time: %s \r\n",ctime(&result));
- printf("Current Temperature: %s Kelvin \r\n",weather.temp);
- printf("Humidity is %s \r\n",weather.hum);
- printf("Weather Condition: %s \r\n", weather.desc);
+
+
+ // pc.printf("\n\nCurrent Time: %s \r\n",ctime(&result));
+ // pc.printf("Current Temperature: %s Kelvin \r\n",weather.temp);
+ // pc.printf("Humidity is %s \r\n",weather.hum);
+ // pc.printf("Weather Condition: %s \r\n", weather.desc);
+ //
+ double weather_temp = atof(weather.temp.c_str());
+ //double weather_temp = 301.483;
+ weather_temp = weather_temp - 273.15;
+ weather_temp = (weather_temp * 9/5) + 32;
+ // range is 60 - 85
+ weather_temp = weather_temp - 60;
+ weather_temp = weather_temp * 360/25;
+ wait(5);
+ motor3 = 1;
+ smotor3.step_position(weather_temp);
+ wait(1.5);
+ communicate = 1;
wait(60);
}
-}
-}
+
+}}