Broken Trust – An Ubuntu upgrade gone wrong

 Linux  Comments Off on Broken Trust – An Ubuntu upgrade gone wrong
Apr 242016
 

When doing the regular updates to my Ubuntu laptop this weekend, I got prompted about an upgrade to version 16.04 (I am on 15.10 currently).
As all updates and upgrades have been smooth and without any problem before, I gladly pushed that button.
In retrospect, I should have been more careful.
The upgrade as such went without any hassle, even though it took quite some time, but no errors or any other messages shown.

It all started when login in the first time.
After entering the password on my account, the desktop is briefly shown with a pop up message about some System program problem detected, then immediately back to login screen.
No chance to read the complete message, nor to interact with the pop up buttons.
Same thing if I try the Guest login.

To catch this picture I had to set the phone camera to burst mode.
Ubuntu1604_login_problem

But doing CTRL + ALT + F1 to get a tty1 console, and I can login on my account.
So far so good, but what do I do now?

First thing first. Hook up an external USB disk, mount it, and backup the files I absolutely do not want to lose.
It is at times like these, you start to wonder when you made your last backup, and was that a complete backup or did I miss something.
This action was taken just to be safe, if I will end up in having to do a complete re-installation on the machine.
I really hope not to end up in that situation.
But as the saying goes, "Hope for the best. Prepare for the worst".

Scouring the net on the login loop problem, it seems to have happened before to people upgrading to other versions (14.04).
One of the solutions I found is.
mv .Xauthority .Xauthority.bak
and then reboot.
But that did not help on my computer. Obviously a solution for another problem.

