1. Overview of the system:

     SMS Controller sim900 module with communication between PIC microcontroller and Breakout sim900 is a comprehensive solution for monitoring and control equipment effectively. Featuring 4 relay outputs for controlling any 4 devices in the house, perfect control capability including 220V AC power supplies as there is complete isolation from the control circuit via the relay. With four alarm input ports, the user can connect to any sensor with an input signal level, the circuit will monitor and alarm. In addition to the 8 extra RF ports, the connection to removable RF circuits is very convenient, allowing for more efficient and faster remote control, which is also fundamental to extending the monitoring input to the module. wide range of activities.

 

 

   

Highlights of the circuit:

       Breakout SIM900 connectivity support

  • Quad-Band 850/900/1800/1900 MHz
  • GPRS multi-slot class 10 / class 8 supports GPRS coding schemes
  • CS-1, CS-2, CS-3 and CS-4.
  • Supports energy saving mode.
  • Integrated TCP / IP protocol.

       MCU: PIC18F4620-I / PTProgram Memory (KB): 64, RAM Bytes: 3,968

  • Date EEPROM (bytes): 1024,
  • 1-A / E / USART, 1-MSSP (SPI / I2C)
  • 2CCP, Timers: 1 x 8-bit, 3 x 16-bit
  • ADC: 13 ch, 10-bit, Comparators: 2
         

       Vcc: 2V to 5.5V Output

  • 4 relay outputs 12VDC. The common point, usually closed, usually open.

       Input: Pulse source uses IC LM2596 for 3A load current, frequency response 150Khz

  • 4 inputs using isolation opto.
  • 8 inputs RF Receiver 315Mhz - 433Mhz
          

   Operating voltage 7-15VDC

      a. PIC Controller:

 

 

 

   

The central microcontroller module uses the PIC18F4620 with a 4.5V power supply and communicates with the Sim900 via a UART set consisting of two transceivers, Tx (C6) and Rx (C7). The four relay pins are located in the pins RD4, RD5, RD6, RD7 corresponding to the relay 1,2,3 and 4. Similarly, the four alarm input pins are arranged at pins RB0 , RB1, RB2, RB3 respectively IN1, IN2, IN3, IN4. In addition, the RF input pins are also located at a separate port, the pins RA1, RA2, RA3, RA4 respectively D3, D2, D1, D0 of set 1 and respective pins RC5, RC4, RD3, RD2 D0, D1, D2, D3 of set 2.

     In the above diagram, generally use the basic pins of the PIC with the I / O import function and use the UART interface to communicate with the SIM900, with basic things you can develop more applications. Other enhancements to the board include ADC applications for temperature readings, expandable I / O ports to handle larger devices, and more.

     b. Power source:

 

 

   

The power supply circuits include microcontrollers, sim900 modules, I / O blocks, so we need a sufficiently large current source. Here we choose the source circuit with the design LM2596 -ADJ, this is the source IC capable of up to 3A load to ensure stable system work. Our system uses 4.5V power supply for whole circuit, so we need voltage divider for LM2596 -ADJ so that input 12V and output is 4.5V. According to the datasheet of IC LM2596 -ADJ, we have the following formula:

         Vout = 1.23 (1+ R2 / R3)

      We have to choose a pair of resistors so that Vout is 4.5V, with R3 = 2.1K and R2 = 5.6K satisfying the above conditions.

c. Input block:

 

 

   

The requirement is that when there is an external action or in other words a pulse, the microcontroller understands and executes the alarm via the SIM900, which is also the function of this input input block. In order to carry out the input signal collection we use an input buffer Oppto to do that.

      Oppto's configuration consists of a led and an optic transistor. If the high-level led input latches into the op- pode, then the optically induced transistor coincides with the high output if the output is connected to the source. .

      The oppto input circuit is capable of gathering input signals at a high level of 5V-12V completely isolated from the system board due to the nature of the OpType structure.

      d. Control Output Unit:

 

 

 

   

     The control unit is responsible for controlling the peripheral devices via a normally closed and normally open contact. The circuit uses oppto-enabled transistors and relay isolators that control the device with high application capability, which can be used for a wide variety of devices, including devices with 220V AC power.

     The principle of operation of a typical channel in the block as star: look at the principle diagram we see, when there is an output signal from the microcontroller pin 5V-12V high level click on Anode led by oppto led light oppto , when the optical transistor of the oppto leads the 12V through the 10K resistor to the B terminal of the C1815 transistor. At this point, the C1815 transistor continues to power 12V through the relay coil down to the mass. When there is power through the relay coil, the relay switches on and terminates the device control.

     e. Breakout Block SIM900:

 

 

 

   

