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: NTPclient Firebase-https
Revision 1:7f0e80fcb3a0, committed 2020-03-08
- Comitter:
- star297
- Date:
- Sun Mar 08 14:45:02 2020 +0000
- Parent:
- 0:76248fdccc2a
- Commit message:
- Added NTP set RTC function.
Changed in this revision
--- a/Firebase-https.lib Thu Jan 23 22:33:09 2020 +0000 +++ b/Firebase-https.lib Sun Mar 08 14:45:02 2020 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/star297/code/Firebase-https/#768ae9838086 +https://os.mbed.com/users/star297/code/Firebase-https/#4f2c1fcc6fb6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPclient.lib Sun Mar 08 14:45:02 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/star297/code/NTPclient/#3854dc7bd4de
--- a/main.cpp Thu Jan 23 22:33:09 2020 +0000
+++ b/main.cpp Sun Mar 08 14:45:02 2020 +0000
@@ -1,10 +1,11 @@
#include "mbed.h"
#include "Firebase.h"
#include "trng_api.h"
+#include "NTPclient.h"
DigitalOut led1(LED1,0);
-DigitalOut led2(LED2,0);
-DigitalOut led3(LED3,0);
+DigitalOut led2(LED1,0);
+DigitalOut led3(LED1,0);
char dataPUT[200]; // PUT data container
char dataPOST[200]; // POST data container
@@ -16,18 +17,23 @@
int main()
{
- ThisThread::sleep_for(1000); // allow time to reset
+ ThisThread::sleep_for(100); // allow time to reset
printf("\033[0m\033[2J\033[H\n ----- Firebase Example -----\r\n\n\n");
printf("Initialise!\r\n\n");
-
- // Need to set the date/time here first eg, SNTP server
-
+
// connect to the default connection access point
- network = connect_to_default_network_interface();
- if (!network) {
- printf("Cannot connect to the network, see serial output\n");
- return 1;
- }
+ net = connect_to_default_network_interface();
+
+ // get NTP time and set RTC
+ NTPclient ntp(*net);
+ printf("\nConnecting to NTP server..\n");
+ // NTP server address, timezone offset in seconds +/-, enable DST, set RTC
+ if(ntp.getNTP("0.pool.ntp.org",0,1,1)){
+ time_t seconds = time(NULL);
+ printf("System time set by NTP: %s\n\n", ctime(&seconds));
+ }
+ else{printf("No NTP could not set RTC !!\n\n");
+ }
printf("\nConnecting TLS re-use socket...!\n\n");
TLSSocket* socket = new TLSSocket();
@@ -47,7 +53,7 @@
if(RTCsecond%10==0){PUTdata=1;} // PUT 10 second counter
if(RTCsecond==0){GETdata=1;} // GET minute counter
- if(RTCminute==0 && RTCsecond==0){POSTdata=1;} // POST hour counter
+ if(RTCminute==0 && RTCsecond==0){POSTdata=1;} // POST hour counter
if(PUTdata){ // PUT data to Firebase, initialise a data block the updates it on subsiquent PUT's
led3=1;
@@ -74,7 +80,7 @@
if(GETdata){ // retrieve data from Firebase
led2=1;
strcpy(FirebaseUrl, FirebaseID); // Firebase account ID
- strcat(FirebaseUrl, "/Test/Current/.json?auth="); // bit in the middle to send .json data and authority
+ strcat(FirebaseUrl, "/Mill/Current/.json?auth="); // bit in the middle to send .json data and authority
strcat(FirebaseUrl, FirebaseAuth); // Firebase account authorisation key
printf("\nGET current... time: %s\n",timebuff);
printf("%s \n\n",getFirebase((char*)FirebaseUrl));
@@ -88,13 +94,13 @@
{
// dummy sensor values, change these if you add real sensors eg, BME280, DS1820 etc.
// STM32F7 trng
- RCC->AHB2ENR |= RCC_AHB2ENR_RNGEN; // Enable RNG clock source
- RNG->CR |= RNG_CR_RNGEN; // RNG Peripheral enable
- while (!(RNG->SR & (RNG_SR_DRDY))); // Wait until one RNG number is ready
- int num = RNG->DR;
- num = abs(num%100);
+ //RCC->AHB2ENR |= RCC_AHB2ENR_RNGEN; // Enable RNG clock source
+ //RNG->CR |= RNG_CR_RNGEN; // RNG Peripheral enable
+ //while (!(RNG->SR & (RNG_SR_DRDY))); // Wait until one RNG number is ready
+ //int num = RNG->DR;
+ //num = abs(num%100);
- //int num = abs(rand()%100);
+ int num = abs(rand()%100);
//printf("RNG: %d\n",num);
char Temp[5][7] = {"23.80","72.50","65.00","45.30","30.60"};
--- a/mbed-os.lib Thu Jan 23 22:33:09 2020 +0000 +++ b/mbed-os.lib Sun Mar 08 14:45:02 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#430e64fce8098fd5e54f6de32f3f029f35dc705f +https://github.com/ARMmbed/mbed-os/#c12b433026beae5b3b769c27941bc6d7fe5d4b27
--- a/mbed_app.json Thu Jan 23 22:33:09 2020 +0000
+++ b/mbed_app.json Sun Mar 08 14:45:02 2020 +0000
@@ -16,19 +16,26 @@
"*": {
"platform.stdio-baud-rate": 921600,
"platform.stdio-convert-newlines": true,
- "mbed-trace.enable": null,
+ "mbed-trace.enable": true,
"mbed-http.http-buffer-size": 2048,
"nsapi.default-wifi-security": "WPA_WPA2",
- "nsapi.default-wifi-ssid": "\"SSID\"",
- "nsapi.default-wifi-password": "\"PASSWORD\""
+ "nsapi.default-wifi-ssid": "\"Molino Metz\"",
+ "nsapi.default-wifi-password": "\"36693557\""
},
- "NUCLEO_F401RE": {
+ "NUCLEO_L476RG": {
"target.network-default-interface-type" : "WIFI",
"esp8266.serial-baudrate" : 460800,
"esp8266.tx" : "D8",
"esp8266.rx" : "D2",
"esp8266.provide-default" : true
},
+ "DISCO_L476VG": {
+ "target.network-default-interface-type" : "WIFI",
+ "esp8266.serial-baudrate" : 230400,
+ "esp8266.tx" : "PB_6",
+ "esp8266.rx" : "PB_7",
+ "esp8266.provide-default" : true
+ },
"NUCLEO_F446ZE": {
"target.network-default-interface-type" : "WIFI",
"esp8266.serial-baudrate" : 460800,
@@ -37,18 +44,32 @@
"esp8266.provide-default" : true
},
"NUCLEO_F767ZI": {
- "target.network-default-interface-type" : "WIFI",
+ "target.network-default-interface-type" : "ETHERNET",
+ "esp8266.serial-baudrate" : 460800,
+ "esp8266.tx" : "D1",
+ "esp8266.rx" : "D0",
+ "esp8266.provide-default" : true
+ },
+ "NUCLEO_H743Z12": {
+ "target.network-default-interface-type" : "ETHERNET",
"esp8266.serial-baudrate" : 460800,
"esp8266.tx" : "D1",
"esp8266.rx" : "D0",
"esp8266.provide-default" : true
},
"DISCO_F746NG": {
- "target.network-default-interface-type" : "WIFI",
+ "target.network-default-interface-type" : "ETHERNET",
"esp8266.serial-baudrate" : 460800,
"esp8266.tx" : "D1",
"esp8266.rx" : "D0",
"esp8266.provide-default" : true
+ },
+ "DISCO_F469NI": {
+ "target.network-default-interface-type" : "WIFI",
+ "esp8266.serial-baudrate" : 230400,
+ "esp8266.tx" : "PC_6",
+ "esp8266.rx" : "PC_7",
+ "esp8266.provide-default" : true
}
}
}