Thursday, 5 September 2013

Programming ATTiny45 using an Arduino Uno

Wiring of the Programmer
The Arduino is programmed using the Arduino IDE and USB with the ArduinoISP sketch from the File Menu located in examples. Remember to choose the correct board and Serial port from the Tools menu, I was using an Uno. You have to set up the Arduino software to be able to program devices like the ATTiny45, I used the http://hlt.media.mit.edu/?p=1695 site to add the support. It was then just a matter of wiring up the Arduino as shown, putting an ATTiny45 in the 8 pin socket selecting the new board ATTiny45 (Internal 1MHz Clock) and programming the device with a sketch I wrote for this particular device.

Wednesday, 4 September 2013

Wi-Spy DBx2 USB Repair

Be careful when soldering and wear eye protection. I am not responsible for any omissions or errors on this Blog YMMV.

Broken USB Connector


The USB connector had been ripped off the board ( it wasn't me :) ) so I cleaned and removed the broken lugs from the PCB. I also cleaned the PCB pads left on the USB connector.
Pulled Out Contact
I straightened one of the contacts that had been pulled out of the connector and pushed it back in. I then Fast-Set Epoxied the connector to the PCB and clamped it using a sprung plastic clamp until the glue cured. I then soldered the ground connection and the remaining connections using thin tinned copper wire to bridge the ripped up tracks on the PCB. I finally soldered the corners of the connector to the PCB lug holes to provide extra mechanical strength to the assembly.
Connections Soldered
Proof it Works!
Job Done :).

Thursday, 4 April 2013

Raspberry PI Enterprise Wifi

The dongle I used was the Farnell WiPi this was identified by the PI using
the command lsusb as a
Bus 001 Device 005: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

I put the required certificate in the /etc/cert directory.
The wpa_supplicant.conf file was edited as follows:-
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ctrl_interface_group=root
update_config=1
network={
ssid="myAP"
key_mgmt=WPA-EAP
eap=PEAP
identity="myuser"
password="mypassword"
ca_cert="/etc/cert/cacert.crt"
phase2="auth=MSCHAPV2"
priority=0
}

The file /etc/network/interfaces was edited as follows :-
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant.conf
iface default inet dhcp
gateway 192.168.1.1
up route add default gw 192.168.1.1

Raspberry PI Kiosk

Do the usual things after installing an image on the SD card and booting the Pi
for the first time run
sudo raspi-config
then set boot desktop in boot_behaviour

sudo apt-get install chromium x11-xserver-utils unclutter

Edit /etc/xdg/lxsession/LXDE/autostart file and comment out screensaver line, add lines below
@xset s off
@xset -dpms
@xset s noblank
@chromium --kiosk --incognito http://www.google.com # your URL here



Monday, 25 March 2013

Repairing a Windows Installation After Installing a New Motherboard.


The usual warnings about backing up data before you proceed apply here, you have been warned.

I needed to do this after the motherboard's hard drive controller died and I didn't just want to do a re-install and lose all my settings and accounts with a motherboard change, I did have a backup but I wanted a challenge. I rebooted with the new motherboard installed and just got the BOD then a restart. The Windows recovery came up during this reboot but in the end it said the installation couldn't be recovered.

Most of the forums I came across recommended a re-install, this I thought was a bit defeatist so a bit more research came up with a useful article:-
How To Repair a Windows Install After Replacing Motherboard
I followed this pages description and got the drivers I needed for my new motherboard. I put them on a USB memory stick then booted the new machine with the Windows 7 install DVD as described in the article, the important command is :-
dism /image:d:\ /add-driver /Driver:f:\ /recurse
This copies the various drivers for the new motherboard chipset, vga, harddrive controller and audio etc from the USB memory stick to the Windows installation on the hard drive. This means when Windows restarts it'll have all the correct drivers for the new motherboard. It did reboot and appeared to work, no BOD, it rebooted again after the initial boot. Fantastic it only took about half a hour and it works flawlessly.

