Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

20 May, 2017

GY-MCU90614-BCC Serial IR Non-contact Module: Python code

It seems that this variant of the module, with serial interface, is not that popular or at least I could not find code that I can easily port to Raspberry Pi. One can find a Windows program that prints the values from the serial port but that is all.
Anyway, I found description of the protocol on several pages, and it looked doable. Later, I found an Arduino example code, which could have helped, but...  I start programming before I had the module, which explains the reason why I first convert the characters to hex and then decode... This way is easier to debug it... So, here is the Python code (at the end of the post) that tests the checksum, decodes and prints the values to the standard output. (by the way, I still do not know how to get negative values for the temperature...)

Example output:
$ ./IRserial.py
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08

07 February, 2015

Raspberry Pi 2: tigervnc - the easy way

For a long time I wanted to use a Raspberry Pi (RPi) as a VNC client to my linux machines. The first RPi was a bit too slow for all the tests I have done, so I simply gave up on it.

With the new version, I thought this might work... Unfortunately, the VNC clients packed with the Raspbian image repositories are performing poorly, with one exception - ssvnc (after some tweaking), but the programs last update was in 2011... and I want to change F8 to something else...

Then, here is the long story short.

I remembered that Thinlinc is using TigerVNC in their product and they have ARMv7 hard-fload version on their download page: https://www.cendio.com/thinlinc/download . I have downloaded the Linux Dynamic package for this purpose. After extracting the package, one simply needs to run this binary:


tl-4.3.0-4538-client-linux-dynamic-armhf/lib/tlclient/vncviewer

Enjoy!
Thanks to the ThinLinc team.

Update 2015.03.27: RealVNC binaries for Raspberry PI can be downloaded from the software developer's page http://www.realvnc.com/download/viewer/

28 October, 2013

Home automation: second round

Some time ago I briefly mentioned here the main concepts behind the project. Nothing has changed dramatically, except that I realized that my SMSgate solution was outdated. The phone battery was seriously deteriorated and I also realized that it is not that easy to just replace the phone anymore.

Well, I had an old Android phone (HTC Wildfire) that was essentially lying unused for quite some time. There is not so much that one can do with this old phone... but it turned out it works just perfectly to send and receive SMS and much more.

If you are in the "business" of home automation and you have Android device, Tasker is a MUST HAVE! To send and receive SMS messages I use SMS Gateway (I could not find an easy way to send SMS from external device via Tasker).


Briefly: I have changed the original python code to send SMS via SMS Gateway via HTTP GET request from RPi and then I have slightly modified the example, so I can control stuff by SMS. It is very clean and simple solution.

Now, since I have web server on which I get the notifications from the SMS Gateway I can simply use the same code to handle events from Tasker! This is how I get notifications on call - piece of cake. I have added, at the end of the post, an example how to switch on/off device 2 via tdtool.

24 June, 2013

Home automation: Raspberry Pi + Tellstick Duo ++

There are many sites that has this project in many flavors... I will just add mine.

Brief summary: Tellstick Duo is connected to Rasberry Pi (running Raspbian).  I have SE K700i GSM phone connected to RPi as well. The main features are:
  • control several radio controlled switches (Anslut)
  • monitor temperature and humidity from my wireless weather station
  • monitor for "door open event" (NEXA LMST-606)
  • monitor for commands send by SMS (gammu) Update: replaced by Android SMS Gateway. Read more...
  • report on selected events by sending SMS to predefined phone number (gammu)
  • simple web interface to control some of the features (apache + php)
  • events are logged locally in to a file and to a remote server (own twitter like)
To install telldus-core follow this guide. One can compile the GUI for RPi or use it on another computer to set the codes. I wanted to be able to repeat the original codes from the remote controls. Advanced users can use code from the examples to "learn" the codes.

Essentially, I am running a monitoring program written in python (took one of the provided examples and changed it severely). It catches signals from the remote controls and could trigger an action. In other words, I can use the remote controls to send signals to RPi. The same program monitors the GSM. It could trigger an action upon CALL or SMS. The signal from the door is logged by default but could also send an SMS - poor man's home security alarm.

I particularly like the CALL feature since you do not need to answer the call, so no cost attached. The downside is that there is only one action hooked to this event. SMS is easier but will cost you (or not - depends on the plan you have). When SMS is received from another phone (not mine) the SMS is logged and forwarded to my phone.

21 December, 2010

MobaXterm: free X server for Windows

I work under Linux and Windows on a daily base, so from quite some time I was looking for simple, free and reliable X server for Windows. Just to mention that I have tried several solutions before: X server under Cygwin, Xming, and some commercial software as well.

Cygwin: I have tried that solution long time ago, perhaps now it is way better. At that time, it was quite slow, heavy and not that simple for occasional purposes.

