
Coordinator_1
Dependencies: ESP8266 mbed nRF24L01P
Revision 1:7f3a0c145a08, committed 2016-07-07
- Comitter:
- monish
- Date:
- Thu Jul 07 06:53:25 2016 +0000
- Parent:
- 0:e246677dfb3b
- Commit message:
- Updated to phant
Changed in this revision
Receiver.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e246677dfb3b -r 7f3a0c145a08 Receiver.cpp --- a/Receiver.cpp Wed Jul 06 06:26:16 2016 +0000 +++ b/Receiver.cpp Thu Jul 07 06:53:25 2016 +0000 @@ -1,48 +1,48 @@ /*****Multiceiver wireless network with IoT*****/ - + #include "mbed.h" #include "nRF24L01P.h" #include "ESP8266.h" - + //Serial Transmission Serial pc(USBTX, USBRX); // tx, rx - + //wifi UART port and baud rate ESP8266 wifi(PTE0, PTE1, 115200); - + //nRF module nRF24L01P my_nrf24l01p(PTD2, PTD3, PTD1, PTD0, PTD5, PTD4); // mosi, miso, sck, csn, ce, irq - + //blue for pipe1 and green for pipe0 DigitalOut GreenLED(LED2); DigitalOut RedLED(LED1); - + //buffers for wifi library char snd[255],resp[1000]; char http_cmd[300], comm[300]; -int timeout = 3000; //timeout for wifi commands - +int timeout = 6000; //timeout for wifi commands + char count[1]; char RxDataCnt_PIPE0, RxDataCnt_PIPE1; char temp; - + //potvalue and ldrvalue char pot_val, ldr_val; float potval, ldrval; float opv=0; float olv=0; - + //Public and private keys for phant -char* Public_Key = "3I4DFZQSYETVGFM9"; -char* Private_Key = "3CVTRI3P2PMCQI6M"; +char* Public_Key = "wrZ1PpONOpCk1QPM03wki1yDdZXb"; +char* Private_Key = "OzYl9EOZOEcvPZ3Wbxjvs3A7OpXM"; //SSID and password for connection -#define SSID "RIFT" -#define PASS "rift2015" +#define SSID "Eduvance_WiFi" +#define PASS "eduvance" //Remote IP -#define IP "184.106.153.149" //184.106.153.149-ThingsSpeak IP - +#define IP "192.168.0.2" //184.106.153.149-ThingsSpeak IP + //Wifi init function void wifi_initialize(void){ @@ -93,11 +93,11 @@ pc.printf("No response while setting single connection \r\n"); wait(1); } - + void wifi_send(void){ pc.printf("******** Starting TCP connection on IP and port ********\r\n"); - wifi.startTCPConn(IP, 80); //cipstart + wifi.startTCPConn(IP, 8080); //cipstart wifi.RcvReply(resp, timeout); if (wifi.RcvReply(resp, timeout)) pc.printf("%s",resp); @@ -106,7 +106,8 @@ wait(1); //create link - sprintf(http_cmd,"/update?api_key=%s&field1=%.2f&field2=%.2f",Public_Key,ldrval,potval); + sprintf(http_cmd,"/input/%s?private_key=%s&ldr=%0.2f&pot=%0.2f",Public_Key,Private_Key,ldrval,potval); + //sprintf(http_cmd,"/input/%s?private_key=%s&ldr=%.2f&pot=%.2f",Public_Key,Private_Key,ldrval,potval); pc.printf(http_cmd); pc.printf("******** Sending URL to wifi ********\r\n"); @@ -163,7 +164,7 @@ temp = my_nrf24l01p.read( NRF24L01P_PIPE_P0, count, RxDataCnt_PIPE0 ); pot_val = count[0]; - potval=pot_val/255; + potval=pot_val; pc.printf("Received: %d bytes from PIPE0; POT=%d\r\n",temp, potval); @@ -178,7 +179,7 @@ temp = my_nrf24l01p.read( NRF24L01P_PIPE_P1, count, RxDataCnt_PIPE1 ); ldr_val = count[0]; - ldrval=ldr_val/255; + ldrval=ldr_val; pc.printf("Received: %d bytes from PIPE1; LDR=%d\r\n",temp, ldrval); // Toggle LED2 (to help debug nRF24L01+ -> Host communication)