Thursday, July 24, 2014

RFM12 adapter (optional UART with PIC16)

I've been using RFM12 modules for over 5 years. They are pretty nice and cheap radio modules. This modules use frequency modulation(FM) which means they are more robust than AM ones. The only downside I can see is that this modules are prototype unfriendly. 

To solve this issue you need an adapter. The internet is full with all kind of adapters for RFM12 modules. Almost all of this modules just convert unfriendly footprint to a friendly one (breadboard friendly). 

My idea was to make an adapter that had 2 functions:
  • a simple breadboard friendly adapter
  • a standalone board with MCU

The main idea was to put an optional MCU on the board. So, if you don't need the MCU just don't solder it and use the board as a simple adapter. The winner for this project was a PIC16F1824 microcontroller. This one has ulta-low-power operation modes which are great for low power devices. 

This is a 3D model of the board:


On the top there is only one LED which can be used for status or something else.

And here is the bottom side:


Here we have some decoupling caps and a few resistors(reset etc.). And of course the PIC micro in 14 pin SOIC package. Almost all PIC micros that have 14 pin are pin to pin compatible, this means that you can use any micro you want(that has 14 pin). For programming the microcontroller there are some test pads. This pads can also be used for UART communication.

The schematic is pretty simple:



And here is the pcb:



Unfortunately RFM12 eagle part did't had all pins routed, so I had to put some connection that don't relate to schematic. This connection are not used, but I've made them anyway.


Download:


Thursday, March 13, 2014

Useful Linux commands

I am not a Linux user, but I like it. It has some pretty cool features. Sometimes I know what I want from the Linux, but I don't know how to do it. This problem is very common in CLI. So, here I will dump some useful CLI commands, that I use rarely use and unfortunately can't remember.

USB stuff:

1) Check all connected USB devices:
pi@raspberrypi ~ $lsusb

2) Show descriptors for a specific USB device (16C0:5DC - VID and PID for V-USB):
pi@raspberrypi ~ $lsusb -v -d 16C0:5DC

3) Show libusb version on current system:
pi@raspberrypi ~ $dpkg -l | grep libusb

4) Install libusb library(works on Ubuntu and some other distros.):
pi@raspberrypi ~ $sudo apt-get install libusb-dev

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.