Refrences

Raspberry Pi Tips…

To start SSH on boot from new Image 
Before booting the Raspberry Pi: 
1. Place an empty file named ssh without an extension in the boot 
   folder.
Note: If you used Notepad you will have to remove the .txt extension 
      by renaming the file to ssh

Convert a Windows DOS file to Unic file
1. tr -d '\r' < infile > outfile
Note: This removes the \r carriage return from the Windows DOS file

Weather Sensor Formulas…

Anemometer:

/* Measurement period (miliseconds)                               */
const int period = 4000;

/* Calculate revolutions per minute (RPM)                         */
RPM=((counter/2)*60)/(period/1000);

/* Pie                                                            */
const float pi = 3.14159265;

/* Radius from vertical anemometer axis to a cup center (mm)      */
const int radio = 65;

/* Calculate wind speed on m/s                                    */
SpeedWind = ((2 * pi * radio * RPM)/60) / 1000;

Wind Vane:

/* Two way to get 0 - 360 degree Wind Vane direction              */

int Vvane = analogRead(VANE_PIN);
  
Direction = (Vvane / 1023.0) * 360.0; 

Direction = map(Vvane, 0, 1023, 0, 359);

Temperature:

/* Temperature conversions C to F - F to C                        */

int tempC = analogRead(TEMP_PIN);

/* Convert C to Fahrenheit */ 
tempF = tempC * 9 / 5 + 32;

/* Convert Fahrenheit to C */ 
tempC = (tempF - 32) * 5 / 9;

Dew Point:

/* dewPoint function NOAA                                         */
/* reference (1) :                                                */
/* http://wahiduddin.net/calc/density_algorithms.htm              */
/* reference (2) :                                                */
/* http://www.colorado.edu/geography/weather_station/Geog_site    */
/* /about.htm                                                     */
/* From A DHT11 Class for Arduino                                 */
       
dewPoint(temperature, humidity);

double dewPoint(double celsius, double humidity)
{
  // (1) Saturation Vapor Pressure = ESGG(T)
  double RATIO = 373.15 / (273.15 + celsius);
  double RHS = -7.90298 * (RATIO - 1);
  RHS += 5.02808 * log10(RATIO);
  RHS += -1.3816e-7 * (pow(10, (11.344 * (1 - 1/RATIO ))) - 1) ;
  RHS += 8.1328e-3 * (pow(10, (-3.49149 * (RATIO - 1))) - 1) ;
  RHS += log10(1013.246);

  // factor -3 is to adjust units - Vapor Pressure SVP * humidity
  double VP = pow(10, RHS - 3) * humidity;

  // (2) DEWPOINT = F(Vapor Pressure)
 double T = log(VP/0.61078);   // temp var
 return (241.88 * T) / (17.558 - T);
}



/* delta max = 0.6544 wrt dewPoint()                              */
/* 6.9 x faster than dewPoint()                                   */
/* reference: http://en.wikipedia.org/wiki/Dew_point              */

dewPointFast(temperature, humidity);

double dewPointFast(double celsius, double humidity)
{
  double a = 17.271;
  double b = 237.7;
  double temp = (a * celsius) / (b + celsius) + log(humidity*0.01);
  double Td = (b * temp) / (a - temp);
  return Td;
}

Heat Index:

/* heatindex() Function By sspence                                */
/* From The Super Simple Arduino Weather Web Server               */

double heatIndex(double tempF, double humidity)
 {
   double c1 = -42.38, c2 = 2.049, c3 = 10.14, c4 = -0.2248, 
   c5= -6.838e-3, c6=-5.482e-2, c7=1.228e-3, c8=8.528e-4, 
   c9=-1.99e-6  ;
   double T = tempF;
   double R = humidity;
 
   double A = (( c5 * T) + c2) * T + c1;
   double B = ((c7 * T) + c4) * T + c3;
   double C = ((c9 * T) + c8) * T + c6;
 
   double rv = (C * R + B) * R + A;
   return rv;
 }

Wind Chill:

/* T is the air temperature in degrees Fahrenheit, and V is the   */
/* wind speed in miles per hour.                                  */
 
Wind Chill = 35.74 + 0.6215T – 35.75(V^0.16) + 0.4275T(V^0.16)

/* From Arduino Wind Chill Machine                                */
/* Twc=35.74+0.6215*Tf-35.75MPH^0.16 +0.4275*Tf*MPH^0.16          */
/* double pow (double base, double exponent )                     */

if ((TempF <50.0) && (MPH > 3.0))
{
Twc=35.74+0.6215*TempF-35.75*pow(MPH,0.16)+0.4275*TempF*
pow(MPH,0.16);
}
else
{
 Twc=TempF;
}

Read Vcc (Supply Voltage)

AnalogReference()

/* AnalogReference()                                              */
/* #define DEFAULT (0) Disconnected from PB0 (AREF) pin           */
/* #define EXTERNAL (1) External Voltage Reference PB0 (AREF) pin */
/* #define INTERNAL (2) Internal Voltage Reference                */
/* #define INTERNAL1V1 (2) 1.1v Internal Reference                */
/* #define INTERNAL2V56NC (6) 2.56v no bypass capacitor  PB0 pin  */
/* #define INTERNAL2V56 (7) 2.56v with external bypass capacitor  */

/* ATtiny24-45-85 Datasheet page 134 Table 17-3                   */

ATtiny85  readVCC()

/* ATtiny85 readVCC()By david.prentice - Oct 14, 2013             */
/* The ATtiny85 does not have many pins                           */
/* This needs no pins                                             */
/* Very useful for Calibrating Temperature                        */
/* And it works...                                                */

