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: SHTx SNTPClient WIZnetInterface mbed
Revision 0:73a312631ec9, committed 2015-08-26
- Comitter:
- nanjsk
- Date:
- Wed Aug 26 23:21:42 2015 +0000
- Commit message:
- This code is an example of the SHT-15 & SNTP using WIZwiki-W7500.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SHTx.lib Wed Aug 26 23:21:42 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/NegativeBlack/code/SHTx/#8465801be23f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SNTPClient.lib Wed Aug 26 23:21:42 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/xeon011/code/SNTPClient/#137fc24033c4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZnetInterface.lib Wed Aug 26 23:21:42 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#3b64df29662f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Aug 26 23:21:42 2015 +0000
@@ -0,0 +1,81 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "SNTPClient.h"
+#include "SHTx/sht15.hpp"
+
+uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x11, 0x22, 0xab};
+
+Serial pc(USBTX,USBRX);
+EthernetInterface eth;
+datetime ntptime;
+DigitalOut busy(LED1);
+SHTx::SHT15 sensor(D2, D3);
+
+struct tm timeinfo;
+
+int main()
+{
+ pc.baud(115200);
+ wait(0.5f);
+ pc.printf("Hello WIZwiki-W7500!\n\r");
+ pc.printf("===========================================\n\r");
+
+
+ eth.init(mac_addr); //Use DHCP
+ printf("Check Ethernet Link\r\n");
+ while(1) //Wait link up
+ {
+ if(eth.link() == true)
+ break;
+ }
+
+ printf("Link up\r\n");
+ printf("Getting IP address by DHCP...\r\n");
+ eth.connect();
+ printf("Server IP Address is %s\r\n", eth.getIPAddress());
+
+ printf("Getting time information by using NTP...\r\n");
+
+ SNTPClient sntp("time.nist.gov", 40); // timezone: Korea, Republic of
+ sntp.connect();
+ if(sntp.getTime(&ntptime) == true)
+ {
+ printf("%d-%d-%d, %02d:%02d:%02d\r\n", ntptime.yy, ntptime.mo, ntptime.dd, ntptime.hh, ntptime.mm, ntptime.ss);
+ printf("Completed Get and Set Time\r\n\r\n");
+ }
+ else
+ {
+ while(sntp.getTime(&ntptime) == true)
+ {
+ break;
+ }
+ }
+
+ sensor.setOTPReload(false);
+ sensor.setResolution(true);
+ while(1)
+ {
+ busy = true;
+ sensor.update();
+ busy = false;
+
+ sntp.getTime(&ntptime);
+ printf("< The current time : %d-%d-%d, %02d:%02d:%02d >\r\n", ntptime.yy, ntptime.mo, ntptime.dd, ntptime.hh, ntptime.mm, ntptime.ss);
+
+ // Temperature in celcius
+ sensor.setScale(false);
+ pc.printf("Temperature [ %3.2f C ]\r\n", sensor.getTemperature());
+
+ // Temperature in fahrenheit
+ sensor.setScale(true);
+ pc.printf(" [ %3.2f F ]\r\n", sensor.getTemperature());
+
+ // Relative Humidity
+ pc.printf("Humdity [ %3.2f %% ]\r\n", sensor.getHumidity());
+
+ pc.printf("===========================================\n\r");
+ wait(5);
+
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 26 23:21:42 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file