Searching for the "System program problem detected", and found this to disable the reporting of program problems. Let's see if it helps somehow.
Remove all crash logs, and disable apport.
sudo rm /var/crash/*.crash
sudo vim /etc/default/apport
Change 'enabled=1' to 'enabled=0', restart system.
But this did not help either.

Continued searching, and found someone stating it could be video driver problem (again). Try,
sudo apt-get purge nvidia*
Doing this, I got a question on restart on how to proceed with graphics settings. I chose low quality for now.
I still get the 'system program problem detected' pop-up, but I can enter the desktop.

Finally able to login to the desktop, I notice that WiFi is not working any longer. Wonder what else has stopped working.
After some investigation.
lspci -knn | grep Net -A2
nmcli -p c
nmcli -p g
nmcli dev wifi
lshw -C network
It all looked okay. Ended up just de-selecting the Broadcom WiFi driver in Additional Drivers. Reboot. Then choosing that BCM driver again.
Viola! WiFi is working again. No good explanation on why it works, just happy it does.

While in the Additional Drivers, I also selected the Nvidia graphics driver again. And to my joy, I still am able to login.

Well that actually makes me think I am finally upgraded to Ubuntu 16.04 with everything working.

License

 Software  Comments Off on License
Dec 072015
 

When writing software, at work or at home, you will eventually end up thinking about which license, if any, you should use.
I have been thinking about this for some time, and found this site, http://choosealicense.com/, which was really helpful to me.

I have chosen to go with the MIT license, since it very permissive and simple.
This is how the license text look like.

The MIT License (MIT)

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

It should be either inserted into the source code file, or added as a LICENSE.txt file in the project.

ISP Watcher

 Linux, Python, Raspberry Pi  Comments Off on ISP Watcher
Dec 062015
 

After waiting for several years, we finally got fiber internet connection two months ago.
Sadly in these two months we have had three occasions when we had no connection to internet at all.
Last time, a couple of days ago, it was out for more than 24 hours!
This is way worse than I expected, and much worse than the old ADSL connection we had before.
On the good side is, that when we actually have connection, it works really good.

But to have better statistics on the connection reliability I made a small python program.

#!/usr/bin/python2 -tt
# Joakim Wesslen

'''
Check internet connection and log result to file
'''

"""
The MIT License (MIT)

Copyright (c) 2015 Joakim Wesslen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

"""

import sys
import time
import urllib2
import socket


logfile = "ispwatcher.txt"
loop_delay_minutes = 30
seconds_per_minute = 60

urls = [
'www.dn.se',
'www.sds.se',
'www.svd.se',
'www.cnn.com',
'www.bbc.co.uk',
'www.dmi.dk',
'www.nrk.no'
]


def getdatetime():
	'''Get date time string'''
	return time.strftime("%Y-%m-%d_%H:%M:%S")


def check_url(url):
	'''check url connection'''
	try:
		response=urllib2.urlopen('http://' + url, timeout=10)
		return True
	except urllib2.URLError as err: 
		pass

	dt = getdatetime()
	s = "Error: {}: {}".format(dt, url)
	print s
	write_result(dt, s)
	return False


def check_urls(urls):
	'''check list of urls'''
	results = []
	for url in urls:
		res = check_url(url)
		results.append(res)
	return results


def calc_result(results):
	'''
	calculate the result of check_urls.
	if one url is accessible, we are connected.
	'''
	if True	in results:
		result = "connected"
	else:
		result = "disconnected"
	return result		


def write_result(dt, result):
	'''write result string to file with datetime'''
	s = "{}: {}".format(dt, result)
	print s
	with open(logfile, "a") as txt_file:
		txt_file.write(s + "\n")


def wait_minutes(minutes):
	'''wait some minutes'''
	time.sleep(minutes * seconds_per_minute)


def get_lock(process_name):
	'''make sure only one instance exists'''
	global lock_socket
	lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
	try:
		lock_socket.bind('\0' + process_name)
	except socket.error:
		print "Already running"
		sys.exit()


def close_lock():
	'''release the lock'''
	global lock_socket
	try:
		lock_socket.close()
	except socket.error:
		print "close_lock exception!"


def main(args):
	try:
		while True:
			dt = getdatetime()
			results = check_urls(urls)
			result = calc_result(results)
			write_result(dt, result)
			wait_minutes(loop_delay_minutes)
	except KeyboardInterrupt:
		print 'Stopped by user'
		close_lock()
		sys.exit(0)


if __name__ == '__main__':
	get_lock('ispwatcher')
	sys.exit(main(sys.argv[1:]))

The program checks internet connection two times per hour, and writes the result to a file.
I put it on a Raspberry Pi, connected directly to the router, and also set up a cron job to make sure it runs.
The cron job starts the script every half-hour, and is done as:

00 * * * * /home/pi/ispwatcher.sh
30 * * * * /home/pi/ispwatcher.sh

The shell script is simply starting the python program.

As you can see the python program makes sure only one instance is running, so this setup should be okay I hope.
Let's see what the result will show.

Home Automation – Receiver

 Arduino, DIY, Electronics, Home Automation  Comments Off on Home Automation – Receiver
Aug 112015
 

I have made a couple of attempts over the past years to make a Home Automation Receiver with an Arduino Uno and a simple 433MHz receiver.
But so far I have failed, believing the Uno maybe wasn't fast enough for the task at hand.
By chance a colleague of mine stumbled upon my blog, and wondered if I did not have any such receiver at hand, since I had made transmitters way back in time.
I told him about my endeavors and my disbelief about the performance. Luckily he did not listen too much, and did some internet searching.
Of course there are sketches out there for the receiver task. After looking at some of them I decided to try to do one myself.
One major difference in my new sketch, compared to my older attempts, is the use of pulseIn(). Before I tried to sample with digitalRead()  but could never get a consistent result.
With pulseIn() we detect only the low part of the pulses, and by comparing the length of the low part, conclude what type of bit it was.

This is what the HW setup looks like.
DSC_0952

Here is the sketch.

/*
   Joakim Wesslen
   2015-08-10

   We detect data pulses by catching the low part of every pulse.   

*/

