Category: Uncategorized

DD06CVSA used as true UPS

A small addon circuit I picked up on Aliexpress for a couple of euros. I needed something for my home ControlBox project for power management. The initial idea was simple to keep it plugged into a USB port all the time for operation. While this works, it’s not very convenient to take the ControlBox as a remote about the house, which is why I dediced to get a single Lipo battery in it so I could be temporarly used without an external powerbank.

Enter UPS

That’s right, granted a small UPS. Using the the battery as an uninterruptple power supply introduces following benefits:

  • uninterrupted use of the controlbox when moving around, connecting and disconnecting from the USB power cord.
  • charging/discharging of the battery is autonomous.
  • no toggle switch to turn on or off the power.
  • any amount of Lipo cells can be cascaded in parallel to increase operation

This is led me to the DD06CVSA sold on Ali. The only problem I had with it: the documentation (also Chinese manuals).

The problem I had after hooking everything up was that the UPS would power off the load (ESP) whenever I removed the external power bank. The manuals and Google only talked about toggling the KEY to ground.

A guess brought me to the simple solution: connect the KEY permanently to V?IN? to have the power in true UPS mode. Hence this blog.

SQ13 Mini spycam wifi features

SQ13 Mini spycam wifi features

Introduction

The documentation provides a link the ‘sports dv’ app on google play store. Not looking very promising based on the reviews, I decided to have a go at the alternatives. Also I didn’t like the idea of connecting to the camera on it’s own wifi network. Working on a laptop wirelessly it’s a bit convenient to keep switching from wifi (the internet connection and the camera’s own private), why not just add the wireless camera to the existing wireless internet. In technical terms we needed to but the camera in STATION mode rather than the default AP mode. The only case I can imagine where AP mode is actually wanted is: on the road… But at home, lets use the existing infrastructure, so the cam can be used in surveillance applications.

Find out the IP address

First thing we need. Real easy. Turn on the wifi of the camera by long pressing the mode button. Notice the green led stays lit. Connect your laptop by searching for its Wifi. Check the ipconfig / ip addr show (if your in linux). Notice the subnet 192.168.25.0/24 . The’ve provided us with a gateway (like it matters) hinting that might be the devices service application IP address.

cmd

In my case opening a standard browser http://192.168.25.1 show me a chinese login page. In case you haven’t learned Chinese yet (shame on you) it’s asking for credentials. Typically it’ll be nothing. Correct. Voila the settings allow you to turn off the DHCP server, change from AP to Station. Exactly what I needed.

sq13

Surveillance camera worthy?

The next step then of coarse was to put it in our network and have our computers be able to access it as an rtsp client, dig in to the live feed.

So far I haven’t had any luck guessing the rtsp:// / link yet. Wireshark might be able to tell me more when I’m back from a business trip.

Until then.

Setting up a Docker Host OS

Introduction

This article explains step by step how to a get a bare-metal headless machine ready to serve docker containers. It’ll be able to automate builds and deploy angular apps

 

Install Linux on the PC

We’ll be using Alpine (standard). The reason for that is it’s small size and quick boot time.

  1. Create a bootable USB with the alpine image.
  2. Boot the pc and run through the setup-alpine.

 

 

Install minimal software.

After booting the pc and login in the following commands can be run:

SSH

  1. addgroup users
  2. adduser -s /bin/ash -G users walterwhite
  3. apk add sudo
  4. apk add nano
  5. nano /etc/group
    1. // Add walterwhite (or whatever name you chose) 
      // to the wheel group.  
      wheel:x:10:root,walterwhite
      
  6. visudo
    1. %wheel ALL=(ALL) ALL // uncomment the #

Docker

  1. nano /etc/apk/repositories
    1. uncomment vx.x/community
  2. apk update
  3. apk add docker
  4. rc-update add docker boot
  5. service docker start

Compose

  1. apk add py-pip
  2. pip install docker-compose

Portainer (optional)

Not necessary, but I nice easy GUI served through a web service showing containers running etc..

  1. dfg

Others

GIT

We’ll need this to pull our app.

  1. apk add git

Tip: to never allows have to type the credentials you can run this command in your git project directory:

  1. git config credential.helper store

Nano

Easier to edit files with imo via the console.

  1. apk add nano

Example: Install the Angular App HomeBaseWeb

As a test we’re going to pull a git repo, which features a ready made dockercompose file, telling us where to the dockerfiles are for which containers to spin up.

To do this we’ll create a new project directory and clone the git there:

  1. mkdir mycoolapp
  2. cd mycoolapp
  3. git init
  4. git config credential.helper store
  5. git pull <link t.b.d>
  6. docker-compose up
Esp8266 Restarts / Power Tip

Esp8266 Restarts / Power Tip

While connecting the esp-12x like in the title picture does work, I ran into problems while using it connected this way controlling the house.

Due to the existing boards on my din rail being foreseen with a 8pin headers, I needed a way to connect the esp-12s (which have more flash). I used standard pin cable which seemed to do the job fine. This means I was able to:

  • Flash it (over USB aswell as OTA)
  • Connect to WIFI with a stable ping.
  • Have the MQTT client heartbeat to a broker.
  • ESP polling a DHT-22 over the GPIO

Then when I wanted to control an output (which is done through a UART to an AVR), the command would work, but right after the ESP would reboot! This was strange since the code was near-identical to the chip I used before (esp-01).

My first instinct was the power. The UART pushes the ESP in a power hungry beast sagging the 3.3V below tolerance.

