Marcin Barabasz

imagination is more important than knowledge… A. Einstein


Leave a comment

Cheap WIFI Switch review (KK-SP3)

20150625_22135520150625_22141020150625_22142020150625_221349

This time I would like to share my experience of a cheap Chinese wifi switch that i bought on Ebay for approx. 16$, plenty of sellers offer it. It is advertised to be able to operate from mobile phone via dedicated app. I was really hoping I wouldn’t need to use it for anything more than configuring connection to my home wifi:).

After receiving the package after few weeks from ordering I was really surprised how good it actually looked. The only drawback was the need to use power switch adapter – but it is not that bad since it is hidden under the switch when plugged in.

After connecting the switch to my home wifi using dedicated android app (There is a manual included). I could indeed turn the device connected on and off – it did it’s job pretty well, but that was not a main purpose I bought this device.

After a little googling I was able to connect to it via ssh.

username: root; password: p9z34cCapture

It turned out that it is actually powered by Linux koven 3.10.26 – very nice indeed – always good to see some familiar interface. This distribution is of course very limited to fit this small device but anyway great to have another Linux device at home.

The next thing was to be able to interface the switch over some well recognized channel- like REST for example.

Here is how I did it (from linux prompt):


mkdir /www/cgi-bin

chmod 755 cgi-bin

Download a cgi script from link and put it to cgi-bin directory.

After that you should be able to control the switch with using:

http://192.168.1.13/cgi-bin/relay.cgi?on

http://192.168.1.13/cgi-bin/relay.cgi?off

(replace 192.168.1.13 with the ip of your kankun)

Using this few small steps I can now utilize this switch in my home automation solution. It will be a topic of a separate post so stay tuned.


Leave a comment

Electric longboard

20141212_081440

20150623_215302

20150623_215326

I got this idea of making myself an electric skateboard after watching one episode of a gadget show in polish TV titled “Nowy gadżet” where presenter was enjoying electric skateboards made by Tesla Boards. His experience was great, but there was one problem – the price. At that time the cost of the board was around 4000 PLN which is around 1000 euros. After little bit of digging I have found loads of other manufacturers who sold assembled boards, and also kits allowing to convert your traditional board to an electric one. Unfortunately all of those were still beyond the limit I would be willing to spend for this gadget. After even more digging I have found few instructions how this was build by amateurs one really caught my attention link. The guys goal was to come down to around 300$ which is pretty good for me as well. Then I have decided I will try to make similar project. Actually the other project is very well documented and should be a must read for anyone willing to build their own electric long board. I got all needed components from HobbyKing for about 270$ including shipping, that did not include pulleys and belt, that I have found in one local manufacturer ebmia. The prices were very affordable. Next step was to modify pulleys and create a frame for the motor. Unfortunately I don’t have neither mill nor lathe so I had relay on outsourcing this task to someone else. Politechnika Wrocławska was my choice, also in case of welding it all together – the prices of all this was around 50$ in total. My biggest concern was of course welding, since it is aluminium, and I had no idea which type of aluminium the trucks were made of, some are not weldable at all. Finished frame with motor already mounted looks like this:

20141114_193002

As for battery and all electronics I had an idea of using an old HDD drawer. I thought it would be cool to be able to have a spare battery in a backpack to extend the range. I however abandoned this idea after realizing that first of all I wouldn’t probably need this extra range, second the whole rack was a bit too big. I have ended up using just a drawer.

20141019_184948

20150221_140057

20141211_220516

Putting all things together was really no more than one evening job, The next day I had to try it out so I did. The experience was just awesome. It was even better than I imagined it to be. First runs were smooth and carving without the need to kick was just great. When I first used the board I didn’t have much experience with LiPo batteries, and wasn’t really aware how important it is not to discharge them below certain limit. Unfortunately I used the board a little bit too much without knowing it and I went below that limit. Not only I had to come back home on foot (around 7km) but also I completely damaged one of the batteries (it got swollen and couldn’t be charged anymore). I had to pay my price for being hasty.  After I ordered and received a new battery I invested also in voltage meter and set the limit to 3.5V per cell. The meter starts beeping when the limit is reached and this is definitely the time to stop.

20150425_130417

Charging the batteries is quite convenient. I use IMAX B6 charger and a balancing port. This protects battery from overcharging any of the cells which is not very healthy for the battery pack. The charging does not take long – I usually set the current to 3A and then charging takes around an hour. Of course I had a small issue with charging as well. When I wanted to charge the board fast I set the current to 3 A, having 5A power supply. I thought I was save, but didn’t think that the power supply gives only 12V, and battery pack is 22.2 all together. This resulted of course in frying power supply. Fortunately it was cheap, now I use a server salvaged  power supply (thanks to my colegue) , that is capable of providing around 50A which is plenty to spare.