/*
More info at:  
http://tech.jolowe.se/home-automation-rf-protocol-update/
http://tech.jolowe.se/home-automation-rf-protocols/


Physical data structure (in air):
Bit
0        10        20        30        40        50           60
1234567890123456789012345678901234567890123456789012 34 56 7890 1234
--------------------------------------------------------------------
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT GG OO DDDD NNNN

Bits #01-52 -> TxCode (T)
Bits #53-54 -> Group (G)
Bits #55-56 -> On/Off (O)
Bits #57-60 -> ? Dimming/Channel ? (D)
Bits #61-64 -> Device Nbr (N)


Logical data structure:
0        10        20           30  
12345678901234567890123456 7 8 90 12
------------------------------------
TTTTTTTTTTTTTTTTTTTTTTTTTT G O DD NN

Bits #01-26 -> TxCode (T)
Bits #27 -> Group (G)
Bits #28 -> On/Off (O)
Bits #29-30 -> ? Dimming/Channel ? (D)
Bits #31-32 -> Device Nbr (N)

*/


int rxPin = 12;

boolean debugOn = false;  // enable debug prints

int tPause = 0; // debugging
int tSync = 0; // debugging

unsigned long loopCounter = 0;  // stats
unsigned long dataCounter = 0;  // stats

// Setting limit boundaries
int pauseMinTime = 7000;
int pauseMaxTime = 14000;

int syncMinTime = 2100;
int syncMaxTime =  3200;
 
int oneMinTime = 70;
int oneMaxTime = 300;

int zeroMinTime = 1000;
int zeroMaxTime = 1900;

signed long timeout1 = 1000000;
signed long timeout2 = 100000;


#define MAX_STR 150

char bin[MAX_STR + 1];

// get a 'binary' 32 bit string from value
char *dec2binStr(unsigned long ul)
{
 int len = sizeof(ul) * 8;
  int c, d;
  int count = 0;

  memset(bin, len, '0');

  for (c = len-1 ; c >= 0 ; c-- )
  {
    d = ul >> c;

    if ( d & 1 )
       bin[count] = '1';
    else
       bin[count] = '0';
    
    count++;
  }
  bin[len] = '\n';
  return bin;
}

// log function
void ilog(const char *fmt, ...)
{
  char tmpStr[MAX_STR + 1];
  va_list ap;

  va_start(ap, fmt);
  vsnprintf(tmpStr, MAX_STR + 1, fmt, ap);
  va_end(ap);
  Serial.println(tmpStr);
}

// debug log function
void dlog(const char *fmt, ...)
{
  if (debugOn) 
  {
    char tmpStr[MAX_STR + 1];
    va_list ap;

    va_start(ap, fmt);
    vsnprintf(tmpStr, MAX_STR + 1, fmt, ap);
    va_end(ap);
    Serial.println(tmpStr);
  }
}

char binPhy[MAX_STR + 1];

// get a 'binary' 64 bit string from value
char *dec2binPhyStr(unsigned long ul)
{
 int len = sizeof(ul) * 8;
  int c, d;
  int count = 0;

  memset(binPhy, MAX_STR, '0');

  for (c = len-1 ; c >= 0 ; c-- )
  {
    d = ul >> c;

    if ( d & 1 )
    {
       binPhy[count] = '1';
       binPhy[count+1] = '0';
    }
    else
    {
       binPhy[count] = '0';
       binPhy[count+1] = '1';
    }
    
    count += 2;
  }
  binPhy[len*2] = '\n';
  return binPhy;
}

// debug statistics printout
void printStats(unsigned long loopCnt, unsigned long dataCnt)
{
  ilog("Loops: %d, Packets: %d", loopCnt, dataCnt);
}

// print decoded receiver data
void printPacketData(unsigned long data)
{
  ilog("Received: %s", dec2binStr(data));
//  ilog("ReceivedPhy: %s", dec2binPhyStr(data));
}

