0% found this document useful (0 votes)
28 views3 pages

Sewage

The document contains code for a microcontroller program that reads sensor data using an ADC, displays the values on an LCD screen, and sends the data to a server over HTTP if certain thresholds are met. It monitors gas, moisture, and light levels, triggering alerts or status updates depending on the sensor readings.

Uploaded by

balaji badshah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Sewage

The document contains code for a microcontroller program that reads sensor data using an ADC, displays the values on an LCD screen, and sends the data to a server over HTTP if certain thresholds are met. It monitors gas, moisture, and light levels, triggering alerts or status updates depending on the sensor readings.

Uploaded by

balaji badshah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include<pic.

h>
#include<htc.h>
#define _XTAL_FREQ 20000000
__CONFIG(FOSC_HS &WDTE_OFF & PWRTE_ON & CP_OFF & BOREN_ON & LVP_OFF & CPD_OFF);
void main()
{
TRISB=0X00;
PORTB=0X00;
TRISC=0x81;
PORTC=0X0f;
TRISD=0X00;
PORTD=0X00;
while(1)
{
lcd_com(0x80);
lcd_str("G1=");
n1=ADC_Read(0);
val(n1);
if(n1>400)
{
RD0=1;
lcd_com(0xC8);
lcd_str("HIGH CO");
__delay_ms(100);
RD0=0;
lcd_com(0xC8);
lcd_str(" ");
}

lcd_com(0x88);
lcd_str("G2=");
n2=ADC_Read(1);
val(n2);
if(n2>400)
{
RD0=1;
lcd_com(0xC8);
lcd_str("HIGH ME");
__delay_ms(100);
RD0=0;
lcd_com(0xC8);
lcd_str(" ");
}

lcd_com(0xc0);
lcd_str("WL=");
n3=ADC_Read(2);
n3=1023-n3;
val(n3);
if(n3>700)
{
RD1=1;
lcd_com(0xC8);
lcd_str("BLOCKED");
__delay_ms(100);
}
else
{
RD1=0;
lcd_com(0xC8);
lcd_str(" ");
}
if(RC0==1)
{
lcd_com(0x01);
lcd_str(" SENDING ");
lcd_com(0xC0);
lcd_str(" EMERGENCY SMS ");
Delay(10);
uart_sendstring("AT+CMGS=\"+917299944417\"\r");
Delay(15);
uart_sendstring(" EMERGENCY ALERT ");
Delay(15);
uart_sendchar(0x1A); //////ctrl+z
uart_sendchar(0x0D); //////enter
Delay(500);
l=0;
lcd_com(0x01);
}
//////////
if(l>500)
{
lcd_com(0x01);
lcd_str(" SENDING ");
lcd_com(0xC0);
lcd_str(" IOT ");
Delay(10);
uart_sendstring("AT+SAPBR=1,1\r\n"); //Querying bearer
Delay(5);
uart_sendstring("AT+HTTPINIT\r\n"); ////Initializing HTTP service.
Delay(30);
//http://vehicleiot.in/gas/get.php?gas=100&load=100
uart_sendstring("AT+HTTPPARA=\"URL\",\"http://vehicleiot.in/sewagemonitor/get.php?
g1="); //Setting up HTTP parameters..
val1(n1);
uart_sendstring("&g2=");
val1(n2);
uart_sendstring("&wl=");
val1(n3);
uart_sendstring("&st=");
if(n3>700)
{
uart_sendstring("BLOCKED");
}
else
{
uart_sendstring("FLOWING");
}
uart_sendstring("\"\r\n");
Delay(20);
uart_sendstring("AT+HTTPPARA=\"CID\",1\r\n"); //Set the CID
Delay(30);;
uart_sendstring("AT+HTTPACTION=0\r\n"); //HTTP action is read
Delay(100);
uart_sendstring("AT+HTTPREAD\r\n"); //Read the HTTP response
Delay(50);
uart_sendstring("AT+HTTPTERM\r\n"); //Terminating HTTP session..
Delay(50);
l=0;
lcd_com(0x01);
}
l++;
}
}

You might also like