Thursday, May 21, 2015

eBay wifi module for RaspberryPi buy and setup


Last month I bought a wifi Module for my RaspberryPi 2 and it's so small. But it was not working as it is! So doing so research and I found some solution is working for me. It's so cheap and small.
eBay link:
http://www.ebay.com/itm/231273301300?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

And the solution is:

sudo apt-get install linux-headers-generic build-essential git
sudo apt-get install git
git clone https://github.com/porjo/mt7601.git 
cd mt7601/src
make
sudo make install
sudo mkdir -p /etc/Wireless/RT2870STA/
sudo cp RT2870STA.dat /etc/Wireless/RT2870STA/
sudo modprobe mt7601Usta
For Windows: http://www.mediatek.com/en/downloads/ and look for "mt7601"
Let me know if you got success! Have a nice day!

Tuesday, April 28, 2015

Android "android.os.NetworkOnMainThreadException" error

Last night I was trying to insert value from Android to MySQL but I could not manage to do it and finally after kill 2 hour I found the solution. For new Android OS we need thread. So if you want to send value you should follow:

            public void onClick(View v) {
                new Thread(new Runnable() {
                    public void run() {
                       //Do your operation here like insert();
                    }
                }).start();
            }
        });


Android - Run/install/debug applications over WiFi

I was very tired to Install app through USB so I was wondering it would be cool if I can install apk over wifi and I found the solution:

  1. Connect device via USB and make sure debugging is working.
  2. adb tcpip 5555
  3. adb connect <DEVICE_IP_ADDRESS>:5555
  4. Disconnect USB and proceed with wireless debugging.
  5. adb -s <DEVICE_IP_ADDRESS>:5555 usb to switch back when done.
No root required!
To find the IP address of the device: run ./adb shell and then netcfg. You'll see it there.

Tuesday, April 21, 2015

RaspberryPi and Arduino receive data from Attiny85 + 433 MhZ

Attiny85 Connecting with DHT11 and 433 Mhz:



Transmit code:
#include <dht.h>
#include <VirtualWire.h>
#include <avr/sleep.h>
#include <util/delay.h>

int led=0;
const int transmit_pin = 4;
dht DHT;

#define DHT11_PIN 3

void setup(){
  vw_set_tx_pin(transmit_pin);
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);  // Bits per sec
}

byte count = 1;

void loop(){
  int chk = DHT.read11(DHT11_PIN);
  int t=0;
  int h=0;
  //_delay_ms(200);
  t=DHT.temperature;
  h=DHT.humidity;
  char myBigArray[128];
  char temp[4];
  itoa( t, temp, 10);
  //char razib[1]={'k'};
  //char msg[7] = {'H','e','l','l','o',' ','#'};
  myBigArray[0] = '\0';
  //strcat(myBigArray, "T:");
  strcat(myBigArray,temp );
  strcat(myBigArray, ":");
  itoa( h, temp, 10); 
  //strcat(myBigArray, razib);
  strcat(myBigArray, temp);
  //msg[6] = count;
  //digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)myBigArray, strlen(myBigArray));
  vw_wait_tx(); // Wait until the whole message is gone
  //digitalWrite(led_pin, LOW);
//  delay(100);
  count = count + 1;
  //system_sleep();
  //delayMicroseconds(20);
  _delay_ms(1000);
}
RaspberryPi Receiver:


Hardware Requirements:

  • Raspberry Pi(I used a Raspberry Pi Rev.2)
  • 433 MHz receiver(Any type of 433 Mhz receiver should work, but for this tutorial I used a 4 pin variant)
  • A breadboard
  • Some jumper wires
  • A 433 MHz transmitter(I used a 4 channel 433 MHz transmitter Remote)

Installing WiringPi:

WiringPi is needed to control the pins on the Raspberry Pi. Which will be connected to the 433 MHz Receiver.
After running the last command, WiringPi should be installed!
cd ~/
git clone git://git.drogon.net/wiringPi
cd wiringPi

./build


Installing 433Utils:

433Utils is made by GitHub user wolfeidau. He gathered a bunch of code and wrote some himself, all about 433 MHz Radio Transmissions, then made a repo of it.
To install 433Utils, run these commands:
1
2
3
4
cd ~/
git clone git://github.com/ninjablocks/433Utils.git
cd 433Utils/RPi_utils
make
Now 433Utils should be installed!
Running the code:
~/433Utils/RPi_utils/RFSniffer


Thursday, April 9, 2015

Arduino Nano and Attiny85 communication

Below picture is showing how to connect Arduino nano as a programmer for Attiny85.






Friday, March 20, 2015

RaspberryPi communication with Attiny85+PIR sensor alert system depends on movement

In this project I used Attiny85 + RaspberryPi+ 433Mhz Transmitter and PIR sensor. So when ever PIR sensor detect any human movement, it(PIR sensor) will activate attiny85 and send signal throw 433MHz transmitter and RaspberryPi will receive the signal and put to MySQL. Below video can explain more about my project:

Attiny85

Ask me question if you want to more about this project.

Saturday, March 14, 2015

Wordpress Permalink issue

This is only true for linux server:

If anyone of them is not working for you:

To enable it the rewrite module, run "apache2 enable module rewrite":You need to enable mod_rewrite
sudo a2enmod rewrite
You need to restart the webserver to apply the changes:
sudo service apache2 restart
If you plan on using mod_rewrite in .htaccess files, you also need to enable the use of .htaccess files by changing AllowOverride None to AllowOverride FileInfo. For the default website, edit /etc/apache2/sites-available/default:
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            # changed from None to FileInfo
            AllowOverride FileInfo
            Order allow,deny
            allow from all
    </Directory>
After such a change, you need to restart Apache again.