uint16_t readVcc(void)
{
  uint16_t result;
  // Read voltage reference against Vcc
  ADMUX = (0<<REFS0) | (12<<MUX0);
  delay(2); // Wait for Vref to settle
  ADCSRA |= (1<<ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCW;
  return 1125300L / result; // Back-calculate AVcc in mV
}

Improving Accuracy:

/* Improving Accuracy By Scott Daniels - July 9, 2012             */
/* Simply measure your Vcc with a voltmeter and readVcc() function. */ /* Then, replace the constant 1125300L with a new scale_constant. */ 
internal1.1Ref = VRef * Vcc1 (read voltmeter) / Vcc2 (readVcc() function)

scale_constant = internal1.1Ref * 1023 * 1000

/* Calibrated value will only good for the AVR chip measured. */

Vcc:

/* Vcc (power supply voltage)                                     */

float Vcc = (readVcc() function) / 1000.0;

Read ATtiny25-45-85 Band Gap Reference Voltage

/* readVbg()                                                      */
/* After finding readTemp()By digistump                           */
/* I modified what he had to read the Band Gap Reference Voltage  */
/* This will just show the selected Analog Reference Voltage      */
/* So to read Vcc select the DEFAULT Voltage Reference            */

uint16_t readVbg(void)
{
  int bg = 0;

  // Average Band Gap Voltage
  for(int i=0;i<3;i++)
  {
    bg += analogRead(A0+12); // ATtiny25-45-85
  }
  analogRead(A0);
  delay(3);
  bg = bg / 3;

  return 1125300L / bg; 
}

LM1117 Datasheet

LM1117 3.3v Low Dropout Voltage Regulator
arduino-attiny-lm1117-3.3v-ldo-voltage-regulator

LM35 Datasheet

LM35 Precision Temperature Sensor

arduino-attiny-lm35-temperature-sensor

/* Best LM35 calculation By jondecker76 - April 25, 2011          */
/* Adjusts for variation in VRef voltage                          */
/* VRef Reference voltage Selected with AnalogReference()         */
/* multiplier = actual_temp / lm35_temp                           */

float tempC = ((VRef * multiplier) * analogRead(0) * 100.0) / 1024.0

Get Internal Chip Temperature Sensor

/* Read Chip temperature sensor Celsius against 1.1V reference    */

#define OFFSET -5

int read_Chip_Temp() 
{ 
// ATtiny24-44-84 
// ADMUX = (1<<REFS1) | (1<<MUX5) | (1<<MUX1); 
// ATtiny25-45-85 
ADMUX = (1<<REFS1) | (15<<MUX0);

delay(2); // Wait for ADMUX setting to settle
ADCSRA |= (1<<ADSC); //Start temperature conversion
while (bit_is_set(ADCSRA,ADSC)); // measuring

uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
int temperature = (high << 8) | low; // combine the two

return temperature - 273 + OFFSET;
}

ATtiny  read_chip_Temp()

/* This is a much easier way to read ATtiny85 chip Temperature    */
/* By digistump September 23, 2013                                */
/* Must turn ON the 1.1v Internal Reference                       */

uint16_t read_chip_Temp(void)
{
  int raw = 0;

  // Average Temperature Reading
  for(int i=0;i<5;i++)
  {
  //raw += analogRead(A0+34); // ATtiny24-44-84
    raw += analogRead(A0+15); // ATtiny25-45-85
  }
  analogRead(A0);
  delay(3);
  raw = raw / 5;

  // This for Temperature Celsius
  raw -= 5; // raw adjust = kelvin
  int in_c = raw - 273; // celcius
  in_c = round(in_c);

 return in_c;

 // This for Temperature Fahrenheit
 // float tempOffset -12
 // int in_f = ((raw - 273)*1.8)+32;
 // in_f = round(in_f)+tempOffset;

 // return in_f;  
}

DHT11 Humidity/Temperature

DHT11-attiny-arduino-humidity-temperature-wireless weather-station

ATtiny Datasheet

Atmel ATtiny25/45/85 Datasheet
Atmel Web Site

Atmel ATtiny24/44/84 Datasheet
Atmel Web Site

Parallax Manual

/* The Parallax Serial LCD has the capability */
/* to store up to eight user-defined custom   */
/* characters in RAM 0-7, and they only have  */
/* to be defined one's in (setup)             */
/* Arduino - ATtiny Custom Character Example  */
/* This is how I define a custom Character    */

// build a specific custom characters 'degrees'
byte customCharacter1[]  = {4, 10, 4, 0, 0, 0, 0, 0};

void setup(){
 Serial.begin(9600);               // Set Serial Speed
 delay(5);

 Serial.write(249);                // Store Custom Char to memory 1
 Serial.write(customCharacter1,8); // Define Custom Char 1

 Serial.write(22);                 // Cursor OFF 
 Serial.write(17);                 // Turn back-light on
 delay(10);                        // Required delay

 Serial.write(12);                 // Clear display 
 Serial.write(163);                // Position 1,15
 Serial.write(1);                  // Display Custom Char 1
}

void loop(){

 Serial.write(163);                // Set Cursor Position 1,15
 Serial.print(Example);            // Print Example on LCD
 Serial.print(F("Example"));       // Use F() to save memory

}

See manual for complete command set.

Note: I do use when I have lots of flash memory:
SoftwareSerial
ParallaxLCD

But to save valuable flash memory on the ATtiny, I only use:
TinyDebugSerial
with Parallax commands

Google Charts api …

Links…

Calculators:

Advertisements