// receiver for home automation data
void dataReceiver(void)
{
  dlog("--- Wait for Pause and Sync ---");

start_over:  
  int i = 0;
  signed long t = 0;
  
  byte prevBit = 0;
  byte currBit = 0;
  
  // Packet data, logical structure
  unsigned long dataPacket = 0;

  loopCounter++;
  
  // Wait for Pause bit (10500 us).
  while ((t < pauseMinTime) || (t > pauseMaxTime))
  { 
    t = pulseIn(rxPin, LOW, timeout1);
  }
  tPause = t; // Save timing for debugging purposes
  if (t == 0)
  {
    dlog("!!! - Pause Timeout - Start over.");
    goto start_over;
  }

  // Wait for Sync bit (2750 us).
  while ((t < syncMinTime) || (t > syncMaxTime))
  { 
    t = pulseIn(rxPin, LOW, timeout1);
  }
  tSync = t; // Save timing for debugging purposes
  if (t == 0)
  {
    dlog("!!! - Sync Timeout - Start over.");
    goto start_over;
  }

  // data collection loop
  while (i < 64)
  {
    t = pulseIn(rxPin, LOW, timeout2);  // shorter timeout?
    if (t == 0)
    {
      dlog("!!! - Data Timeout - Start over.");
      goto start_over;
    }
    else if (t > zeroMinTime && t < zeroMaxTime)
    {
      currBit = 0;
    }
    else if (t > oneMinTime && t < oneMaxTime)
    { 
      currBit = 1;
    }
    else
    { 
      dlog("Incorrect data - Start over. t=%d", t);
      goto start_over;
    }

    if (i % 2 == 1)
    {
      if ((prevBit ^ currBit) == 0)
      { 
        // must be either 01 or 10, not allowed to be 00 or 11
        dlog("Bad data - Start over");
        goto start_over;
      }
  
      // Store packet bits
      dataPacket <<= 1;
      dataPacket |= prevBit;
     }
     prevBit = currBit;
     ++i;
   }
   if (i > 0)
   { 
     dataCounter++;
     printPacketData(dataPacket);
   }
}


void setup()
{ 
  pinMode(rxPin, INPUT);
  
  Serial.begin(9600);
  ilog("Home Automation Receiver");
}


void loop()
{
  dataReceiver();
}

Next, I shall try and make this into a library.

Review – Home Automation with Arduino

 DIY, Home Automation, Review  Comments Off on Review – Home Automation with Arduino
Nov 012014
 

This post is a review of a couple of eBooks I have received from Marco Schwartz, who runs the site over at Open Home Automation.

He has produced a series of books on the Open Source Home Automation theme. They are intended for anyone, from the complete beginner to the more experienced maker, who is interested in making a home automation system of their own.

I find the books very well structured, and easy to read and follow. Everything in the books are open source, and as such it is of course available on the internet. But these books do a very good job of putting it all together into a complete project structure.  They are very inspiring, and makes me want to start creating a project right away.

The complete series comprises:
* Introduction to Arduino
* Home Automation with Arduino
* Design Guide for Home Automation
* Internet of Things for Home Automation
* 3D Printing for Home Automation

Where the first book is for the complete beginner with breadboard projects. The rest of the books and  projects get more complex, but also more and more interresting.

You can find more info, and buy the books from here, http://www.openhomeautomation.net/home-automation-arduino/.

Micro Python

 DIY, Electronics, Python  Comments Off on Micro Python
May 182014
 

Received my Micro Python board on the 12th of May which is a Kickstarter project I supported back in November last year, https://www.kickstarter.com/projects/214379695/micro-python-python-for-microcontrollers.

I just backed the project as I thought it was an interesting idea to use python in an embedded product.
So far I haven't had time to play around with it much, but I am really looking forward to it.

Here is the official web site for the project, http://micropython.org/.

board and box

One thing I noticed though upon starting the device up is that, at least on my Ubuntu machine, I did not get the pop-up window of the pyboard drive as described in the tutorial, if I have the SD-card inserted. If the SD-card is inserted, the only thing I get is the USB drive of that card. Without the SD-card inserted, I get the pyboard drive with the files mentioned. So I will go on without the card for now.

The tutorial, http://micropython.org/doc/tut-contents, is really nice and easy to follow.

