Thursday, December 5, 2013

Automatic feeder v2

This is another version of an automatic feeder. I've seen some guys on the internet using a cereal dispenser for this purpose.

A nice stuff about this dispenser is, that it has a valve made out of rubber. This prevents the food breaking into small pieces.

So you just need to add a motor with gears (or a servo motor) and a timer and you are good to go.

Sunday, March 17, 2013

TL-WR740N & wireless temperature & humidity sensors

      I have 3 wireless temperature & humidity sensors that sends data over wireless. It is standard 433Mhz frequency.Each sensor send temperature and humidity over wireless. One more information that is send by the sensor is an address. The problem about the address is, that it is changed on every power up. So if you change your batteries you have to reassign the sensor to the specific room(let's say you are login the temperature for a specific room). The sensor i am using looks like this:


      You can get more information about the sensor i am using and the data coding on this page.

      The receiving block schematic diagram is:

      The router has internal regulator that gives me 3.3V, but the only 2 reasons i don't use that voltage is because my radio receiver module needs 5V and my USB cable(for simplicity i am using usb cable) has only 4 wires(5v, GND, RX, TX). So I added a 7805 to give the 5V for the radio module and a LD1117 regulator to make local 3,3V.

      As i mentioned here i will use a microcontroller to receive the data. I am using a PIC24F08KA101. I find the pic24 microcontroller a good choice that can be placed between an Atmega328(arduino classic) and an ARM.
    The result is this:


The rest of the components are SMD and are placed under the PCB board. And the schematic:





Schematic... work in progress...





The changed router looks like this:



The 7805 regulator is in the router, so i am sending 5V to the radio board. Don't forget to add a pull-up resistor(10k) for the router RX line and a wire for TX<->CPU as mentioned at openwrt page

Software will be posted soon...

Ethernet to UART software bridge

When you want to make a quick project, it is very important to have a bunch of software written for you.   For example, it took me more than a week to write an application that makes a communication between microcontroller and a router. The problem with the router is, that it has small memory, so you can't install a compiler or to install java, python etc... Of course, you have lua(or another scripting language), a great embedded language, but how many people knows lua. The embedded world is based on C(in my opinion). In order to write apps for openwrt in C language, you need to install tools, figure out how to use, configure, write your app. So i made this app, that i think is a general app for embedded stuff.

What this software does, is very simple, but i think very useful. If you want to connect, let's say your arduino to a router, just connect it via native UART or via USB to UART converter and you can communicate with it over your IP network.

How does it work? The program creates a TCP server socket on a router(on any port you want). So using a simple client app on your PC you can collect data from your board. For example you can use Hercules(just google it). The program also opens the serial port. So all data received over TCP are send to serial port, and all data received over serial port are send over TCP.

How to install? Just copy .ipk file to router using for example winscp. To install the app, login to your router with putty and type the command:

          opkg  install  eth_uart_bridge_1.0_ar71xx.ipk

How to use? In command line type:

          eth_uart_bridge

The program will be started with default parameters as shown below :
  • 5000      - TCP port
  • ttyATH0 - default openwrt serial port
  • 9600bps - serial baud rate
  • 8N1       - 8 bits, no parity, 1 stop bit
If you want to run the program with non-dafault settings, just type:

         eth_uart_bridge  /path_to_file/config_file.txt

   where the config_file.txt is a file that holds configuration data.It can have any name and looks like so:

    Ethernet_port:5007;           //1024 - 9999
    Serial_port:ttyUSB0;
    Baud_rate:19200;  
    Frame_info:8N2;

The router kernel uses the serial port as console output. In order to block that you have to comment(with #) or erase the following line in /etc/inittab:

          ttyS0::askfirst:/bin/ash --login

If you want to run the program when the router starts just add this line in /etc/rc.local:
        
         eth_uart_bridge > /dev/null 2>&1 &
 
For more details about starting at startup go here.

You can download the package here, and the configuration file here. This software was tested on the TL-WR740 and TL-MR3020. Actually it can be installed on any router that is ar71xx compatible.


    Update: Before making some stuff, it is useful to google first. Unfortunately i forgot to do that :D.  There is a software that makes exactly the same thing i needed. The program is called ser2net (serial to network proxy). This program is ported to all linux compatible OS. 


Wednesday, March 13, 2013

Wireless humidity & temp. sensor

Some times there is a need to measure temperature and humidity in a place where you can't put wires. The best way to resolve this problem is to put a wireless sensor. You can make one by yourself, but it will require a lot of work: making the pcb, find a good isolated enclosure(in case it rains). Ok, maybe one device will not be so complicated to make, but if you need few of them it can take a lot of time. So i decided to take a commercial one and to hack it. Of course there are some base station for that remote sensors, but they don't do smart think and you can't connect them to the internet :).

There are a lot of companies that produce wireless humidity and temperature sensors. This is my choice :



And back side:



Here you can see the pcb:



And one more picture:


This sensor sends humidity and temperature over 433Mhz radio frequency every minute. Also it has a lcd to display the data.  The precision of temperature is 0.1 degree, pretty good. The device can be forced to send data by pressing the TX button on the back. On the back there is a switch to select Celsius or Fahrenheit to be displayed.

In order to decode the signal we need a 433Mhz radio receiver. I plugged the receiver to mic input on a sound card(unfortunately i don't have a digital oscilloscope). And to register the signal i used sound forge.

It looks like the sensor sends the same frame 32 times. Every frame lasts for around 52 ms and the pause between frames is around 8ms. So, all 32 frames are sent in 1920ms(it's a big window). Here is how looks one frame:



As you can see there are only two patterns. In both of them the timing when the signal is high is the same. That means, that only variation in the timing, when signal is low, says when we have logical "1" or logical "0". So i made the following assumption:

                 
                


I made a table that shows the received code and the actual temperature(displayed on lcd):

Received code Temperature (°C) Humidity (%) Battery status
0100_1011_0001_0000_0011_0100_0000_1100_0000 19,2 52 -
1100_1010_1001_0000_0010_0110_0000_1111_0010 24,2 38 low
0110_0110_1001_0000_0010_1000_0001_0000_0000 25,6 40 low
1001_1100_0001_0000_0010_1000_0001_0000_0010 25,8 40 -
1010_1000_0001_0000_0010_0000_0001_0001_0001 27,3 32 -


After some thinking a have got this( for 24,2°C, 38% ):


So the sensor sends 36 bits, that means:
  • address  -  first 8 bits are changed on every power up of the sensor. 
  • battery  -  when the battery is low,  this bit is set to '1'.In this case a battery is displayed on the LCD screen.
  • unknown data  -  this 8 bits remains always the same, so i couldn't track them.
  • humidity  -  is the binary representation of the humidity. So dec(38) = bin(0100110).
  • temperature  -  is the binary representation of the temperature multiplied by 10(or just remove comma from the temperature). That means: dec(242) = bin(000011110010).
The only problem with this sensor is that the address is changed on every power up. That means, that i have to reassign the sensor in my system every time i change the batteries, which happens every 10 months.

Tuesday, March 12, 2013

Wireless temperature sensor

Some times there is a need to measure temperature in a place where you can't put wires. The best way to resolve this problem is to put a wireless sensor. You can make one by yourself, but it will require a lot of work: making the pcb, find a good isolated enclosure(in case it rains). Ok, maybe one device will not be so complicated to make, but if you need few of them it can take a lot of time. So i decided to take a commercial one and to hack it. Of course there are some base station for that remote sensors, but they don't do smart think and you can't connect them to the internet :).

There are a lot of companies that produce wireless temperature sensor. This is my choice :



And back side:



Here you can see the pcb:



And one more picture:



This sensor sends temperature over 433Mhz radio frequency every minute. The precision is 0.1 degree, pretty good. The device can be forced to send data by pressing the TX button on the back.

In order to decode the signal we need a 433Mhz radio receiver. I plugged the receiver to mic input on a sound card(unfortunately i don;t have a digital oscilloscope). And to register the signal i used sound forge.

It looks like the sensor sends the same frame 10 times. Every frame lasts for around 82 ms and the pause between frames is around 8ms. So, all 10 frames are sent in 900ms. Here is how looks one frame:



















As you can see there are only two patterns. In both of them the timing when the signal is high is the same. That means, that only variation in the timing, when signal is low, says when we have logical "1" or logical "0". So i made the following assumption(which turned to be right):

                   
                

To figure out how the data is coded i used the original base station(that shows me the actual temperature send by the sensor). This are the results:

Received code Temperature (°C)
1110_0100_0001_0100_1000_0000 20
1110_0100_0001_0101_1000_0001 21.1
1110_0100_0001_1010_1100_0000 24
1110_0100_0001_1001_1100_0001 25.1
1110_0100_0001_1001_1100_0100 25.4

So the sensor sends 24 bits. The only thing left is to