Sunday, September 9, 2012

Samba

To install samba type command:
         sudo apt-get install samba samba-common-bin

Create a folder you want to share:
        sudo mkdir /remote_disk

To change the owner of the directory(in this case set owner and the group to be pi):
       sudo chown pi:pi /remote_disk

Add following lines in  /etc/samba/smb.conf to share /remote_disk folder
[public]
        comment = remote disk
        path = /remote_disk
        browsable = yes
        guest ok = yes
        read only = no
        create mask = 0755

To enable security(ask username and password on connect) you have to open /etc/samba/smb.conf file, and uncomment line(delete the '#'):
       # security = user

To restart samba type command:
      sudo /etc/init.d/samba restart


Tuesday, July 3, 2012

Running program at startup


In order to run a program at startup you have to put next line in /etc/rc.local:
            test_program > /dev/null 2>&1 &
where
  • test_program - is the name of the program we want to run at startup
  • > /dev/null - redirects all standard output from the test_program program in /dev/null (black hole). It means all data are dropped.
  • 2>&1 all standard errors are redirected in standard output. Or we could write this line as: 2>/dev/null which will redirect standart errors directly to black hole.
  • & - puts our program in background.

If you want to log all data that are printed by your program do this:
           test_program > log_file &

If you want to stop your program, that is running in background, type this command:
             killall -9 test_program

Thursday, June 14, 2012

Remote speakers

Almost all of my music is saved on my computer. So, i have to connect my boxes to my computer. I use a laptop with Wi-Fi connection in my bed and it's uncomfortable every time to plug audio jack. After some googling i found a few solutions. Or maybe one solution with different implementations.

The main idea is to "plug speakers" into my home network. The simplest implementation is to use another computer, which is connected to a router via Ethernet and the speakers are connected to that computer. The main disadvantage is the power consumption. The second is that you have to buy a new computer, which can cost a lot. But the advantage is that you can use it also as an external hard drive(like NAS), so 2 things in one machine. The software: i used VLC player(best solution). You can install VLC on a Windows, Linux or MAC. I tried on first two and it works. You can setup your playlist.You can even add online radio stations in your playlist. VLC configurations:
  • open VLC, then select Tools > Preferences. In the bottom left corner of the window, under "Show settings", click "All". Than go to Interface > Main interfaces and check the Web radio button.
  • than in main VLC window select view > Add interface > Web. 
  • edit file C:/Program Files/VLC/lua/http (for VLC 2.0.1), uncomment the line with your network (in my case it was: 192.168.0.0/16).
Or you can make all of above setting from command line typing :
         "C:\Program Files\VideoLAN\VLC\vlc.exe" --extraintf http --intf wx
This is useful when you want to start-up VLC on Windows start-up. Now open your browser and type  http://192.168.0.186:8080, this will open VLC web interface. very simpe :).

The grate thing here is that you can use your smart phone to control that remote VLC. I tried this on my phone which runs android 2.3.3, and my ipod touch 4g. It works on both devices. You just have to install VLC remote(i also tried VLC iRemote) , and you good to go. 
     
I also tried connecting my computer to a TV(over VGA). You can pause play change the volume remotely.

For low power solution you can use for example Raspberry Pi or Beagle Bone. In case the VLC isn't working on that devices you have to make your own program .

Saturday, June 2, 2012

Automatic feeder

There are many types of automatic feeders. The one i like is so called screw feeder. The ideea is explained bellow in the picture :


So we need a screw. It's complicated to make one home, without special tools. After a few days of thinking i came up with this:


This is so called meat grinder, that has screw we need. I will try using the whole meat grinder, without some parts. Let's disassemble our meat grinder.


I will use only parts 3, 4, 6 and 7. I will use plate (number 6) with big halls, and not the one in the above picture. I found this one:


It has big halls, so the food can come out easily. It is not enough to use simple motor, because it has to much rpm's. We need a motor with some gears, so called gear motor. We can use something like this:
This gear motor has around 120-180 rpm's.



Saturday, May 26, 2012

Fridge tuning


      I have an old fashion Romanian fridge. This is how it looks like:


     The idea is to add some new functionalites to it. I am thinking of led lights and some measurement device to measure temperature and maybe some thing else in the future.
Reed switch for detecting opened door:


Friday, May 25, 2012

Unlocked door notification


Some time people forget things. It's normal, but some time it is not good. Here i mean doors. If you leave door unlocked, someone can come in or your cat can get out. So the basic idea is to make a system that will announce(with buzzer) you that the door is unlocked.

The simplest way to do it, is to put a micro switch in your door lock. Something like this:

So when door is locked the switch is ON otherwise it is OFF.

Wednesday, May 23, 2012