To get a micro python prompt to write instructions directly to the board do,

screen /dev/ttyACM0

This is what you get from the help() function on micro python interpreter.

>>> help()         
Welcome to Micro Python!

For online help please visit http://micropython.org/help/.

Quick overview of commands for the board:
  pyb.info()    -- print some general information
  pyb.gc()      -- run the garbage collector
  pyb.delay(n)  -- wait for n milliseconds
  pyb.Switch()  -- create a switch object
                   Switch methods: (), callback(f)
  pyb.LED(n)    -- create an LED object for LED n (n=1,2,3,4)
                   LED methods: on(), off(), toggle(), intensity()
  pyb.Pin(pin)  -- get a pin, eg pyb.Pin('X1')
  pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
                   Pin methods: init(..), value([v]), high(), low()
  pyb.ExtInt(pin, m, p, callback) -- create an external interrupt object
  pyb.ADC(pin)  -- make an analog object from a pin
                   ADC methods: read(), read_timed(buf, freq)
  pyb.DAC(port) -- make a DAC object
                   DAC methods: triangle(freq), write(n), write_timed(buf, freq)
  pyb.RTC()     -- make an RTC object; methods: datetime([val])
  pyb.rng()     -- get a 30-bit hardware random number
  pyb.Servo(n)  -- create Servo object for servo n (n=1,2,3,4)
                   Servo methods: calibration(..), angle([x, [t]]), speed([x, [t]])
  pyb.Accel()   -- create an Accelerometer object
                   Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()

Pins are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name
Pin IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD
Pin pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN
Additional serial bus objects: pyb.I2C(n), pyb.SPI(n), pyb.UART(n)

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board

For further help on a specific object, type help(obj)

To close the screen session do 'Ctrl + a' and 'Ctrl + d' in sequence.

As I said before, really looking forward to digging deeper into what I can do with this board.

Home Automation – RF Protocol, update.

 DIY, Electronics, Home Automation  Comments Off on Home Automation – RF Protocol, update.
May 012014
 

Since I wrote the posts on 'Home Automation RF Protocols for simple devices' back in 2012, I have received some questions and feedback, which I find very enjoyable. Unfortunately I have had to turn off the comment options, as I have also received a lot of spam. Still people who really want to, have managed to find my email address (in the 'About Me' page). Some of the questions was on devices which I haven't made the decoding of myself. This made me quite curious, so I went and bought some of these devices.

Now I have three different makers of simple devices, namely Proove from 'Kjell & Company', Anslut from 'Jula', and Nexa which is a wellknown brand not belonging to a special franchise but can be found almost anywhere.

Starting with the 'Anslut' devices, it is really similar to the Proove one when just looking at them. Here is a picture of the transmitters, with Proove to the left and Anslut to the right.

ProoveVsAnslutTransmitter

 

Opening the Anslut transmitter the PCB is also identical to Proove, but checking the IC, it was not the same as in my Proove transmitter.
This one was labeled,
TE89TP16N-
B932U0307#1
But after some searching on the internet it seems to be made by Holtek too.
I would imagine it is just another version of their '8-Bit OTP MCU with RF Transmitter' line-up of IC:s.
The Xtal is marked 13.560 MHz, which is 1/32nd of 433.92 MHz.

The pin-out of the IC is identical to the one on the Proove device

         -------
 Vcc  9-|       |-8 Vcc
     10-|       |-7
     11-|       |-6
 Vcc 12-|       |-5 SW4
 SW8 13-|       |-4 SW3
 SW7 14-|       |-3 SW2
 SW6 15-|       |-2 SW1
 SW5 16-|      o|-1 Dout
         -------

As everything is so similar between these devices, I strongly suspect the decoded data to also be very similar.
This time around I have a digital logic analyzer to decode the data transmitted on the Dout pin.

To my surprise I see a packet burst consisting of SIX packets, and not four as I saw last time. Of course this is most likely due to measurement tool limitations, as I used a USB oscilloscope last time, and it might not have had the bandwidth/capacity to capture all of the data. Anyway, this is what it looks like with the logic analyzer.

