SolarRC

From SGMK-SSAM-WIKI
Jump to navigation Jump to search

Description

A quite inexpensive and simple solar powered AVR ATtiny device to collect data from the environment.

/// this is a work in progress draft ///

Overview

We've tested the following hardware (plug&play style):


In combination with:

  • 2x Arduinos (on the same computer, good for debugging via serial monitor - just start the arduino IDE twice)
  • ATtiny85 (great for final devices, placed somwhere outside) + Arduino UNO on the receiver side


Software: Those two Arduino libraries were tested successfully:


Tests showed that it is possible to transmit data reliably indoor up to a distance of about 20 meters. The signal gets weaker, depending on the obstacles between sender/receiver of course. To improve the signal quality it was helpful to use a simple wire on stick of 17.3cm in length (quarter wavelength) as an antenna on both, sender/receiver modules.

TODO

  • Measure power consumption and average solar charging rate... is it possible to run the device non-stop, also during the night, collecting data?
  • Investigate more about sleep modes of the ATtiny... and energy harvesting in general.
  • What's the minimal number of parts/price needed to shrinkify the the whole setup to a single board? (3.3 V?)
  • Mesh network with receiver/transmitter pair (transceiver) on every node? Can the nodes be used as "relays" to increase transmission range? What kind of protcol is ideal for this? How to minimize collisions/corrupted data (send checksum)? Does it make sense ($$$) compared to XBee, BLE, WiFi etc.?
  • It is possible make a very simple radio transmitter, by using just the internal oscillator of the microcontroller! Have a look at this great hack by Scott W Harden. To receive the data, a diode detector could be used to demodulate the AM signal and read it in again on an analog pin...? but this is just fantasy, no clue if/how/how good this will work, we'll see...


Setup

Transmitter setup:


Receiver module (sending out QTouch ADC data just for the fun - check out cocomake7):

Code

Below are the copy/pasted examples from the ManchesterRF lib.

There are two things to think about, in order to get this running on the ATtiny85:

  • Make your Arduino IDE ready to build and program the ATtiny. ManchesterRF relies on that Arduino environment. - http://highlowtech.org/?p=1695 - (To program the ATtiny, we've used the USBasp, but any other programmer should work too.)
  • Make a tiny modification in the ManchasterRF lib itself; the example will not compile otherwise with the current version of the library. Somehow it still works without that interrupt handler... Replace the junk at the end of the ManchesterRF.cpp file with this:

// MOD MOD MOD
#if defined( __AVR_ATtinyX5__ )
#else
//#if defined( __AVR_ATtinyX5__ )
//	ISR(TIMER1_OVF_vect)
//#elif ...

#if defined( __AVR_ATtinyX4__ )
	ISR(TIM1_OVF_vect)
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1284P__)
	ISR(TIMER3_OVF_vect)
#elif defined(__AVR_ATmega328P__)
	ISR(TIMER2_OVF_vect)
#else
	#error "Manchester library doesnt support your microcontroller"
#endif
{
  DEBUG_TOGGLE();
	MAN_RX_INTERRUPT_HANDLER();
}

#endif // MOD


Then it should build and run just fine. Play around with different link speeds and transmission distances...

Any hints and ideas about this are always welcome! This is just a little work in progress experiment...


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();
    }
  }
}


Hardware

Hooking up the modules is straight forward. Just keep in mind that the Arduino pins are mapped like this to the ATtiny85:

More info can be found there...

The data pins on the RF modules are labled, just power them via VCC/GND and connect the RX/TX lines to the uC.