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


No comments:

Post a Comment