I then rigged up an adapter board to get the ESP-12 as close as possible to the LDO-3v3. It worked. After rigorous testing with the uart command the ESP did not reboot again.

Once again (as many others mentioned), I’d like to remind the importance of stable, nearby power supply when using the ESP.

Below are some pictures of the adapter board. Basically it allows to fit an esp-12 onto a esp-01 header:

IMG_20180826_134813.jpg

And mounted on the din rail to resume house-automation operations.

IMG_20180826_134740.jpg

Stay tuned for more exciting house developments!

Setup MQTT in Angular 2 project.

Today we’re going to be using MQTT in our angular 2 program. Gathering on;y bits and pieces after hours of browsing the internet, I’ve decided to combine everything in this I hope easier to follow guide to get you going.

The solution I’ve found (may not be the most up to date nor correct), did prove to run the code I need for my application.

In this guide, I’m going to assume you’ve got your project folder setup, any you’re ready to start adding mqtt services to it.

For reference, Usually I like to boiler-plate off the angular 2 Tour Of Heroes demo, and using the Visual Code as IDE, but you could easily add this to any existing project.

Installing Mqtt

Command prompt to your project directory and issue the following commands

npm install mqtt --save

As it’s just javascript, and we want to make it typescript’able; we’re gonna need its typings:

npm install --save-dev @types/mqtt

Now  we can use mqtt in our program:

import 'mqtt';
import { Client, Packet, connect } from 'mqtt';
import { ClientOptions } from 'mqtt';

I’ve created a seperate service that’ll take care of the mqtt bits.

Implementation

Now for the actual implementation of the service I’m going to be referring to this Chinese Site. I did find the host parameter missing in their config.json file. Couldn’t comment on their site so I’ll correct it here then: Could comment using the wechat app.

{
 "host": "127.0.0.1",
 "port": 9001,
 "ssl": false,

"user": "john",
 "pass": "smith",

"subscribe": [
 "Test"
 ],
 "publish": [
 "Test"
 ],

"keepalive": 10
}

In my config, you’ll see I’m using port 9001, a websocket port I discussed in my other blog.

 

My Debian Server favourites

Intro

Whilst you may be running debian as an HTPC (Home Theater PC) connected to your TV running Kodi , the machine can be servered-up do additional tasks.

For instance I would also like it to host my angular app controlling my MQTT devices, or make files accessible though the internet using ssh/ftp/nfs ..

For that reason this blog is a list of addtional services I’ve installed on that machine. No need to waste the resources of buying an extra machine for the server or home automation.

Programs

Samba

Allows the server to share a folder using the smb:// protocol. This makes it’s shares visible to the windows workgroup network. Easy for accessing files between windows-linux from explorer-thunar (in debian XFCE )

The easiest in use and configuration by far is from the gadmin package:

sudo apt-get install gadmin-samba

VNC

Now you may be wondering, why a VNC client when we’ve got teamviewer? Well while Teamviewer is easy to install and use, there are some drawbacks:

  • they’ve been hacked not long ago exposing accounts and passwords
  • it’s commercial soft; the annoying nag screen that comes on the remote computer after disconnecting.. messing up your movie/game experience
  • it prevents some games going fullscreen correctly

Vnc is light and easy to install using the following steps (for debiaan 8 xfce )

su
apt-get install xfce4 xfce4-goodies gnome-icon-theme tightvncserver

Additional tasks

External Access: anywhere through the internet to your server

For most people, the server is on a NAT behind the ISP’s router. In my case, the ISP gives you one dynamic external IP address… Easier would be to link it to a dynamic dns service. Create a free account on no-ip.com , just gotta log in every 30days to keep it alive. The client software can also be found on their site.

cd
wget http://www.noip.com/client/linux/noip-duc-linux.tar.gz
tar zxvf noip-duc-linux.tar.gz
cd noip-2.1.9-1
sudo make
sudo make install

The make install asks for your credentials you credited in the noip account earlier. Don’t forget to setup your account and one hostname first! ( I recommend following the new device configurator). It’s ver straight forward for the average user.

screen-shot-2016-11-01-at-20-35-49

Once you’ve got your connection tested from the noip configuration wizard, you only need to forward your ports on your router that your apps use on the remote server.

HTPC (entertainment + server in one ! )

In my case my debian server will not be head-less. Since the server is sitting near the TV we might as well give it some added functionality like KODI and some simple games

Debian Software Common Packages

This adds the add-apt commands for example making it easier to add repositories:

sudo apt-get install software-properties-common

 Emulation

It’s always fun having the old-school emulators to play games from N64, Sega .. Let’s get our emulators installed first. So let’s get retroarch installed: dependencies for debian 8.7

apt-get -y install build-essential libxkbcommon-dev zlib1g-dev libfreetype6-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev nvidia-cg-toolkit nvidia-cg-dev libavcodec-dev libsdl2-dev libsdl-image1.2-dev libxml2-dev

Then clone the repo so we can make a fresh build.

git clone git://github.com/libretro/libretro-super.git

cd libretro-super

SHALLOW_CLONE=1 ./libretro-fetch.sh

./retroarch-build.sh

NOCLEAN=1 ./libretro-build.sh

Wait a long time for the compilation of all the cores..

mkdir -p ~/ra/cores
cd retroarch
make DESTDIR=~/ra install
cd .. #to libretro-super directory
./libretro-install.sh ~/ra/cores