Update:You may need to re-validate your copy of Windows with Microsoft as the hardware has changed significantly. I had to use Microsoft's automated UK 0800 telephone re-validation system, this was pretty painless, just enter a few blocks of numbers provided by your installation via the phone keypad. You then enter the automated-voice blocks of numbers returned by Microsoft's system into the blank boxes on your installation. All legal again :).
Thanks for reading. Best Wishes.

.........

Monday, 19 November 2012

Improving My ADSL2+ Connection Speed

I used a Netgear DG843GT Modem/Router that I purchased on eBay for £12 delivered. It had a faulty swollen power supply capacitor on the Broadcom modem chip area of the printed circuit board, this I replaced, it was a 1000uF at 6.3V electrolytic capacitor. I flashed the modem/router with DGTeam Firmware Mirror. I didn't like the new firmware's logos at the top of the DG843GT Web interface so I just blocked this frame in my browser to remove it from view :).
This firmware allows you to reduce the noise margin via the routers web interface and command line. I first logged the modems varying ADSL2+ snr over a period of about a week from a Raspberry Pi using a shell script (shown below) to Xively. See the Xively tutorial for more information. The Xively data format is detailed here. The reason I wanted to record the data was to get a feel for the actual noise conditions on my telephone line over a period of time and to see what I was going to be up against.

The Xively internet of everything concept takes a bit of understanding , I'm not sure I fully understand it yet. My attempt to describe it here is that a feed is a location on Xively for your device to record its many data channels also known as datastreams. These channels can be various outputs from sensors on the device or data gleaned from the device itself. In this case I'm screen scraping the Modem/Router's browser based status page to get the SNR and Download speed values. I'm doing this using a few shell scripts running that loop every 5 minutes on a Raspberry PI a low power Linux device that runs 24-7.

To do this yourself you need to signup with Xively to create your own account and password. After this you then create a feed for your DG843GT with two channels one called SNR (Signal to Noise Ratio) measured in dB (decibels) and the other is speed the download speed measured in kbps (kilo Bits Per Second).

As part of the account set up process a Product ID , Product Secret , Serial Number and Activation Code is created as is a Feed ID ,
Feed URL in the form :-
https://xively.com/feeds/***Feed_Number***
and an API endpoint URL of the form :-
https://api.xively.com/v2/feeds/***Feed_Number***
An auto-generated device key for your ***Feed Number*** is also created to allow secure uploading of the readings from your remote device.

The script RouterCall.sh uses a command wget to automatically log in to the DG834GT Modem/Router and download the stattbl.htm page. This page is then scraped using various cut commands to get the value into variables within the script which are then packaged up into a data.json file that is uploaded to Xively by running the cosm.sh script. The cosm script has the feed details and associated security key along with the reference to the data.json data file.
The annotations on the screenshot images are as follows #1 is the API endpoint #2 is the device key for the feed number.

Screenshot of the Device Feed

The following image is of the cosm script and shows #1 the API feed endpoint URL and  #2 is the device key for the feed , this shows hopefully how they are linked.


cosm,sh


Note the area of the graph below showing off scale and a flat line is where I was playing around with the Router. From the graph below one can see that before the noise margin reduction it was around 10dB, and you can see the reduction at night time due to interference from MW radio stations etc reducing the noise margin. You can also see where I reduce the noise margin down to the target 6dB, this is where my download speed increased from 5Mbps up to 7.4Mbps, what a result :).

The connection has been rock solid for over a week with no line re-sync and a very low crc much in line with what I experienced with the higher noise margin and a lower speed.



