SolarRC

From SGMK-SSAM-WIKI
Revision as of 10:15, 23 April 2015 by 0rel (talk | contribs) (A very inexpensive and simple solar powered ATtiny circuit to collect data from the environment.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

description

A very inexpensive and simple solar powered AVR ATtiny circuit to collect data from the environment.


transmitter

/*

  Manchester Receiver example
  
  In this example transmitter will transmit two 8 bit numbers per transmittion
    
*/


#include "ManchesterRF.h" //https://github.com/cano64/ManchesterRF


#define TX_PIN 3 //any pin can transmit
#define LED_PIN 13

ManchesterRF rf(MAN_300); //link speed, try also MAN_300, MAN_600, MAN_1200, MAN_2400, MAN_4800, MAN_9600, MAN_19200, MAN_38400

uint8_t data = 0;

boolean state = false;

void setup() {
  pinMode(LED_PIN, OUTPUT);  
  digitalWrite(LED_PIN, HIGH);
  rf.TXInit(TX_PIN);
  
  Serial.begin( 9600 );
}

void loop() {

  int a, b;
  rf.transmitByte(a = ++data, b = data*data);
  digitalWrite(LED_PIN, state); //blink the LED on receive
  state = !state;
  
  Serial.print( a );
  Serial.print( ", " );
  Serial.print( b );
  Serial.println();
  delay(500);
}


receiver

/*

  Manchester Receiver example
  
  In this example receiver will receive two 8 bit numbers per transmittion

*/


#include "ManchesterRF.h" //https://github.com/cano64/ManchesterRF

#define RX_PIN 4 //any pin can receive
#define LED_PIN 13

ManchesterRF rf(MAN_300); //link speed, try also MAN_300, MAN_600, MAN_1200, MAN_2400, MAN_4800, MAN_9600, MAN_19200, MAN_38400

uint8_t a, b;

boolean state = false;

void setup() {
  pinMode(LED_PIN, OUTPUT);  
  digitalWrite(LED_PIN, HIGH);
  rf.RXInit(RX_PIN);
  
  Serial.begin( 9600 );
}

void loop() {

  if (rf.available()) { //something is in RX buffer
    if (rf.receiveByte(a, b)) {
      //process the data
      //...
      digitalWrite(LED_PIN, state); //blink the LED on receive
      state = !state;
      
      Serial.print( a );
      Serial.print( ", " );
      Serial.print( b );
      Serial.println();
    }
  }
}