Wireless water flow meter


In Romania (may be in other countries is the same) you have to give you water consumption to the administrator. This have to be done every month. By my experience, you always forget to do that. So let's help us.

So in this project i will try to build a system that sends your water consumption wireless. I will try to modify an ordinary water flow meter to fit my requirements. I found this on:


I liked it, because it has a compartment where i can put all electronics(including battery). Another advantage: it hase a magnet on one of it's weel, so i can integrate easily a magnetic sensor to measure water flow. This is where the magnet is placed:


and onother one:





Interfacing with TL-WR740N

     
In this post i will try to explain how to interface with a router. By interfacing i mean connecting another embedded devices to router. For example:
  • tmperature sensor
  • port expander
  • external ADC(analog to digital converter)
  • a radio module
  • motors (servo, stepper)
Any router has GPIO. Actually all led's and buttons are connected to GPIO. We can use them. But there is a problem controlling them. You can't control the GPIO in a router the way you can control them in a microcontroller. You don't have precise timers to measure time between edges. Or you can, but i don't know how :D. So i will need to use a microcontroller, so i can do all the above thinks. It will not add big cost to ower system, because you can get a microcontroller for under 1$.  I will use PIC24 microcontroller, PIC24F04KA201. I am already familiar with ATMEL 8 bit microcontrollers. For a while i wanted to learn a 16 bit family from the microchip. So this will be a good start.

I will use TL-wr740N, because it's chip :) .This is how it looks like inside:


        

Thursday, May 3, 2012

Metro alarm


The ideea of metro alarm is to notify the user about his metro station, when he is sleeping or hardly thinkink. Actually this is a phone based application, that countes stations. The main problem here is: how can we count station? How does the phone know when you arrive to the station. Well there are a few posibilities that have been explored by the people.
   -  You can do voice recognition, so the phone can listen using the microphone and to process the voice captured. I see here 2 problems. First one is that you have to make some powerful calculations, that will consume your battery. Second is the background noise.
    -  My ideea (i am sure not only mine), is to use accelerometer. So when the train accelerates/decelerates you will see some changes on one of the axis. The problem here is that the phone have to be in the same position, or you can make adaptive algoritm, to automatically adjust the settings when you move the phone, but i think it is to complicated.

Saturday, April 28, 2012

Exploring OpenWRT


For a while I started using linux embedded OS. The idea is to replace ordinary 8/16 bit microcontrollers, that does't have yet very well desvolted Network support. I was looking for a low cost chip that can run linux OS. After some searching i fountd out about OpenWRT. So i started searchig a router to hack. I stopped at Tp-Link router TL-MR3020. It is small, low cost and has enouth power.

Some pictures :





It took 5 min to hack it :).

Unfortunatly you can't play with timer in linux like you can in ordinary microcontrollers. Or to manage GPIO, menaging interrupts. So i desided to use a low cost 8 bit microcontroller. Attiny2313 is good enouth. So our microcontroller will take data from ower sensors, but ower router will do some calculations and will send it over the network(Ethernet or WiFi).

So, the upcoming problem is: how to connect our microcontroller with our linux machine?
I see 3 choices:
  1. via GPIO
  2. via UART
  3. via USB 
For (3) we have to use USB to UART converter (ex. FT232), but this addes some additional costs to our system. Or we can emulate our USB slave in Attiny2313, but it will take our valuabale codesize and CPU performance.

It took me few days to explore the second choice. I was able only to transmit data from router to microcontroller. The problem is that the kernel ocupies the serial port for console. I think in order to repair this i have to recompile the kernel, but for now this is too advanced for me.

The only choice left is number one. There are some librarys that can be used to make an I2C over GPIO.
But i will try to emulate SPI using GPIO. In this table we have described some GPIO avaliable to us.


 GPIO ports are to used by kernel, but here we can release them. To do that we have to execute this commads :
       > rmmod leds_gpio
       > rmmod gpio_buttons

The second step is to export them in user space so we can use them. For example in order to export the Ethernet LED we have to write:
       > echo 17 > /sys/class/gpio/export
     , where 17 is pin number from above table.

In order to set direction of the pin we have to write in or out words in direction file. Ex.:
       > echo out > /sys/class/gpio/gpio17/direction
To set 1 or 0 for the output pin we ahve o write corespondin value in value file.

Pseudo dual core microcontroller

An example of Atmega128 and external memory:



 The ideea is to use two Atmega128 microcontrollers and one memory. So called shared memory. The memory i will be using is called Dual-ported RAM. There are actually some chips that can implement this kind of memory. I will try to use 7025E or IDT7130.

This is block schem of the IDT7130:



And here is the general idea:




Tuesday, January 31, 2012