Here is a quick (work in progress) demo of the BLECM board being used for a quick 'remote relay' application from a cell phone app.
http://ww1.microchip.com/downloads/en/DeviceDoc/BLECM_out_of_box_helpfile.pdf
I only needed to modify the stock firmware to add (piggyback on the led control code) relay outputs on the mikrobus port pins and quickly design/build a 5vdc relay board with a DIP socket interface.
Port D on the PIC24 allows for 5 volt open-drain operation so these pins were used to drive an ILQ2 optocoupler for the relay coils.
The next step is to customize the generic Android app.
https://github.com/MicrochipTech/blecm_android_app
Project directory
https://github.com/nsaspook/fac_relay
http://ww1.microchip.com/downloads/en/DeviceDoc/BLECM_out_of_box_helpfile.pdf
I only needed to modify the stock firmware to add (piggyback on the led control code) relay outputs on the mikrobus port pins and quickly design/build a 5vdc relay board with a DIP socket interface.
Port D on the PIC24 allows for 5 volt open-drain operation so these pins were used to drive an ILQ2 optocoupler for the relay coils.
The next step is to customize the generic Android app.
https://github.com/MicrochipTech/blecm_android_app
C:
PIC24 xc16 C code change fragments
config.h
//Enable / Disable the MCP1642B 5V boost power supply for 5V power pin on MikroBUS header
//Set to 0 to disable; 1 to enable (Enable this for 5V Click Boards)
//#define MCP1642B_EN 0
#define MCP1642B_EN 1
...
// RELAY outputs
#define RELAY1 LATDbits.LATD3 // output 0 (low) turns on relay
#define RELAY2 LATDbits.LATD9
#define RELAY3 LATDbits.LATD10
#define RELAY4 LATDbits.LATD4
main.c
// RELAYs are outputs and open-drain
// to drive ILQ2 opto
// setup in Mikrobus header
ODCDbits.ODD3 = 1; // pin 16
ODCDbits.ODD9 = 1; // pin 11
ODCDbits.ODD10 = 1; // pin 12
ODCDbits.ODD4 = 1; // pin 2
leds.c
case LED_BTLE_PAIRED:
LED1 = appData.led1; // logic high turns on led
RELAY1 = !appData.led1; // logic low turns on relay
LED2 = appData.led2;
RELAY2 = !appData.led2;
LED3 = appData.led3;
RELAY3 = !appData.led3;
LED4 = appData.led4;
RELAY4 = !appData.led4;
LED5 = 1;
LED6 = 0;
break;
https://github.com/nsaspook/fac_relay
Last edited: