The Project board is for sharing projects based on Silicon Labs' component with other community members. View Projects Guidelines ›

Projects

    Publish
     
      • EFM8-Powered Plug And Play Solar Concept

        nikodean1 | 02/33/2017 | 06:46 PM

        Hey everyone,

         

        I used the EFM8UB1 starter kit to complete construction of my plug and play solar system concept. The goal of the concept is to make solar system installation as easy (and hopefully) as cheap as possible by reducing the amount of on-site assembly required.

         

        It has a built-in inverter, charge controller, 12 Volt, 12 Ah UPS battery, 12 Volt solar panel input, a 5 VDC power rail for a later centralized USB power project, and 120 Volt AC outlets. You just connect a solar panel, flip a switch, and you have a 120 VAC solar power source.

         

        I used the EFM8UB1 to construct an automatic transfer switch for it, so it can automatically switch appliances (or a house, if it is scaled up) to the grid if there is a shortage of solar power. This is convenient for those who want to minimize battery costs without running the risk of a blackout.

         

        Here is a video of me discussing and demonstrating it. 

         

        The EFM8 made it very easy by providing the option of a low-energy USB port (which the white USB cable is connected to) and a built-in CR2032 battery slot.

         

        This is important because it is battery-powered, and I couldn't afford to have it deplete the battery during a cloudy week, or in general: wasting the power generated by the 20 watt solar panel that recharges it. 

         

        In addition to that, the analog-to-digital converter configuration was very quick and easy.

      • Big red button on Thunderboard Sense and Samsung Artik 5

        DanilBorchevkin | 02/32/2017 | 12:19 AM

        As a weekend project, I decided to select an implementation of a big red button based on Thunderboard Sense and Samsung Artik 5. Why a big red button? Because everybody likes red buttons. About it even make films (The Box, 2009).

         

        Sorry for any possible mistakes - I am not a native English speaker/writer. By the way this article there is in russian language.

         

        What is needed for the project

         

        1. Big red button - for this all was conceived. The button should to be normally open
        2. Thunderboard Sense Kit
        3. Samsung Artik 5
        4. Seeed Studio Arduino Base Shield
        5. Seeed Studio Grove Buzzer

         

         

        Setup Thunderboard Sense

         

        Fortunately, we do not need to change anything in the code of the Thunderboard Sense, otherwise it would become a headache - Bluetooth SDK to this device requires an IAR ARM 7.80 compiler, that for many would be a big problem.

         

        As an actuator will act SW1 button - on this button will be tied up all logic of own project.

         

         

        Default firmware do not need any changes because it have following logic:

        1. Board sleep in inactive state and can't accept incoming connections. For change it mode to connectable mode need to push SW1.
        2. After push on SW1 green led start blink there is a possibility for connect to it.
        3. When disconnect is happened Thunderboard Sense again going to sleep.

        Thunderboard Sense provides various BLE services and characteristics (full list available in Android App repository). For us interested only one characteristic - CHARACTERISTIC_PUSH_BUTTONS, which have UUID fcb89c40-c601-59f3-7dc3-5ece444a401b and constist from one value uint8_t, with following states:

        1. Zero (=0) if no buttons was pressed;
        2. One (=1) if SW1 was pressed;
        3. Two (=2) if SW2 was pressed;
        4. Three (=3) if was pressed both SW1 and SW2;

        It is noteworthy that this characteristic has only read property which leads us to the solution of a periodic value reading.

         

        Setup Artik 5

        If it a first-time work with Artik 5 then you need to basic setup according to Quick Start Guide. For start developing you should upgrade to latest firmware and setup internet connection.

         

        Pre-installed packet manager for OS Fedora on Artik is dnf so all following instructions will be for it.

         

        First install all software needed for Bluetooth:

         

        dnf install bluez bluez-libs bluez-libs-devel

        Besides install Git:

        dnf install git

        Futher install Node.JS and npm:

        dnf install nodejs npm

        After this we need to install main module for work with BLE - noble - this module allows to serve BLE connections in case when controller have to do a central role.(for inverse situation there is the bleno module):

        npm install noble

        Now we ready for coding!

         

        Pairing

         

        For pairing devices we need to use the interactive util bluetoothctl. First start it:

         

        bluetoothctl

        After starting we need to switch on a pairing possibility:

         

        pairable on

        Then we should activate Thunderboard sense by pressing on SW1 and start scanning:

         

        scan on

        Target device we can determine by friendly name or by address.

         

         

        When the needed device is finding we should stop the scanning:

        scan off

        The most important for us - remember the address of own Thunderboard Sense and execute following commands:

        pair 00:0B:57:36:71:82
        trust 00:0B:57:36:71:82
        connect 00:0B:57:36:71:82

        At this stage we get message "Connection successful" and now we can request information about connected device:

        info 00:0B:57:36:71:82

        Output will be similar to my:

         

         

        Now input:

        exit

        and ... we ready to write code on Node.JS!

         

        Work with Bluetooth on Artik 5

         

        noble allows develop code for central device. So we have to implement following logic for work with Thunderboard Sense:

        1. Scanning for finding connectable Thunderboard Sense.
        2. Connect to device with a known address.
        3. Gettings lists of services and characteristics.
        4. Read the buttons characteristic's value.

        If you need only working code - go to https://bitbucket.org/sithings/app_thunderboardtoartik

         

        For start scanning we must make sure that Bluetooth controller is power up and only after that we can start scanning:

        /* Event of the state change of the BLE controller on board */
        noble.on('stateChange', function(state) {
        	if (state === "poweredOn") {
        		/*
        		 * If BLE normally started start scanning with duplicates with any UUIDs services
        		 */
        		console.log("\x1b[36m", "\nBLE is poweredOn. Start scanning", "\x1b[0m");
        		noble.startScanning([], false);
        	} else {
        		console.log("\nStopScanning. Status is %s", state);
        		noble.stopScanning();
        	}
        });

        After start scanning we must push SW1 on the Thunderboard Sense for wake up it. Once the device will be available script will be attempt connect to it:

        noble.on("discover", function(peripheral) {
        	
                ...
        
        	/* If founded device is own big red button */
        	if(config.bigRedButton.deviceAddress === peripheral.address) {
        		peripheral.connect( function(error) {
                        
                        ...
        
        		});
        	}
        });

        After successful connect we need to get all services and characteristics:

        peripheral.connect( function(error) {
        	peripheral.discoverAllServicesAndCharacteristics(function(error, services, characteristics) {
        		...
        	});

        In my code I define the desired characteristic by enumeration method:

         

        for(i = 0; i < characteristics.length; i++) {
        	/* If we find characteristic with button state when color it */
        	if (characteristics[i].uuid === config.bigRedButton.characteristicUUID) {
        		buttonStateChar = characteristics[i];
        	}
        	...

        Desired characteristic which contaits value with button state have only one property - read. For acquiring button states we need implement peridical reading of desired value. Afrter define the desired characteristic we need to set a polling interval.

         

        readingInterval = setInterval(readButtonCallback, config.bigRedButton.pollingInterval);

        Listing of the callback:

         

        /* Button callback started by setInterval */
        function readButtonCallback() {
        	buttonStateChar.read(function(error, data) {
        		buf = data[0];
        		console.log("\nData: %d", buf);
        		if (buf === 1) {
        			console.log("SW1 was pressed");
        			/* Enable buzzer */
        			config.buzzer.set();
        		}
        		else if (buf === 2) {
        			console.log("SW2 was pressed");
        		}
        		else if (buf === 0) {
        			console.log("No button pressed");
        			/* Disable buzzer */
        			config.buzzer.clear();
        		} 
        	});
        }

         

        Make buzz

         

        Unfortunately, I could not get to work with GPIO over artik-sdk module and I decided work with GPIO over sysfs. Grove Buzzer in my solution connected over Seeed Studio Base shield to pin gpio121 (2 pin of Arduino expansion).

         

        After starting the script a desired pin must to init as "out":

         

        exec("echo 121 > /sys/class/gpio/export");
        exec('echo "out" > /sys/class/gpio/gpio121/direction');

        To buzzer squeaked the pin must be pulled up:

         

        exec('echo "1" > /sys/class/gpio/gpio121/value');

        To silence buzzer the pin must be pulled down:

         

        exec('echo "0" > /sys/class/gpio/gpio121/value');

        Then exiting the script the buzzer's pins must be released:

         

        exec("121 > /sys/class/gpio/unexport");

        All of this was implemented in config.js of the project. Link to repository.

         

        Connect big red button to Thunderboard Sense.

         

        I have this kind of the button:

         

         

        Interesting fact - the button is more expensive than Thunderboard Sense Kit.

         

        Connect the button by soldering as described on a following scheme:

         

         

        In my case, it looks like this:

         

         

        Testing

         

        Video with test:

         

         

         

         

        But it isn't serous because buzzer too weak. I change the buzzer to relay with signal lamp:

         

         

         

         

        Now the big red button is really cool!

         

        Results

         

        It works. Repository with project - https://bitbucket.org/sithings/app_thunderboardtoartik

         

        Links