project

Dependencies:   mbed HTTPClient LM75B mbed-rtos EthernetInterface MMA7660

Revision:
4:88613477855a
Parent:
3:e68b56ffa127
diff -r e68b56ffa127 -r 88613477855a main.cpp
--- a/main.cpp	Thu Dec 30 15:22:40 2021 +0000
+++ b/main.cpp	Tue Jan 04 00:28:08 2022 +0000
@@ -234,13 +234,13 @@
 {
     int ret = 0;
     char field[50];
-   _station station(TRIGGER_HAND, ECHO_HAND, TRIGGER_BOTTLE, ECHO_BOTTLE, PUMP_SIGNAL);
-    station.start_station();
+   _station station(TRIGGER_HAND, ECHO_HAND, TRIGGER_BOTTLE, ECHO_BOTTLE, PUMP_SIGNAL);//initialize the station with sensor pins
+    station.start_station();//start the station
     
-    eth.init(); //Use DHCP
-    ret= eth.connect();
+    eth.init(); //initialize ethernet port
+    ret= eth.connect();//connect the ethernet
 
-    if (!ret){
+    if (!ret){//check if ethernet connected successfully or not
             pc.printf("\r\nConnected, IP: %s, MASK: %s, GW: %s",
             eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
     } else {
@@ -252,7 +252,7 @@
         pc.printf("Hand Distance = %d\n\r", hand_distance);//print the hand distance calculated
         pc.printf("Sanitizer = %d\n\r", santizer_lev);//print the sanitizer level detected
         wait(5);
-        post_field1();//callin the post feild1 to post the information to thingspaek
+        post_field1();//calling the post feild1 to post the information to thingspaek
         
     }
 }
@@ -260,65 +260,3 @@
 
 
 
-/*
-#include "mbed.h"
-#include "HTTPClient.h"
-#include "LM75B.h"
-#include "MMA7660.h"
-#include "EthernetInterface.h"
-
-
-LM75B sensor(D14,D15);
-MMA7660 accel(PTE25 , PTE24);
-char buffer[256];
-char resp[1024];
-char val[4][16];   
-int ret = 0;
-
-Serial pc(USBTX,USBRX);
-//Ethernet Interface
-EthernetInterface eth;
-//HTTP Client for interfacing to web services
-HTTPClient http;
-#define IP "184.106.153.149" // thingspeak.com IP Address
-
-//http client init
-HTTPMap map;
-HTTPText inText(resp, 1024);
-//String thingtweetAPIKey = "TTEVLP931ODJ5GMT";
-
-
-int main () {   
-//ethernet init
-    eth.init(); //Use DHCP
-    ret= eth.connect();
-
-    if (!ret){
-            pc.printf("\r\nConnected, IP: %s, MASK: %s, GW: %s",
-            eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
-    } else {
-        pc.printf("\r\nError eth.connect() - ret = %d", ret);
-    }
-    
-    while(1){
-        pc.printf("\r\nWriting to thingspeak");
-        map.put("api_key","xxx");  /* Fill your thingspeak API KEY*/
-/*
-        sprintf(val[0],"%4.1f",sensor.read());
-        map.put("field1", val[0]);
-        map.put("field1", val[0]);
-        map.put("field1", val[0]);
-        
-        
-        
-        pc.printf("\r\nPosting Data...");
-        ret = http.post("https://api.thingspeak.com/update", map, &inText);     //writing data to Thingspeak
-        if (!ret){
-            pc.printf("\r\nPOST successfully - read %d characters", strlen(resp));
-            pc.printf("\r\nResult: %s\n", resp);
-        }else{
-            pc.printf("\r\nError Connecting to ethernet port - ret = %d - HTTP return code = %d", ret, http.getHTTPResponseCode());
-        }
-    }
-}
-*/
\ No newline at end of file