Posts

=================================

A remote controlled AC power switch with visual monitoring capability | DzQ39 |

As a 3D printing hobbyist, I recently developed a system to help me remotely monitor my print and cut off power to my printer in case it starts making spaghetti.

Different Flavors of 3D Printed Spaghetti



Or, generating too much heat that will burn down the machine or even the house.


Reference:
http://forums.reprap.org/read.php?392,294850
http://hackaday.com/2016/12/07/dont-leave-3d-printers-unattended-they-can-catch-fire/
http://hackaday.com/2016/03/21/ask-hackaday-mrrf-edition-3d-printers-can-catch-fire/
http://www.fabbaloo.com/blog/2015/9/23/3d-printer-almost-burns-down-house

Configuration

In the photo below, the device on bottom left is the remote power switch with visual monitoring capability that I developed. In the center is a Logitech USB Webcam. On the right is a 3D printer that's printing the enclosure for the remote power switch.

The power of the 3D printer as well as the power of the heated bad (I use AC 110V heated bad) are plugged into the outlets on the remote power switch.


Left: Power Switch, Center: USB Webcam, Right: 3D Printer

User Interface

The power switch is controlled via a web app that runs on Android, iOS, Windows, and Linux devices that support modern web browser.

Switch Status

This page shows the on/off status of the power switch as well as the photo (if any) taken by the webcam.

Remote Control

This page allows the user to remotely turn on/off the power switch and take photo.


How It Works

Below are screenshots taken from my phone while I was away from home working. Things looked normal in the photo on the left. But, in the photo on the right, there was an obvious gap between the hotend and the printed object so I killed off the power to the printer remotely. When I got home, I found that the new filament is too tight to be pulled into the extruder so I loosen it up to make another print.


The Offer

I am offering this as a kit which includes:

- AC 110V / 220V, 40A Solid State Relay x 1
- Heat Sink for Solid State Relay x 1
- Control Board (with software pre-loaded) x 1
- Power Outlet (with 2 sockets and rated for AC 125V, 15A) x 1
- AC Power Cord x 1

Item Location: Taipei, Taiwan.
Delivery:
- Unless specified otherwise, delivery will be made via EMS with tracking no.
- Delivery Lead Time: Around 10 ~ 14 working days after receipt of complete payment.

Price: US$49.99 (shipping not included)

Below are the things to be prepared by the buyer:

- USB Webcam (Logitech C-series will do. Mine is C905) x 1
- Micro USB Male to USB A Female Cable x 1
- 5V, 1.5 ~ 2A Micro USB Charger x 1
- Mini tripod x 1 (for mounting the USB Webcam) x 1
- Enclosure x 1 (to be printed by buyer using the stl file provided)

If you are interested or have any questions, please leave your comment in the comment section below.













How to use Ubuntu to build C/C++ programs that run on LinkIt Smart 7688 Duo - Method 2 | DzQ39 |

This post is about how to use Ubuntu to cross-compile C/C++ programs that run on LinkIt Smart 7688 Duo running OpenWRT Chaos Calmer 15.05.1 r49203 .

It's assumed that the SDK has been downloaded and installed on the Ubuntu machine. If it hasn't been installed, please refer to http://wei48221.blogspot.tw/2017/05/linkit-smart-7688-7688-duo-using.html for instructions on how to download and install it.

Note, the method described below builds an executable file that can be executed directly by using the "./filename" command.


Step-1, Find the location of "mipsel-openwrt-linux-gcc"

sudo find -name mipsel-openwrt-linux-gcc


Note,

For an Ubuntu machine with "OpenWrt SDK for C/C++ for Linux" installed under the "SDK" folder, below is the location of the file "mipsel-openwrt-linux-gcc".

./SDK/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc

For an Ubuntu machine with "C/C++ Toolchain for Linux" installed under the "OpenWrt-Toolchain-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64" folder, below is the location of the file "mipsel-openwrt-linux-gcc".

./OpenWrt-Toolchain-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc

Judging from the experiment below, having the SDK installed on the Ubuntu machine is enough for cross compilation and there is no need to install the Toolchain.

Step-2, Prepare the helloworld.c file to be compiled

#include <stdio.h>
int main(int argc, char** argv)
{
printf("Hello, World!\n");
return 0;
}

Step-3, Use "mipsel-openwrt-linux-gcc" to compile

SDK/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc helloworld.c -o helloworld


Check the result. There is a helloworld


Check the status "ls -l".


Step-4, Use WinSCP to copy helloworld from Ubuntu to LinkIt Smart 7688 Duo.


Use "chmod +x helloworld" to make the file executable.


Step-5, Run the program.

Use "./helloworld" to run the program.


--------------------------------------------------------------------------------------------------------------------------

How to set STAGING_DIR and PATH

The section below is obtained from https://github.com/japaric/rust-on-openwrt