Traditionaly a movie of a board in action here


4 Comments

ESP8266 Kindle Remote Page Turner

20150416_233208

Finally I had time to publish a new updated version of my Kindle Remote Page Turner. This time the build will be made using ESP8266 module I got from ebay for about 3$. This module is just brilliant and fits this project perfectly since kindle’s only wireless interface is wifi, so lets start.

What I will be using in this build is one ESP8266 module ESP-03 to be more precisely. There are various packages available, but 03 seems to be perfect combination of size and features (lots of GPIOs). I will just use three gpios in this project two for switches and probably also one for WIFI status led. The first challenge was to solder additional wires to the module to be able to stick it on a breadboard for prototyping. This is what I ended up with:20150416_223954

Since this will be battery powered also I need a way to provide a stable 3.3V. I went with a DC to DC converter and a pair of AAA batteries.

I bought a battery case for 3xAAA batteries, but the plan is to use only 2 batteries, and utilize extra space for all the electronics (DC converter, esp8266, 2 resistors and some wiring).

20150416_221927

Kindle is prepared as in previous post “Kindle remote page turner” with the addition of cgi scripts for turning the pages via web requests. This modification is very well explained here.

Everything is connected as shown on the schematic

kindle_page_turner_bb

kindle_page_turner_schem

But first I need to program my esp8266 to do what it is supposed. I went with NodeMCU firmware as it proves to have biggest community and using it is very easy. What you need is just NodeMCU Programmer ldownload. and ideally ESPlorer IDE ldownload to make programming nice and flawless. The main ideas for the program are:

1. Put ESP8266 into AccessPoint mode.

2. Configure interrupts to wait for key presses on two selected GPIOs

3. Once interrupts occur send HTTP calls to interface created on Kindle to turn pages forward and back

4. How would I know the ip of kindle. This can be addressed by allowing just two possible IP addresses via mask. This way first one will always be for the host and another for the kindle once it connects. This should be sufficient as I don’t want to allow more than one device to connect anyway.

UNFORTUNATELY THIS APPROACH DID NOT WORK SINCE KINDLE IS UNABLE TO CONNECT TO ACCESS POINT CREATED USING ESP8266 MODULE. COMPUTER DOES! I WILL KEEP DIGGING WHY IT CAN’T BUT UNTIL THEN THERE IS ALTERNATIVE.

the alternative is to put ESP into Station mode and connect to the same network as kindle. This solution has however some shortcomings:

1. you can not use this solution outside of one defined network

2. you have to know details like kindles IP address and program your ESP with these details.

but for testing purposes it is ok. The program looks like:

-- This is the original idea to put kindle into AP mode however kindle is unable to connect-- to the device

--wifi.setmode(wifi.SOFTAP)
--wifi.ap.config({ssid="kindle",pwd="0000"})
--wifi.ap.setip({ip="192.168.1.1",netmask="255.255.255.252",gateway="192.168.1.1"})

wifi.setmode(wifi.STATION)
 wifi.sta.config("<SSID>","<PASSWORD>")
 tmr.alarm(0, 1000, 1, function()
 if wifi.sta.getip()==nil then
 print("Connect AP, Waiting...")
 else
 tmr.stop(0)
 print(wifi.sta.getip())
 gpio.mode(8,gpio.INT, gpio.FLOAT)
 gpio.trig(8,"down",forward)

gpio.mode(5,gpio.INT, gpio.FLOAT)
 gpio.trig(5,"down",back)
 end
 end)

function forward(level)
 conn=net.createConnection(net.TCP, false)
 conn:on("receive", function(conn, payload) print(payload) end )

conn:connect(80,"192.168.1.14")
 --conn:connect(80,"192.168.1.2")
 conn:send("GET /cgi-bin/f.cgi HTTP/1.1\r\n"
 .."Host: 192.168.1.14\r\n"
 --.."Host: 192.168.1.2\r\n"
 .."User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36\r\n"
 .."Content-Type: text/plain; charset=utf-8 \r\n"
 .."Accept: */*\r\n"
 .."Accept-Encoding: gzip, deflate, sdch\r\n"
 .."Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4\r\n"
 .."\r\n")
 tmr.delay(500000)
 end

function back(level)
 conn=net.createConnection(net.TCP, false)
 conn:on("receive", function(conn, payload) print(payload) end )

conn:connect(80,"192.168.1.14")
 --conn:connect(80,"192.168.1.2")
 conn:send("GET /cgi-bin/b.cgi HTTP/1.1\r\n"
 .."Host: 192.168.1.14\r\n"
 --.."Host: 192.168.1.2\r\n"
 .."User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36\r\n"
 .."Content-Type: text/plain; charset=utf-8 \r\n"
 .."Accept: */*\r\n"
 .."Accept-Encoding: gzip, deflate, sdch\r\n"
 .."Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4\r\n"
 .."\r\n")
 tmr.delay(500000)
 end

 