Based on the schematic of the Break900 SIM900, we designed a connector that communicates with the PIC. Structure and schematic diagram Breakout SIM900 you can refer in the product.

      This block is very important in the SIM900 SMS Controller circuit, the Break900 SIM900 is the bridge between the system and the mobile phone, the task is to receive messages from the phone and transfer messages to the processor concurrent processing Receive text messages from the microcontroller and transmit to the user's phone via GSM network.

     f. RF block:

 

 

   

     The RF block consists of connectors connected to the external RF circuit that receive signals from the RF unit to the microprocessor. The SMS Controller has a built-in 8 RF channel, which is equivalent to 2 removable RF units for each 4-channel set.

      The integration of RF boards on the board is very important and the benefits are great. With the RF unit, you can easily control the equipment with the remote. RF inputs can also be used as wireless alarm inputs.

      2. Activities:

      You can visualize the whole system through the block diagram as follows:

 

   

      AT-COM has developed a demo code system for the SMS Controller SIM900, written in CCS, with this system. The SMS Controller is capable of performing the basic functions of device control messaging as well as gateway monitoring. enter through the input port.

      Text messaging controls the device system extremely simple with the ability to completely synthesize by the programmer.

 

 

    Here we specify the message syntax with the above program. The syntax is as follows:

    Open device 1: #[pass] On1.

    Open device 2: #[pass] On2.

    Open device 3: #[pass] On3.

    Open device 4: #[pass] On4.

    Open device 5: #[pass] Tat1.

    Open device 6:  #[pass] Tat2.

    Open device 7:  #[pass] Tat3.

    Open device 8:  #[pass] Tat4.

    Pass is a string of security characters specified by us and shown on the command line. Char MK [] = "123456"; When you text message just the correct syntax has been specified microcontroller can understand and work according to your requirements. The extensibility of this code is very high, you can develop with a completely different syntax for example above, the security character may be longer than that which will provide higher security. .

      In order for the microcontroller to receive the message content from the SIM900 sent down through the UART, it is necessary to have UART interrupt set up.

 

 

     

This is a UART interrupt program that accepts characters and saves them into a buffer array, which also recognizes the beginning of the string and ends the string through the special "#" and "." Special characters for efficient dark string management. The best. Of course, there are two lines of code that can be used to initialize the UART break in main () when using this interrupt:

      enable_interrupts (INT_RDA); // allow uart

      enable_interrupts (GLOBAL); // allow full access

      At the Breakout SIM900, in addition to powering the circuit, so that the module can start working, you need to click a high-level pulse on Breakout SIM900's ON / OFF pin number 1, and the processor will take care of that. The Init_sim900 program is located at the beginning of the Main section to activate the Break900 SIM900 to activate.

 

 

    

      PWU is Breakout SIM900 pins corresponding to the RC3 pins of the microcontroller. When the Breakout SIM900 is successfully triggered by sending the AT command to the SIM card, the system will alert you that the boot system is complete by sending a message to the phone number set in the code.

      The send_sms (num1,0) command; The message sent to the user is not only a complete startup, but all related alerts include opening the device, turning off the device, etc.

 

     The message content of the response cases is in the case of the switch - case, when that happens it only takes the case of the case and sends it. The phone number we specified above with the command:

     char num1 [] = "01265105xxx";

     And so in the messaging program, we just take that phone number and execute the command sent by the AT Command syntax. The message has the following syntax:

      AT + CMGS = "xxxxxxxxxxx" (xxxxxxxxxxx: is the phone number needed for IM)

     > message content

     After entering the message content and finally Ctrl + z to simulate and send the message.

     Similar to the SMS sendback program, we also built a separate alarm event for a particular SMS send program segment, called program send_cb (char * p); This program also has SMS feedback function but it is used in sending SMS when there is input effect.

 

 

 

    The program structure is nothing new compared to the SMS response program, only changes in the content of the sent SMS, instead of content is stored in each case of the switch function - case here we will scan things. Each input state and if the input is affected, only send the correct input content.

     To get the input state for the send_cb program, the main program can not lack a program scan input:

 

 

     This is a program that directly scans the input state from RB0 pins to RB3 pins, and sends messages.

     The final part is indispensable piece of SMS reception program and device control:

 

 

      This is the entire receiver system, comparing message content and device driver as required. To get a better understanding of the operation of the program, I would like to give you a brief example of device driver 1, and through which the rest of you can learn more:

 

In the program above you see, the variable sms_mode is responsible for receiving the variable when the sms arrived, sms_mode = true when the message, sms_mode = false, this variable will be set in the interrupt program you can see Again program content interrupt above. The if (sms_mode = = true) function checks incoming SMS.

     Assuming there is a message coming in and sms_mode = true the next step of the program is checking the password, comparing the default password with the password in the message, shown in the next two chapters:

    Ptr1 = strstr (buffer, MK);

   If (strncmp (ptr1, MK, 6) = = 0)

     The strstr () function is used to search for the first occurrence of the MK string inside the buffer. The result of the function is that the Ptr1 pointer points to the first element of the buffer string containing the MK string. The next strncmp () function is used to compare two MK strings and a Ptr1 pointer whose first position value is the MK string in the buffer, with a comparable value of six, if the two strings are the same. Returns the value of 0.

     The last step in checking the message is to check the control characters, using the same two commands as the password check:

     ptr2 = strstr (buffer, mo_tb1);

     if (strncmp (ptr2, mo_tb1,3 = = 0)

     If all the conditions are right, the microprocessor system will turn off the device according to the requirements of the message user.

    3. Video Demo

 

 

   4. Summary:

     In summary, all of the above has introduced you to the overview of all the basic operations of the SIM900 SMS Controller circuit, the functions you see above are just the most basic functions that A SIM900 SMS Controller must do, based on the code as well as the instructions above you can develop yourself new application flexibility, the deployment of add on board is not difficult. The limitation of the demo code on many, the code does not have the function of controlling the device through the RF transceiver, do not have many message servers.

     You can develop other important functions such as password change, password saver in epprom, power outage monitoring, more display block to help users more intuitive, etc. ...