Monitoring the status of washing machine using GPRS module:
When washing machine starts running until it finishes its execution, every 30 seconds a timer interrupt handler will update the state of washing machine on the webserver. For this we are using https requests to “POST” data to web server. For this project we are using the ThingSpeak webserver by Mathworks to monitor our washing machine. We have also added text sms feature of GSM to monitor the washing machine. Since GSM sms service is passive, slow and generally unreliable, we only send sms for start, resume and pause states of the washing machine.
IMPLEMENTATION DETAILS:
We have made four command interfaces for interface between GSM and GPRS https functionality and the machine.
These four commands are as follows:
void Command(char*str)
This will wait for OK to come from previous command and then execute the current instruction.
void send_command(char* str)
This will send command to the module and clears the wait for the next module
Void Command_msg(char* str, char* msg)
This takes two arguments which are the command to send message(AT+CMGS=“Mobile no.”)
and message to send. It will send only when we get OK from previous command
Void send_msg(char* msg)
This sends the message to the gsm module and terminates it with the special character Ctrl+z
In addition to above command interfaces we have made two more functions that run special commands – specific https AT commands.
Void command_dld(char *cmd)
This will wait for “download” keyword returned from previous command instead of OK keyword.
INITIALIZATION FUNCTION:
For using the gsm and gprs functionality we have to initialize the following AT functions. Below are the initialization functions and their description.
ATE1: it enable the the echo mode of gsm module.
AT+CGATT=1: This command checks whether or not GPRS is attached
AT+ SAPBR=3,1,”CONTYPE”,”GPRS” : This command is used to set the connection type, which is GPRS
AT+SAPBR=3,1,”APN”,”internet” : Set up the APN
AT+SAPBR=1,1 : Enable the GPRS
AT+HTTPINIT : Enable HTTP mode
AT+HTTPPARA=“CID”,1 : Mandatory command which sets the bearer
AT+HTTPPARA=“URL”,api.thingspeak.com/update” : Set the URL of the page to be read:
For sending data over internet, we use the following commands
AT+HTTPDATA=70,2000 : Send 70bytes in max of 2000 seconds ( the gsm modules “listens” for max 2000s )
AT+HTTPACTION=1 : Start the HTTP POST session:
To terminate the http session, we use the following command
AT+HTTPTERM : End the HTTP request
AT+CGATT=0: Disconnect GPRS
For sending the message to we use the following commands
AT+ CFUN=1
AT+CMGF=1
AT+CMGS=“Mobile number”
>type message here(ctrl z)
*The message need to be terminated with the special character ctrl+z*
RESULTS:
FIGURE 1 DETAILS:
Field1: shows the pause and resume state of washing machine
Field2: shows the stat of washing machine(i.e. High, low, medium)
Field3: shows the mode of washing machine(i.e prewash, wash, spin)
Field4: show the timer of washing machine
FIGURE 2 DETAILS:
It show the gsm text messages received on the prescribed mobile number(i.e. WASH START, WASH RESUME, WASH PAUSE)
Figure 2:
Recent Comments