Shell Script RouterCall.sh
# This script uses another script cosm.sh to send data to the Cosm Website
# Note you have to create an account yourself and use this id for your script
#!/bin/sh
while [ true ]
do
# Create my data files
touch noise.txt speed.txt data.txt
# Get content of Stats Page from Router
wget --http-user=admin --http-passwd='********' http://192.168.1.1/stattbl.htm
# Get data into files
cat stattbl.htm | grep kbps | cut -d\> -f3 | cut -dk -f1 | head -1 > speed.txt
cat stattbl.htm | grep db | cut -d\> -f3 | cut -d\< -f1 | cut -dk -f1 | tail -2 | head -1 > noise.txt
# Load Variable list with contents of speed.txt
noise=`cat noise.txt`
speed=`cat speed.txt`
# Send data to Cosm by creating a json file containing the data
echo -e {\"version\":\"1.0.0\",\"datastreams\": [\{\"id\":\"ADSL\",\"current_value\":\"$noise\"\},\{\"id\":\"speed\",\"current_value\":\"$speed\"\}]\} > data.json
# Run other Shell script
cosm.sh
# Remove the created files to renew them next time
rm noise.txt data.txt speed.txt data.json stattbl.htm
# Wait for 5 minutes before looping again
sleep 300
done

Shell Script cosm.sh
# Script to send Data to your Cosm feed page
#!/bin/sh
curl --request PUT --data-binary @data.json --header "X-ApiKey: ***********You use your Key Here************" --verbose http://api.cosm.com/v2/feeds/***Your Feed Number Here*******

Update: I have managed a consistent 8.227Mbps by reducing the noise margin to around 3dB, it is also a rock solid connection and is much better than my old Zyxel P-660HW T1 V2 at around 4Mbps, it also used to restart for no reason even when it was brand new.

Further Update: I have now managed a consistent 9.139Mbps by further reducing the noise margin to around 2.4dB, it is still a solid connection. It was up at 9.9Mbps but this was not stable so it was reduced. These changes were made in the summer when static and atmospheric noise is at its highest on the frequencies used by ADSL2 so fingers crossed that it stays this way :).

Even Further Update
My broadband started playing up around the 1st of April 2014 and it took BT Openreach about 2 weeks to fix it, I am still trying to get a refund. I was effectively without broadband during this time due to excessive noise on my telephone line, it was very crackly like static on a radio. I did however use a 3G USB Dongle for my broadband over this time. My SNR logging came to the rescue as I could see exactly when it happened and what was occurring on the line. See my image of the the SNR below.

My system is now back but it is now only running around 3Mbps which is pretty rubbish. My line still has to go through a learning process so the equipment at the telephone exchange can eventually see the line is no longer noisy and so should allow higher speeds hopefully. 


 Even Further Further Update

After over a full month of mediocre/sometimes non existent broadband I have finally got the speed I think I should. I contacted them on two separate occasions saying I had been capped since the fault at 3Mbps even after BT saying the cap had been removed. I told them I had the evidence for the cap not being removed when even after a router reset the speed was always 3Mbps +- a few kbps. This morning I was contacted by BT to say the cap had not indeed been removed but that it was now and could I restart the router. This I did, the speed immediately went to 10Mbps download and 1Mbps upload, thanks goodness, fingers crossed that it stays this way. Images of the broadband speed and SNR are shown below.





New Router Installed
My old Netgear DG834GT started to disconnect at random, so I purchased a Billion 7800DXL modem router to replace it. This was installed and no tweaking of the SNR was necessary, I am getting a reliable 9.2Mbps download and 1.0Mbps upload so a good result. The added benefit of this is that this router has dual band wifi and 1Gbit ethernet ports so file transfers to and from my NAS which is also 1Gbit on the home network is pretty rapid.

References Used: With grateful thanks


Making a datalogger for a Kamstrup electricity / gas meter with Raspberry Pi!


Duncan Jauncey's Blog



Wednesday, 10 October 2012

APC UPS Serial Port Setup

Setup Serial Port
I use Ubuntu 12.04 LTS 64bit and install apcupsd using the command:-
sudo apt-get install apcupsd 

I edited the file /etc/default/apcupsd and changed the entry  
ISCONFIGURED=NO to ISCONFIGURED=YES

I found out the USB dongle serial port used by issuing the command dmesg | grep ttyUSB in my case it was /dev/ttyUSB2. This was added to the config file  /etc/apcupsd/apcupsd.conf file

DEVICE /dev/ttyUSB2 
UPSTYPE apcsmart

I then issued the command sudo apctest this allowed me to run a battery calibration test.

Defender 300tdi Lucas 10AS Alarm Immobiliser (Spider) Problems

We have a 1997 Landrover Defender 300tdi that has given immobiliser problems intermittently. I had initially fixed the fuel solenoid as we w...