Xming: That is in principle what I need. It works... almost... I have problems running it under limited user account, I heard about problems under Vista, as well...

As result, I kept using alternative ways to avoid using X. Usually, as awkward as: NoMachine (or VNC over SSH) to Linux machine at work, then to the target Linux machine... This solution is still acceptable for occasional use, since I have already everything setup to connect at work. Of course, this "solution" is very inconvenient for occasional use to a regular Linux machine.

Anyway, today (yes, it is only one day and I am already excited) I have found another free software that completely fits my need!!! MobaXterm. It has embedded all the tools one needs and some extra in a single PORTABLE file of 13 MB! No installation (well there is such possibility if you insist) - just run and enjoy. You get more than what you can expect. 
  • X server - you can turn it on/off interactively
  • Simple file transfer - very neat
  • Remote XDMCP session - certainly handy
  • Local applications: mc, wget, vim, ssh - just to mentions some...
  • rsync - this one is just a jewel (providing that ssh environment is available)
  • Many more, not that important... I keep exploring...
Exactly what I want. I can't imagine what could be better... Do you?

08 January, 2010

Windows to Linux file synchronization over ssh: Dokan solution

Apparently, the Unison solution that I have posted before was not very good solution after all...

Well, it worked well as expected, just it was always very slow to index the files (well, i wanted to be safe so I am using "fastcheck = no" setting) and the file transfer was very slow as well... Probably, I should not blame Unison for that but... Anyway, here is one more solution that is more than "file synchronizations"...! Well, what about free Windows SSHFS?! Here it is - Dokan!

That simplifies everything. After installing the libraries and the SSHFS part you will be able to mount any remote folder with ssh access without any need of any additional software on the remote host (well, running ssh server is a prerequisite).

There is nothing more I need to say. You will simply have the remote folder mapped/mounted as a local drive to your Windows computer (you can select the drive letter). Then you can use any regular file synchronization software...

Note: ExpanDrive (former SftpDrive) is the shareware solution to map remote folder with ssh access.

22 November, 2009

Windows to Linux file synchronization over ssh: Unison solution

The aim: Portable and simple solution (no administrative right required on both sides) to synchronize files from Windows to Linux machine over insecure network (trough ssh) using Unison (ie. using only freeware software).
The problems: There is no ssh command line client in Windows.

Here are the important details:
I have used Unison (version 2.32.52), runtime GTK+ 2.14.7a environment from the Pidgin project (as described on the unison's page), plink.exe (version 0.60) and small script to point unison's sshcmd to plink.exe.

1) Create a new folder and unpack the two executable from Unison ("Unison" in my case).

2) As user install GTK somewhere.
- add the c:\somewhere\GTK\2.0\bin to the PATH variable in the system settings.
- or copy all files from \GTK\2.0\bin to the Unison folder. Then copy the whole (not the content) "etc", "lib" and "share" folders as well in the same folder.
3) Download and copy plink.exe in the "Unison" folder.

4) In notepad copy paste the following line
@c:\pathtoputty\plink.exe -ssh -P 22 -pw [mypassword] -l [myusername] -load [myputtysavedsession] "unison -server -auto"
change to fit your configuration and save it as "plinker.bat" in the "Unison" folder.
If you use pagent from the PuTTY then you can omit the username and password and use ssh-keys as usual (then also your password will be safe)

5) On the linux computer download or install unison. It will be good if you match the version on the Windows machine or vice versa. If you download the static binary, put it somewhere in your $PATH.

6) Start the Unison Gui version and configure your profile. This will fail, because ssh is not specified. Go to C:\Documents and Settings\yourprofile\.unison and add this line to the profile you have created.
sshcmd = plinker.bat
This and the GTK assumes that you have started Unison from its folder.

6) Start again - this time it should work. Enjoy.

Note: In point 4 you might need to provide the full path to the unison binary on the Linux machine.
Note: Since the configuration for the server address is actually specified in "plinker.bat" (it actually overrides the address specified in unison) you will need another script to connect to another server.

The original idea for the plinker.bat script is taken from here.

08 November, 2009

GlobalSat BU-353 gps receiver

Product details on the vendor's web page.

Well, this is my first experience with GPS receivers, so I am not in a position to compare performance with any other receiver. The general opinion, from the countless reviews in the Net, is that is very sensitive and fast to fix the position.

My intention is to use the receiver with my Eee PC 901 in the rare occasions when I need a GPS navigator or rather as a small home project.

First impressions: smaller than what I was expecting from the pictures, reasonable length of the cable (1.5 m), time to fix from cold start 15~20 minutes from inside the room in my apartment and about 4~5 minutes in a car.
Under Windows XP the initial setup is quite simple. There is a small standard tool provided on the installation disk "GPS Info" that can connect to the virtual serial COM port and communicate with the receiver - excellent to check on the status of the module.
Under Linux, most probably you will need "gpsd" to communicate with the device. I have installed "GPSDrive" from synaptic that has also pulled all the necessary dependencies including gpsd.

