• Simple wireless relay control and temperature reading with 1000pads-mini system

    This application features two 1000pads-mini-system boards, 2 Xbee modules and a Microchip Pic16F88 to control two relays and read a temperature sensor over-the-air. The final assembly is simple and tiny: boards can be placed anywhere using a common 9V Battery. Relay switching will be made remotly from a pc, the temperature sensor on board will be read from pc too. The programming language used for the MCU is Hitec-C lite version (I've used 9.65PL1 version that comes with MPLAB IDE 8.40).


    We need the following boards:

    2 XBee modules (you can use series1, series 2 or PRO)
    1 990.002 XBee USB Board (used for Xbee connection on the pc)
    1 990.102 1000Pads-Mini XB Board (used for Xbee connection on the pic)
    1 990.107 1000Pads-Mini 2 relays board

    Assembling

    On the 1000pads-mini xb board we must assemble components following this schematic (click to enlarge):



    B1 is a common 9V battery (but you can use an external power supply too). The temperature sensor used is a LM35DZ. Please pay attention to the board connection of 990.102 1000pads-mini xb board (please refer to 990.102 datasheet). Here are shown main connections:



    Note: Pads marked as "3.3Volt" must be NOT used in this application! Let them free!

    On the mini-xb board we'll mount: Xbee, Power supply, Temperature sensor and resistors to adapt 5Volt transmission level of picmicro to 3volt level of Xbee (this is required only on RX pin of XBee: XBee's TX level of 3volt is suitable for picmicro without any arrangement). The 1000pads-mini xb board will need a 10pin-male-pinstrip connector soldered on the lower side: we will use this connector for attaching the 1000Pads-mini 2 relay board (where we'll place the PIC16F88 also). Only 5 pins of this connector will be used: 2 for power supply, 2 for UART Tx and Rx and 1 for feed the analog read from LM35DZ to PIC16F88. So you can use a 5 pin connector instead of 10 pin too.

    Note: please testing all voltage level before attach XBee module: voltage on RX pin of XBee must not exceed 3.3 Volts!
    Then on the 990.107 1000pads-mini 2 relay board we'll assemble this schematic:



    I reccomend to use a crystal in HC49S format. In the following picture are shown the connections for RA2 and RA1 ports of the pic16F88 for relay control (please refer to 990.107 Datasheet)





    On the 990.107 1000pads-mini 2 relay board we'll solder a 10pin-female-pinstrip to connect this board with the upper board. This is a picture shows how are made boards connection:






    The boards could look like this:



    We'll mount the xb board on top of relay board using 1,1 or 1,2mm hex spacers, the final result is pretty tiny:

    Note: you can expand this application by using other boards of 1000pads-mini system

    Code

    The code is quite simple (can be downloaded below). Pic16F88 UART will run at 9600bps, then will receive commands from pc via Xbee serial connection.

    Note: XBee's default baudrate is 9600, be sure that is not changed or mcu will not communicate with xbee. You can change XBee baurate using X-CTU software from Digi

    UART setup is performed in "usart.h". A/D conversion will start up every 100mS by a counter incremented by Timer0 Interrupt



    Once code is loaded into Pic16F88, you must open Hyperterminal or other similar software with following settings:



    • BaudRate: 9600
    • Data bits: 8
    • Parity: none
    • Stop bits: 1
    • Flow control: none

    By pressing 's' or 'S' (without quotes!), we will know actual relay status:



    By pressing 'r' or 'R' followed by 1 or 2, we will toggle relay 1 or 2:



    If we press an invalid key after pressing 'R'/'r' an error message will be displayed:



    By pressing 't' or 'T', the remote temperature in C will be displayed:



    The code is optimized for PIC16F88, with an 4MHz Xtal and compiled with "HI-TECH C PRO for the PIC10/12/16 MCU family (Lite) V9.65PL1" under MPLAB 8.40. This code may not be compiled with Hi-tec C 9.70 version due to a bug of compiler.