Layout of the components inside the case:

20150416_233020

Finished device looks like this:

20150416_233208

Traditionally a short movie showing working device.

movie


Leave a comment

Using WinMerge to compare SSIS in Visual Studio git

Comparing SSIS in VisualStudio can be a real pain in the ass. What can we do to make it just a little bit better? One answer would be use a powerful diff tool like WinMerge. But how to do it for source control files. If you are using TFS this is not hard, because there is a setting to choose own diff app in Visual Studio settings. Unfortunately for git it is not in UI anywhere. It is configurable, but a little more hidden.

If your project is already configured to use git as source control, navigate to project root using windows explorer and locate .git folder. In it you will find file called config with simmilar content to this one:


[diff]
 tool = vsdiffmerge
[difftool]
 prompt = true
[difftool "vsdiffmerge"]
 cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
 keepbackup = false
 trustexistcode = true
[merge]
 tool = vsdiffmerge
[mergetool]
 prompt = true
[mergetool "vsdiffmerge"]
 cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
 keepbackup = false
 trustexistcode = true

To change a default diff tool just add another [difftool] and [mergetool] sections and change tool= <name> to the name of tools you just defined.


[diff] 
tool = winmerge 

[difftool "winmerge"]
cmd = \"C:/Program Files (x86)/WinMerge/WinMergeU.exe\" -e $LOCAL $REMOTE

That’s it really after saving this file your default diff tool will be winmerge.

To really benefit from using WinMerge for SSIS there is another trick available. WinMerge contains feature to ignore lines specified with regex expressions. This feature is called “line filters” more about it here http://manual.winmerge.org/Filters.html. For SSIS especially useful would be:

(width|height|top|left|x|y)="-?\d{1,10}"
\{.{36}\}
ddsxmlobjectstreaminitwrapper binary=".{1,24}"
<DTS:Property DTS:Name="VersionBuild">-?\d{1,10}</DTS:Property>

 

Enjoy!


Leave a comment

module not found: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0

If you’ve ever came across this error:

[warn]  module not found: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0
...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbteclipse#sbteclipse-plugin;2.5.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
...
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependenc es exist with the requested attributes.
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.5.0 (scalaVersion=2.10, sbtVersion=0.13) (C:\development\WorkspaceSTS\HelloScala\plugins.sbt#L3-4)
[warn] +- file-searcher:file-searcher_2.10:0.1
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbt eclipse#sbteclipse-plugin;2.5.0: not found

Make sure that your plugins.sbt is in fact in project subfolder, and not in project root. This seems like common mistake.

Proper project structure should be:

my-app
|-- build.sbt
`-- project
    |-- build.properties
    |-- plugins.sbt


Leave a comment

Baby carousel

I read somewhere that babies up to two months struggle to recognize colors. Another fact is that babies prefer watching faces above all – Since it was a bit hard to find a proper carousel that would be both black and white, and have front faces “looking” down I’ve decided to do my own. My beloved helped me with that – the materials were just old T-shirts. A little fun project to do in your spare time – I liked it even more since my machine sawing skills were getting bit rusty recently.

 

As for attaching the “faces” I used regular wooden black hanger, and a fishing rod🙂 The final product is a bit funny, but my daughter seems to like it very much. whenever the faces are there she just can’t stop looking at them.

enjoy


Leave a comment

Useless box

When I saw it for the first time I knew I was going to build one myself.

Part list:

– Wooden box (I got it for 14 PLN in http://www.empik.com/)

– ON-ON Switch

– Servo (I used cheap Chinese servo from ebay – you can get one for as little as 2$ with free shipping)

– limit switch

– 2AA battery holder

– some wires

– PCB laminate

– Glue gun

– solder

I got electronic parts from local DIY shop for 5PLN total.

First thing is to reassemble the wooden box so that the hinges are on the other side (the box should open lengthwise instead of width wise). Then cut the lid so that both parts are separated. The lid should be cut with less angle so that it closes freely.

Next you need to do is to remove electronics from servo, and limiting pin as well if it exists. The end product should be servo with two wires connected straight to motor.

Next you need to wire things together. It is really not that hard – and nice exercise. The end goal is to have servo rotating in one direction until limit switch is pressed and when ON-ON switch is switched the servo should start turning in other direction that’s it really.

Actually the most tricky part is to attach servo to the box, and construct the arm so that it will open the box and turn the switch. After few failed prototypes made out of cardboard you should get it right. The final piece is made of PCB laminate.

At the end just attach the ON-ON switch to the box and your useless box is ready!

My working piece looks like this http://youtu.be/zVWqqiD8Rmk

 

enjoy