WARNING:(read this before you experiment yourself). I have used EeeBuntu 2.0 that has the necessary modules but for one or another reason does not starts the gpsd daemon when you insert the USB. This is not a serious problem, since as user one can easily start the program with: gpsd -bnN -D 2 /dev/ttyUSB0 . DO NOT forget the "-b" OPTION!!! From the gpsd man page

-b

Broken-device-safety, otherwise known as read-only mode. Some popular bluetooth and USB receivers lock up or become totally inaccessible when probed or reconfigured. This switch prevents gpsd from writing to a receiver. This means that gpsd cannot configure the receiver for optimal performance, but it also means that gpsd cannot break the receiver. A better solution would be for bluetooth to not be so fragile. A platform independent method to identify serial-over-bluetooth devices would also be nice.

And this is the whole story... I have managed to lock my device the very first time I have tested it under Linux (didn't use the "-b" option). It became almost inaccessible. "GPS Info" was showing garbled output while the led remained off. I have almost accepted the damage since 5 minutes without power did not help. A suggestion on the net says that it needs 72 hours to drain completely and reset. The better solution: Under Linux, start gsmd with the "-b" option. Then connect to the the daemon by "telnet localhost 2947" and then type "n=0" to set the sirf-III chip or firmware to output NMEA strings only. Here is the original post of the solution.

The common tools, to get some info from the GPS receiver under Linux are:

xgps: simple test client for gpsd with an X interface. It displays current GPS position/time/velocity information and (for GPSes that support the feature) the locations of accessible satellites.

cgps: client resembling xgps, but without the pictorial satellite display and able to run on a serial terminal or terminal emulator.

as well as xgpsspeed, gpxlogger, cgpxlogger etc.

05 July, 2009

Eee PC 901, 12GB SSD, Windows XP

General considerations:
For those that own such configuration it is well know that the computer can't survive long without serious intervention of the original set up. The computer comes preconfigured with WinXP SP3 without hibernation and paging (virtual memory) but the space left on the C: drive is not enough even for the Windows updates that inevitably should be applied. A "must do" action to save you laptop is to clean and free some valuable space: read this sticky post on the EeeUser forum How to clean up space on your C: drive in Windows XP. Without most of these tasks, your computer is useless.

BIOS:
I am still running the original BIOS version 1101 and I don't have any particular problems except the uneven brightness levels that does not bug me enough.

28 April, 2008

GRT815M - Ubuntu 8.04 (Hardy Heron)

In general the distribution works out of the box. Just a few hints to make your life easier and your computer running smoother.

1. To disable the annoying BIOS bug at the boot screen, add noapic in /boot/grub/menu.lst (leave the # sign intact)
# defoptions=quiet splash noapic
you can add vga=791 to the same line to get nicer text console and then run update-grub to apply the changes.

2. To get your the NVidia drivers running properly (almost) edit the following files:
/etc/modprobe.d/blacklist: add these two lines
blacklist agpgart
blacklist sis_agp
/etc/modprobe.d/nvidia-kernel-nkc: add these two lines (the second is just in case)
options nvidia_new  NVreg_EnableAGPFW=1 NVreg_EnableAGPSBA=1
options nvidia NVreg_EnableAGPFW=1 NVreg_EnableAGPSBA=1
Restart the computer to give up on sis_agp module, then you will get the following result:
cat /proc/driver/nvidia/agp/status
Status:          Enabled
Driver: NVIDIA
AGP Rate: 8x
Fast Writes: Enabled
SBA: Enabled

3. If you want to be able to throttle your CPU, replace powerd with cpufreqd (cpufrequtils) then add p4_clockmod option module in /etc/default/cpufreqd:
CPUFREQ_CPU_MODULE="p4_clockmod"
Comment the line "#MODULE=speedstep-ich;" and add new "MODULE=p4-clockmod;" in /etc/init.d/loadcpufreq
    # Right. Check if it's a P4 without est.
# Could be speedstep-ich, or could be p4-clockmod.
#MODULE=speedstep-ich;
MODULE=p4-clockmod;
# Disabled for now - the latency tends to be bad
# enough to make it fairly pointless.
To be able to alter the frequencies I have made this change in /etc/cpufreqd.conf
[Profile]
name=Performance High
minfreq=20%
maxfreq=100%
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]

Restart the daemon.
sudo /etc/init.d/cpufreqd restart
You can add the "CPU scaling monitor" applet to the Gnome panel but to be able to use it as user run the following command:
sudo chmod +s /usr/bin/cpufreq-selector

Alternatively, use the following commands to alter the parameters: cpufreq-info, cpufreq-selector, cpufreq-set. I was not able to find convenient GUI tool that will do it from the tray but hey - it works.

4. If you find your hard disk clicking - here are some setting to alter to solve the problem.
/etc/hdparm.conf: set ROOTFS = /dev/sda and add these lines at the end of the file.
/dev/sda {
apm = 254
}
/etc/apm/event.d/20hdparm: uncomment the line #APMD_DRIVES=
APMD_DRIVES=

Here is a table of VESA video modes (VGA codes):
         640x480   800x600   1024x768   1280x1024   1600x1200   Ask user at boot.
8 bits vga=769 vga=771 vga=773 vga=775 vga=796 vga=ask
16 bits vga=785 vga=788 vga=791 vga=794 vga=798 vga=ask
32 bits vga=786 vga=789 vga=792 vga=795 vga=799 vga=ask


If you know how to make the computer SUSPEND - please let me know.

06 January, 2007

GRT-815M - Linux

Note: For some reason Google Search often links to this post that is not the most appropriate one. To find better suggestion use the blog search function.
Suse 9.0: (2004-2005)
An ancient distribution nowadays. nVidia drivers were not included, difficulties to mount USB drives etc.

Debian (Sarge): (2005-2006)
It was quite an improvement compared to the previous Suse 9.0 but didn't work with my PCMCIA wireless.

Gentoo: (2 days)
I use KDE. After 5 hours of compilation (kernel and kdebase) I tried to compile k3b - it was not enough so it asked for more - got a format... The installer was not clever enough to configure GRUB to coop with my Windows... took me me lot of nerves to find out the reason and fix it.

Kubuntu 6.06 (Dapper): (2006 - )
It is a pleasure to install and work with this distribution. There was a problem installing from the LiveCD desktop edition so I have done it from the text based alternate edition. Later 6.06.1 version probably fixes that issue. In both cases the initial hardware recognition reports that the BIOS has a well known bug! The guys implementing the KDE have managed to screw up the upgrading capability of this version so... I am stuck with t 6.06 for now.

nVidia drivers are included as restricted modules. Kernel updates are almost flawless. I have 386 & 686 kernels as options. Minor upgrades replaces the old kernels, but in case of major changes you get the new kernel while keeping the old intact and still functional!

USB mass storage works fine - it doesn't sync properly but I can live with it. Wireless is OK. Latest Skype 1.3.053 works excellent with the arts daemon.

You can control the brightness of the screen from KDE - there is a module for SONY laptops that works fine with the model. Volume and brightness buttons are not recognized (not bounded to any events - i did not bother to fix it since I don't use it that often). The special function keys are misaligned and not fully functional but better that any previous distribution.

If you change to powersaved daemon you will be able to change manually the performance profiles from the system tray where the battery information appears or automatically depending on the situation AC/battery power supply. You can even play with the HDD performance - if you have time to waste playing with the config files.

I have never managed to properly suspend or hibernate the computer (nVidia causes enough troubles). There are long guides how to shut down some services and restart them later, but if the only way to hibernate or suspend is to exit the X server (because of the nVidia) - I will rather turn off the computer. I have never found a way to switch or bring the signal to the external monitor after the X server is started (nVidia drivers and tools related problems).

Knoppix:
There was a problem with the version prior 3.5 that one must disable the ACPI support. Latest version 5.0.1 works like a charm - network, hot plugs... The DVD drive is not the fastest and it takes some time to boot and run programs. I have tried poor's man installation by copying the KNOPPIX folder on some of the partitions on the hard disk or on an external USB disk and then it flies. The internal HDD is not that fast so the option on the external USB works faster. The images for the DVD version are splited on files up to 2GB (it is actually DVD iso format restriction) so you can easily "install" it on FAT32. You can go further and copy the kernel files and put a option in the GRUB menu and then you can boot even without the CD/DVD. Having the Knoppix image on the disk is not only faster to run but you get your DVD device free for whatever reason you will need it.


Using GRUB to boot Knoppix images.

(I don't take any responsibility for any damage or etc. that your attempts might cause)
First copy the contents of /boot of the Knoppix CD-ROM to a boot partition on your hard drive, for example "/boot.knoppix". This partition may be ext2/3, reiserfs or even a vfat partition, all of which are supported by grub.

Copy the /KNOPPIX directory from the Knoppix CD-ROM to the top level (root, "/") directory of the file system on any hard disk or partition on your system.

Add and change accordingly the following to your /boot/grub/menu.lst :

title KNOPPIX 3.7 kernel 2.4
root (hd0,1)
kernel /boot/knoppix37/linux24 ramdisk_size=100000 apm=power-off vga=791 from=/dev/hda6 lang=us keyboard=us home=scan
initrd /boot/knoppix37/minirt24.gz


Note: The parameter "fromhd=" is used to specify the disk location of the file system where you previously copied the /KNOPPIX directory.