Anslut_SW1_Overview_DigiView

 

Zooming in a bit on the packet burst.

Anslut_SW1_Overview2_DigiView

Zooming in on one packet to decode bits.

Anslut_SW1_Packet_DigiView

Defining the pulses.
High 250 us, low about 2750 us  -> Sync
High 250 us, low about 1500 us. -> Zero (0)
High 250 us, low 250 us. -> One (1)
Last bit.
High 250 us, low 10500 us. -> Pause
A packet consist of, Sync + Data + Pause.

Decoding 'Data part' of a packet.

Bit
0        10        20        30        40        50           60
1234567890123456789012345678901234567890123456789012 34 56 7890 1234
--------------------------------------------------------------------
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT GG OO DDDD NNNN

Bits #01-52 -> TxCode (T)
Bits #53-54 -> Group (G)
Bits #55-56 -> On/Off (O)
Bits #57-60 -> ? Dimming/Channel ? (D)
Bits #61-64 -> Device Nbr (N)

As every other bit sent over the air is redundant, it is the inverse of the previous bit, the packet consist of 32 logical bits

Going back to my Proove tranmitter, and hooking it up to the digital logic analyzer, it also shows a packet burst consisting of six packets. All of the decoding is the same as for the Anslut device.
Defining the pulses.
High 250 us, low about 2500 us  -> Sync
High 250 us, low about 1250 us. -> Zero (0)
High 250 us, low 250 us. -> One (1)
High 250 us, low 10000 us. -> Pause

Time to check the Nexa device. Note this is the simple version, and cheap, of their devices.

First I open up the transmitter, and can immediately see that it is completely different to the other ones.

DSC_0310

This is how the other side of the pcb looks like.

DSC_0312

The component on the frontside marked 'H R4334' at position SAW101, is a SAW filter with three pins.
1 - Input
2 - Output
3 - GND

Debuging the IC, which has no markings on it, on the backside gives.

     ________
 5 -|        |- 4 
 6 -|        |- 3 
 7 -|        |- 2 
 8 -|       o|- 1
     --------	

Using the oscilloscope to have a look at the signals.	 
Pin:
1 - 3.8 V
2 - Dout, Pulse train when pressing button
3 - 
4 - 3.8 V noisy
5 - < 1 V rippled
6 - same as 5
7 - same as 5
8 - GND

So, we seem to have a Dout pin here too. Time to hook up that analyzer again.

This is what a packet burst looks like. Note, only five packets in the burst.
Nexa_on1_Overview_DigiView

Zooming in a bit on that burst.

Nexa_On1_Overview2_DigiView

Finally here is how a packet looks like.

Nexa_On1_Packet_DigiView

Data part time decoded:
High 250 us, low 2750 us -> Sync
High 250 us, low 250 us -> one
High 250 us, low 1250 us -> zero
High 250 us, low 10000 us -> Pause

This is exactly the same as the Proove device timing, and as expected the data part of the packet is also the same as the Anslut and Proove devices.

With this new knowledge, I have decided to update/change my 'Home Automation, RF Protocols' page to reflect my new findings, and to only have device data which I have decoded myself.

I have also updated the Arduino library that I made some years ago. Since there are some differencies between Proove/Anslut and Nexa, such as the channel code and the way to number unit 1 to 3, I made two librabries: Proove/Anslut and Nexa.

Branching strategy

 Git, Software  Comments Off on Branching strategy
May 012014
 

This is my branching strategy, which should work well for any development from a single developer to a small team.
The goal for the strategy is to minimize branching, and administrative tasks.
For large team development a completetly different approach is needed.

Here is the strategy described in words:
* Use Master branch as development branch.
* When it is time for a release,
- tag the commit, ex v1.0
- create a branch, ex v1.0
* Continue development on Master branch
* Make corrections/fixes for v1.0 release on branch 1.0
* Merge fixes back to development/master branch (if needed)