To verify that you got the right SDK, we'll compile a "Hello, world!" C program, and run it on the OpenWRT device.
When working with the OpenWRT SDK you'll need to set these two environment variables (STAGING_DIR & PATH), and be sure to keep them in your environment for the rest of this how-to.
# Make sure you are in the OpenWRT SDK folder
$ pwd
/home/japaric/openwrt

$ export STAGING_DIR="$PWD/staging_dir"

$ export PATH="$PWD/$(echo staging_dir/toolchain-*/bin):$PATH"
You should now be able to call the cross compiler, which should be in your PATH:
$ mips-openwrt-linux-gcc -v
gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 r42625)
--------------------------------------------------------------------------------------------------------------------------

For my setup, below are the commands issued and the screenshot.

root@root-192.168.2.16:~$ cd SDK

root@root-192.168.2.16:~/SDK$ pwd
/home/root/SDK

root@root-192.168.2.16:~/SDK$ export STAGING_DIR="$PWD/staging_dir"

root@root-192.168.2.16:~/SDK$ export PATH="$PWD/$(echo staging_dir/toolchain-*/bin):$PATH"

root@root-192.168.2.16:~/SDK$ mipsel-openwrt-linux-gcc -v

In the commands above, "wei-hsiung" is replaced with "root" to shorten the line so that the command could be shown in one line.


To verify the STAGING_DIR and PATH have been set correctly

First, check to make sure that "helloworld.c" is in the working directory and there is no executable "helloworld" in the same directory.


Second, issue "mipsel-openwrt-linux-gcc helloworld.c -o helloworld". Then, check again the content of the same directory.


Indeed, there is now an executable "helloworld" in the same directory. And, there is no warning message about STAGING_DIR not defined.

Reference:

How to compile with the openwrt toolchain
http://wiki.wrtnode.com/index.php?title=How_to_compile_with_the_openwrt_toolchain

C Cross Compile for Linkit Smart 7688
https://www.slideshare.net/svrnuke/c-cross-compile-for-linkit-smart-7688

How to use Ubuntu to build C/C++ programs that run on LinkIt Smart 7688 Duo - Method 1 | DzQ39 |

This post is based on https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/c-c++-programming/using-openwrt-sdk-to-build-c-c++-programs with additional info. added from following it.

Note, The method described below uses makefile to build an *.ipk file that could be installed by using the "opkg install filename" command.

Environment:

Working Computer: Windows 8.1.
Cross Compiling Platform: Ubuntu Linux 16.04.2 on ThinkPad-Edge-E420s.

Target:

LinkIt Smart 7688 Duo, OpenWRT Chaos Calmer 15.05.1 r49203


Step-1, Download the SDK

Visit https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/downloads to download the SDK.


The direct download link for the SDK is https://labs.mediatek.com/en/download/AGSSkG38.

Step-2, Copy the SDK to the Ubuntu machine

Use WinSCP to copy the the downloaded SDK (filename: OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2) to the home directory on the Ubuntu machine.

Step-3, Unzip the SDK on the Ubuntu machine

Issue the command below to unzip the SDK.

sudo tar -xvjf OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2

The content of the directory will be like the one below.


Remove "OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2" and rename the folder from "OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64" to "SDK" for easy maneuver.

rm OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar.bz2
mv OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64 SDK

Step-4, Download and unzip the example package file.

The direct download link of the example file: https://labs.mediatek.com/en/download/kJWJnDta

Unzip the file on the PC, then use WinSCP to copy everything under the package directory (including the package directory) to the Ubuntu machine and place the copied directory and files under the SDK folder


Below is the directory structure.


Step-5, Build the package.

From under the SDK directory, use "make package/helloworld/compile" to build the package. Once it's built:

Navigate to SDK/bin/ramips/packages/base to find a package file named "helloworld_1.0.0-1_ramips_24kec.ipk".


Copy the .ipk file to the LinkIt Smart 7688 development board.

In the system console of the board, navigate to the location of the .ipk file and type "opkg install helloworld_1.0.0-1_ramips_24kec.ipk".

After the installation is complete, type helloworld and you'll see a string Hello world, why won't my code compile?

To remove the installed packaged. Use "opkg remove helloworld".

--------------------------------------------------------------------------------------------------------------------------

What to do when compilation failed?


Instead of "make package/helloworld/compile", use "make -j1 V=s package/helloworld/compile" for a more verbose output.

"exec: ccache: not found" is in the output message.


Use "sudo apt-get install -y ccache" to install the missing ccache.


After the installation is done, run "make package/helloworld/compile" again and we have a successful result.


References:

In English.

https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/c-c++-programming/using-openwrt-sdk-to-build-c-c++-programs

https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/c-c++-programming

In Chinese.

https://embedded2016.hackpad.com/ep/pad/static/mhxL7PPo64F