Some ascii art to show the workflow

 tag     1.0                             1.1
 ---------*------------------*------------*------------------*-------> Master
           \                /              \                /
            \              /                \ v1.1         /v1.1.1
             \ v1.0       / v1.0.1           -------------*------> 1.1
              -----------*-------> 1.0

Here is a small example

git init
echo "some text" > a.txt
git add a.txt
git commit
echo "some more text" > a.txt
git commit -a
git tag -a v1.0 -m 'version 1.0'
git branch v1.0
git checkout v1.0
echo "third row of text, on new branch" > a.txt
git commit -a
git checkout master
echo "third row of text on master branch" > a.txt
git commit -a
git merge 681d9911379f4bed16903c876b72243e3de7d4dd
git log --graph --pretty=oneline --abbrev-commit

The resulting git tree.

* 0ffb123 Merge commit '681d9911379f4bed16903c876b72243e3de7d4dd'
|\
| * 681d991 Text added on v1.0 branch
* | 5c8800b Third row of text on master branch
|/
* 0496fc8 Added a second row of text to a.txt
* f5251a8 Initial commit, adding file a.txt

Arduino with Relay module

 Arduino, DIY, Electronics  Comments Off on Arduino with Relay module
Nov 022013
 

Got myself a relay module the other day, as I wanted to use an actuator, and the current supplied from the Arduino itself was not enough to make it work.

This is what I got, http://www.kjell.com/sortiment/el/elektronik/mikrokontroller/arduino/relamodul-for-arduino-p87878.

Here is how I connected the 'Songle SRD-05VDC-SL-C' relay with an actuator to an Arduino.

The pin marked:
'+'  connected to 5V from Arduino
'- ' connected to GND from Arduino
'S' connected to GPIO#2 from Arduino

In the other end connect the middle connector ('Common') to an external voltage source,
in my case 5V, as the actuator was a 5V actuator. The NO ('Normally Open') connector is strapped to one of the actuators input. The NC ('Normally Closed') connector is not used. The other actuator pin is connected to the external power sources GND completing the circuit.

When the GPIO#2 is put high, the external 5V source is fed to the actuator, making it move.
So the only thing you need in your Arduino sketch is 'digitalWrite' of the proper GPIO.
It took me some time to figure the relay out, since I watched some instruction on the internet on how to connect a relay, and all of them used some external diodes and transistors.
But that is not necessary with this one, as it is already mounted on the PCB of the relay module.

ASCII art of the setup:

---------
        |
Arduino |      -----------------
        |      |               |
        |      |     Relay     | 
   5V  --- + --|               |-- NC
        |      |     module    |
   GND --- - --|               |-- Common ---------------- 5V external src
        |      |               | 
GPIO#2 --- S --|               |-- NO -----|
        |      |               |           |       ------- GND external src
        |      |               |           |       |
        |      -----------------           |       |
---------                                  |       |
                                           |       |
                                         --------------
                                         |            |
                                       ==|  Actuator  |=====|
                                         |            |
                                         --------------

Link:
The vendor data sheet of the module, http://www.songle.com/en/pdf/20084141716341001.pdf

Raspberry Pi – Finally arrived

 Raspberry Pi  Comments Off on Raspberry Pi – Finally arrived
Jun 282012
 

Found a parcel in the mail yesterday when I got home from work.
The first text I read was T-shirt, and I wondered what this was. I had not ordered any T-shirt.
But then I read the complete sentence, 'dev-kit and T-shirt'.
At last, my Raspberry Pi had arrived!

It was some time ago since I signed up as interested to get one, and I haven't thought much about it since.
But now I need to get the peripherals needed, keyboard, mouse, SD card.
With that all taken care of today after work, I downloaded the Debian squeeze distro and put it on the card.
Hooking up the board to the TV, it was just to add power and it booted up nicely.

Entering login and password without any problem, and I was all set. Starting gui with startx, and I got this nice desktop!

That's it. All set to go...