Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Posting to Wunderground.com via UNO/MEGA-2560 on: January 07, 2014, 09:39:13 am
//PART TWO of TWO
Code:
void listSSIDResults(void)
{
  uint8_t valid, rssi, sec, index;
  char ssidname[33];
  index = cc3000.startSSIDscan();
  Serial.print(F("Networks found: "));
  Serial.println(index);
  Serial.println(F("================================================"));
  while (index) {
    index--;
    valid = cc3000.getNextSSID(&rssi, &sec, ssidname);
    Serial.print(F("SSID Name    : "));
    Serial.print(ssidname);
    Serial.println();
    Serial.print(F("RSSI         : "));
    Serial.println(rssi);
    Serial.print(F("Security Mode: "));
    Serial.println(sec);
    Serial.println();
  }
  Serial.println(F("================================================"));

  cc3000.stopSSIDscan();
}
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: "));
    cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: "));
    cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: "));
    cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: "));
    cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: "));
    cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    //timesConnected++;
    return true;
  }
}
void windvelocity(){
  speedwind = 0;
  counter = 0; 
  attachInterrupt(0, addcount, RISING);//anemometer
  unsigned long millis();                     
  long startTime = millis();
  while(millis() < startTime + Wait) {
  }
  detachInterrupt(0);
}
void RPMcalc(){
  RPM=((counter*2)*60)/(period/1000);  // Calculate revolutions per minute (RPM)
}
void WindSpeed(){
  speedwind = ((2 * pi * radio * RPM)/60) / 1000;
}
void addcount(){
  counter++;
}
void Heading(){
  analogRead(winDir)* 5.00 / 1023.0;//Wind direction, Tweek the voltage returns below to match your resistor
  if ((winDir > 4.94)||(winDir < 0.01))
    (winddir = 0);
  if ((winDir >= 0.02)&&(winDir < 0.30))
    (winddir = 22.5);
  if ((winDir >= 0.31)&&(winDir < 0.72))
    (winddir = 45);
  if ((winDir >= 0.72)&&(winDir < 0.99))
    (winddir= 67.5);
  if ((winDir >= 1.00)&&(winDir < 1.25))
    (winddir = 90);
  if ((winDir >= 1.26)&&(winDir < 1.52))
    (winddir= 112.5);
  if ((winDir >= 1.53)&&(winDir < 1.91))
    (winddir= 135);
  if ((winDir >= 1.92)&&(winDir < 2.40))
    (winddir = 157.5);
  if ((winDir >= 2.41)&&(winDir < 2.73))
    (winddir = 180);
  if ((winDir >= 2.74)&&(winDir < 2.96))
    (winddir = 202.5);
  if ((winDir >= 2.97)&&(winDir < 3.37))
    (winddir = 225);
  if ((winDir >= 3.38)&&(winDir < 3.55))
    (winddir = 247.5);
  if ((winDir >= 3.56)&&(winDir < 3.85))
    (winddir = 270);
  if ((winDir >= 4.13)&&(winDir < 4.06))
    (winddir = 292.5);
  if ((winDir >= 4.07)&&(winDir < 4.32))
    (winddir = 315);
  if ((winDir >= 4.33)&&(winDir < 4.93))
    (winddir = 337.5);
}
2  Using Arduino / Programming Questions / Posting to Wunderground.com via UNO/MEGA-2560 on: January 07, 2014, 09:38:24 am
Greetings,
I would like to know if anyone else is using the UNO or MEGA for POSTING to:
 "GET /weatherstation/updateweatherstation.php?"  ?
I have been able to use the MEGA with an ADAFRUIT CC3000 WiFi  BoB with some success and am wondering if anyone else has had some success . after random "posts' the unit hangs for no known reason (i think it's the CC3000 library hanging), so after FIVE loops i disconnect the CC3000 and reconnect to my router and start all over again.
My main thought is to simplify  the "post" with all sensor data and text into one string to send it to wunderground so I can  use the RAPID FIRE reporting. as i have it now it takes sometime to go line by line to send the data.
PART ONE of Full Code Below!
PART TWO NEXT POST
I am A learner, so be nice please smiley-kitty

Code:
/***************************************************
 * This is an example for the Adafruit CC3000 Wifi Breakout & Shield
 *
 * Designed specifically to work with the Adafruit WiFi products:
 * ----> https://www.adafruit.com/products/1469
 *
 * Adafruit invests time and resources providing this open source code,
 * please support Adafruit and open-source hardware by purchasing
 * products from Adafruit!
 *
 * Written by Limor Fried & Kevin Townsend for Adafruit Industries.  
 * BSD license, all text above must be included in any redistribution
 ****************************************************/

/*
This example does a test of the TCP client capability:
 * Initialization
 * Optional: SSID scan
 * AP connection
 * DHCP printout
 * DNS lookup
 * Optional: Ping
 * Connect to website and print out webpage contents
 * Disconnect
 SmartConfig is still beta and kind of works but is not fully vetted!
 It might not work on all networks!
 */
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <Wire.h>
#include <DHT.h>
#include <Adafruit_BMP085.h>
#include "RTClib.h"
//Pins
#define led  12
#define anemometer  2         // Wind speed
//#define rainTip = 3;  // Digital 3, Receive the pulse from Rain HALL EFFECT sensor on pin 3/Interupt 1
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
#define DHTPIN  A0            // DHT 22  (AM2302)
#define winDir  A2            // Wind direction
#define WLAN_SECURITY   WLAN_SEC_WPA2
#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data
#define period  5000          // Measurement period (miliseconds)
#define Wait  5000          // Amount of Time to wait till Re-connecting
#define WLAN_SSID       "XXXXXXXXXXX"           // cannot be longer than 32 characters!
#define WLAN_PASS       "XXXXXXXXX"
#define ID              "KFLFORTM63" //wunderground station
#define PASSWORD        "XXXXXX"
//#define WEBSITE      "rtupdate.wunderground.com"// RapidFire Server 2.5 sec interval
#define WEBSITE      "weatherstation.wunderground.com"//standard server
#define WEBPAGE      "GET /weatherstation/updateweatherstation.php?"
#define DHTTYPE DHT22             // DHT 22  (AM2302)
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2); // you can change this clock speed
DHT dht(DHTPIN, DHTTYPE);         // DHT 22  (AM2302)
Adafruit_BMP085 bmp;              // BMP Sensor

RTC_DS1307 rtc;
const float pi = 3.14159265;      // pi, not apple, not pumpkin, not pizza, not even related to Raspberry Pi. http://www.raspberrypi.org/ This is the REAL PI for Wind speed calculations
//int period = 5000;          // Measurement period (miliseconds)
//int Wait = 5000;          // Amount of Time to wait till Re-connecting
const int radio = 65;             // Radius from vertical anemometer axis to a cup center (mm)
unsigned int counter = 0;         // pulse count for wind sensor
unsigned int RPM = 0;             // Revolutions per minute
unsigned int Sample = 0;          // Sample number
//unsigned int timesConnected = 0;  // WiFi conections
float speedwind = 0 / 0.445 ;      // Wind speed (m/s)
float winddir = 0;         // Wind direction

//---DEWPOINT
double dewPoint(double tempf, double Humi)
{
  double A0= 373.15/(273.15 + tempf);
  double SUM = -7.90298 * (A0-1);
  SUM += 5.02808 * log10(A0);
  SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
  SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
  SUM += log10(1013.246);
  double VP = pow(10, SUM-3) * Humi;
  double T = log(VP/0.61078);   // temp var
  return (241.88 * T) / (17.558-T);
}
//---DEWPOINT

uint32_t ip;
void setup(void)
{  
  Serial.begin(115200);
  pinMode(led, OUTPUT);
 digitalWrite(led, LOW);
  bmp.begin();
  Wire.begin();
  
  pinMode(anemometer, INPUT);
  digitalWrite(anemometer, HIGH);
  rtc.begin();
  //rtc.adjust(DateTime(__DATE__, __TIME__));
  Serial.println(F("CC3000 Wunderground Test!\n"));
  dht.begin();// Connect the DHT22 sensor
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
   // Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  Serial.println(F("Connected!"));
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
    ip = 0;
  Serial.print(WEBSITE);
  Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
  //timesConnected++;
  Serial.println();
}
void loop(void)
{
  if (Sample >= 5){

    Sample = 0;
   Serial.println(F("\n\nDisconnecting"));
  cc3000.disconnect();
  delay(10);
    Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
   // Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  Serial.println(F("Connected!"));
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
    ip = 0;
  Serial.print(WEBSITE);
  Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
  //timesConnected++;
  Serial.println();
 }
Sample ++;
windvelocity();
RPMcalc();
WindSpeed();
Heading();
  float tempf = dht.readTemperature(2);
  float Humi = dht.readHumidity();
  float baromin = bmp.readPressure()* 0.0002953;
  float maxwind = 0 / 0.445;
  float Dew = (dewPoint(dht.readTemperature(2), dht.readHumidity()));
  if (speedwind > maxwind) {
    maxwind = speedwind;
  }
  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
  if (client.connected()) {
    Serial.println("Sending DATA ");
    digitalWrite(led, HIGH);
    Serial.print(" Sample # ");
    Serial.println(Sample);
    Serial.println("-------------------------------------");
    DateTime now = rtc.now();
    //  Serial.print(WEBSITE);
    client.print("GET /weatherstation/updateweatherstation.php?");
    client.print("ID=");
    client.print(ID);
    client.print("&PASSWORD=");
    client.print(PASSWORD);
    client.print("&dateutc=");
    client.print(now.year());
    client.print("-");
    client.print(now.month());
    client.print("-");
    client.print(now.day());
    client.print("+");
    client.print(now.hour()+ 5);
    client.print("%3A");
    client.print(now.minute()+ 2);
    client.print("%3A");
    client.print(now.second());
    digitalWrite(led, LOW);
    client.print("&winddir=");
    client.print(winddir);
    digitalWrite(led, HIGH);
    client.print("&windspeedmph=");
    client.print(speedwind);
    digitalWrite(led, LOW);
    client.print("&windgustmph=");
    client.print(maxwind);
    digitalWrite(led, HIGH);
    client.print("&rainin=0");
    //client.print("0");
    digitalWrite(led, LOW);
    client.print("&tempf=");
    client.print(tempf);
    digitalWrite(led, HIGH);
    client.print("&baromin=");
    client.print(baromin);
    digitalWrite(led, LOW);
    client.print("&dewptf=");
    client.print(Dew);
    digitalWrite(led, HIGH);
    client.print("&humidity=");
    client.print(Humi);
    digitalWrite(led, LOW);
    client.print("&action=updateraw");
    client.println();
    digitalWrite(led, HIGH);
    //delay(10);
    digitalWrite(led, LOW);
  }
  else {
    Serial.println(F("Connection failed"));    
    return;
  }
  Serial.println("Server Responce!");
  unsigned long lastRead = millis();
  while (client.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
      lastRead = millis();
    }
  }
  client.close();
  Serial.println("-------------------------------------");
  Serial.print("Waiting ");
  Serial.print(Wait/1000.0);
  Serial.println(" seconds.");
  delay(Wait);// 30sec
  Serial.println();
  Serial.println("-------------------------------------");
 
}//end loop
3  Topics / Robotics / Re: Remote Telescope on: October 22, 2013, 07:56:50 am
You should take a look at this site http://www.weasner.com/etx/menu.html I think I saw a few posts about mods being done to the scopes with arduinos
4  Using Arduino / Displays / Re: 2.8 TFT Touch Shield: Nothing Displayed on: September 27, 2013, 08:56:58 am
Sorry i lost this.
The goofy reason is that SEED is using the TFT library from Adafruit which calls for the SPI for use with it's TFT hardware ST7735.
I know it sounds cumbersome and a waste of memory but thats what we get when we buy sub-standard hardware.

Error=
Code:
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:59: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp: In member function 'void Adafruit_ST7735::commonInit(uint8_t*)':
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:272: error: 'SPI' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:276: error: 'SPI_CLOCK_DIV4' was not declared in this scope
C:\Program Files\Arduino\libraries\TFT\utility\Adafruit_ST7735.cpp:279: error: 'SPI_MODE0' was not declared in this scope
5  Using Arduino / Displays / Re: 2.8 TFT Touch Shield: Nothing Displayed on: July 28, 2013, 08:18:11 am
When you first open the demo sketch that comes with the library it has actually has 2 sketches. goto the second tab select all and delete or make a new sketch and copy all the demo sketch to it
YOU MUST INCLUDE SPI and have the ADAFRUIT ST7735 library installed if it didnt come with the Seeed TFT library (In sub folder UTILITY)
You must also open the config file and replace "def SEEEDUINO"(line 7 in the TFT.h file)with def MEGA if using a MEGA. You do not need to do this for the UNO!!!!!!!!!!!!!!!!!!!!!!!!!

This is what I have come up with to make mine werk.
Code:
// THIS SKETCH IS FOR THE MEGA
//Binary sketch size: 20,914 bytes (of a 258,048 byte maximum)

#include <SPI.h>// MUST INCLUDE THIS for the TFT because the adafruit_ST7735 library uses it, (Seeed hijacked it to make their TFT werk and it compiles with very thing else so watch your memory)
#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <stdint.h>
#include <TouchScreen.h>
#include <TFT.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

#define YP A2   // must be an analog pin, use "An" notation!
#define XM A1   // must be an analog pin, use "An" notation!
#define YM 54   // can be a digital pin, this is A0
#define XP 57   // can be a digital pin, this is A3 #define GPSECHO  false
#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940
#define GPSECHO  false
#define displayTemp
#define gpsHOUR  GPS.hour - 4//neg 4 for the eastern U.S.
Adafruit_BMP085 bmp;
Adafruit_GPS GPS(&Serial1);
int highT = 0.0 ; // Top temp
long runningT;
int SampleT;
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
char Temp [32];//BMP
char Baro [32];//BMP
char Alti [32];//BMP
char Hour [32];//TIME
char Min [32];//TIME
char Sec [32];//TIME
char Lat [32];//GPS
char Lon [32];//GPS

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //init TouchScreen port pins
void setup()
{
  Serial.begin(115200); // com19 on CPU
  bmp.begin();
  Tft.init();  //init TFT library
  pinMode(0,OUTPUT);
  
  Serial.println("Adafruit GPS library basic test!");
  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 1 Hz update rate
  useInterrupt(true);
  delay(1000);
  // Ask for firmware version
  Serial1.println(PMTK_Q_RELEASE);
  Tft.fillRectangle(100,200,30,30,GREEN);
}


  //Tft.setDisplayDirect(DOWN2UP);

uint32_t timer = millis();
void loop(){
  
  // a point object holds x y and z coordinates.
  Point p = ts.getPoint();

  //map the ADC value read to into pixel co-ordinates

  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
  p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
  
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > ts.pressureThreshhold) {
  
 
 // Detect  paint brush color change
 if(p.y < 200)
  {
    if(p.x >= 99 && p.x < 120)
        {
      (GPS.LOCUS_StartLogger());
      Tft.drawString  ("Logging",0,140,2.5,GREEN );
    }
  }
 }
  
  
  
  if (! usingInterrupt) {
    char c = GPS.read();
    if (GPSECHO)
      if (c) UDR0 = c;
  }
  if (GPS.newNMEAreceived()) {
  if (!GPS.parse(GPS.lastNMEA()))  
      return;
  }
  if (timer > millis())  timer = millis();

  // approximately every 2 seconds or so, print out the current stats
  if (millis() - timer > 100) {
    timer = millis(); // reset the timer
    float x = (GPS.latitude);
    int x1=(x-(int)x)*10000;//kick it to the "k" to get all the digits 100 only gives 2 digits after the decimal
    sprintf(Lat, "%0d.%d",(int)x,x1);
    //Baro
    float y = (GPS.longitude);
    int y1=(y-(int)y)*10000;//kick it to the "k" to get all the digits 100 only gives 2 digits after the decimal
    sprintf(Lon, "%0d.%d",(int)y,y1);
    //BMP085 Alt
    //adjust for pressure at sea level and convert from meters to feet."
    float a = (bmp.readAltitude(102500)/3.3);
    int a1=(a-(int)a)*100;//only need Hundredths to get all the digits
    sprintf(Alti, "%0d.%d",(int)a,a1);
    //Baro
    float b = (bmp.readPressure()* 0.0002953);
    int b1=(b-(int)b)*100;//only need Hundredths to get all the digits
    sprintf(Baro, "%0d.%d",(int)b,b1);
    //Temp
    float t = bmp.readTemperature();
    int t1=(t-(int)t)*100;//only need Hundredths to get all the digits
    sprintf(Temp, "%0d.%d",(int)t,t1);
  
/*
if you want to display TIME
    float h = (gpsHOUR);
    int h1=(h-(int)h)*100;
    sprintf(Hour, "%0d",(int)h,h1);//Dont need All the other numbers after the Hour so kill the ".%d".

    float m = ((GPS.minute), DEC);
    int m1=(m-(int)m)*100;
    sprintf(Min, "%0d",(int)m,m1);//Dont need All the other numbers after the Mnutes so kill the ".%d".

    float s = ((GPS.seconds), DEC);
    int s1=(t-(int)s)*100;
    sprintf(Sec, "%0d",(int)s,s1);//Dont need All the other numbers after the Seconds so kill the ".%d".
    */
    
    // =================================for sideways display=================================
    //Tft.fillRectangle (100,160,30,30,RED);//Test
    //Tft.fillRectangle (0,0,50,320,YELLOW);//temp box
    //Tft.fillRectangle (51,51,50,320,BLUE);//Baro box
    //Tft.setDisplayDirect(DOWN2UP);// USB plug to the left
    // =================================for sideways display=================================
    //----------------------Display function------------------------------------
  //BMP085 Temp display
    Tft.drawString   ("Temp: ",0,10,2.5,BLUE);
    //Change the color of the Temp reading when it gets Above or Below a set point
    if (t > 80.00){
      Tft.drawString  ( Temp,100,10,2.5,RED);
    }
    if (t < 80.00){
      Tft.drawString  ( Temp,100,10,2.5,GREEN );
    }
    Tft.drawString     ("*F",200,10,2.5,GREEN );
    //Baro display  
    Tft.drawString    ("Baro:",0,30,2.5,GREEN );
    Tft.drawString    ( Baro,100,30,2.5,GREEN );
    Tft.drawString     ("Hg",200,30,2.5,GREEN );
    //Alt display
    Tft.drawString    ("Alt :",0,50,2.5,GREEN );
    Tft.drawString     (Alti,100,50,2.5,GREEN );
    Tft.drawString     ("Ft",200,50,2.5,GREEN );
    //delay(5000);

    Tft.drawString     ("N:",0,90,2.5,GREEN );
    Tft.drawString     (Lat,55,90,2.5,GREEN );
    Tft.drawString  ("W:",0,110,2.5,GREEN );
    Tft.drawString    (Lon,55,110,2.5,GREEN );
    delay(100);
    //----------------------Clear function----------------------------------
    //delay(Clear);//(Clear the readings only) set prior to void setup().
//====================TEST=========================
//Put test clear code here
//====================TEST=========================
    Tft.drawString     (Baro,100,30,2.5,BLACK);
    Tft.drawString     (Alti,100,50,2.5,BLACK);
    Tft.drawString   (Lat,55,90,2.5,BLACK);
    Tft.drawString  (Lon,55,110,2.5,BLACK);
    //----------------------Clear function----------------------------------
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *F");
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure()* 0.0002953);
    Serial.println(" Hg");
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude(102500)/3.3);
    Serial.println(" feet");
    Serial.println();
    Serial.print("12 Hour, EST: ");
    if(gpsHOUR > 12){  
      //Serial.print("0");
      Serial.print("0");
      Serial.print((gpsHOUR > 12) ? gpsHOUR - 12 :((gpsHOUR == 0) ? 12 : gpsHOUR ), DEC  ); // Once the clock reaches 12:00 Hrs
      // I take away 12 Hrs from the 24 hour clock and print it out
    }
    else{
      Serial.print(gpsHOUR , DEC ); // Conversion to AM/PM
    }

    Serial.print(':');
    if((GPS.minute) < 10){  // Zero padding if value less than 10 ie."09" instead of "9"
      Serial.print("0"); // keeps the numbers in one place when less than 10
      Serial.print((GPS.minute), DEC);
    }
    else{
      Serial.print((GPS.minute), DEC);
    }
    Serial.print(':');
    if((GPS.seconds) < 10){  // Zero padding if value less than 10 ie."09" instead of "9"
      Serial.print("0");// keeps the numbers in one place when less than 10
      Serial.print((GPS.seconds), DEC);
    }
    else{
      Serial.print((GPS.seconds), DEC);
    }
    if(gpsHOUR < 12){   // Adding the AM/PM sufffix
      Serial.println(" AM");
    }
    else{
      Serial.println(" PM");
    }
    Serial.println();
    Serial.print(Lat);
    Serial.print(GPS.lat);
    Serial.print(", ");
    Serial.print(Lon);
    Serial.println(GPS.lon);
  }
}


// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
  // if you want to debug, this is a good time to do it!
  if (GPSECHO)
    if (c) UDR0 = c;  
    // writing direct to UDR0 is much much faster than Serial.print
    // but only one character can be written at a time.
}
void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  }
  else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }

}

  




6  Using Arduino / Networking, Protocols, and Devices / cuHead v2 on: June 10, 2013, 04:06:23 pm
I don't know if its been covered but I have kinda figured out how to serve up my wind speed and direction data to a local page via cpu/tablet or WiFi enabled smart phone using WiServer.


Code:
/*
 * A simple sketch that uses WiServer to serve a web page
 * Using Davis Instraments Anemometer(reed switch) / Wind Vain (Constant rotational Variable resistor)
 */


#include <WiServer.h>

#include <Wire.h>
#include "RTClib.h"
# define anemom 3
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
RTC_Millis RTC;
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,201};//192.168.1.201 // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"Michie Residence"};// max 32 bytes
unsigned char security_type = 2;// 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"webf113b"}; // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
//-------------------------------------
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
unsigned char wireless_mode = WIRELESS_MODE_INFRA;
//unsigned char wireless_mode = WIRELESS_MODE_ADHOC;
//You can use the defines as well
//unsigned char wireless_mode = 1;
//unsigned char wireless_mode = 2;
//-------------------------------------
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


//----Begin Anemometer Params------------------
const float pi = 3.14159265;  // pi number
volatile byte rpmcount;
 unsigned int rpm;
 unsigned long timeold;
 int radio = 50;//Diameter of the wind speed meter from the center of rotation to the center of one of the "CUP'S"
 //----END Anemometer Params------------------
 
// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
 
  //----Anemometer Readinigs------------------
  float voltage = analogRead(A4) * (3.3 / 1023.0);//read the voltage from the wind vane
  float RPM = rpm;
  float speedwind =  ((2 * pi * radio * RPM)/60) / 1000;  // Calculate wind speed on m/s
  float wind =  ((speedwind) /2 / 0.445);
  DateTime now = RTC.now();
    const uint8_t h = now.hour();
    const uint8_t hr_12 = h%12;
    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
     
        // Use WiServer's print and println functions to write out the page content
        WiServer.print("<HTML><HEAD><meta http-equiv='REFRESH' content='5;url=/'></HEAD></HTML>");
        WiServer.print("<html>");
    WiServer.print("Current Time:    ");
    if(hr_12 < 10){                                      // Zero padding if value less than 10 ie."09" instead of "9"
      WiServer.print(" ");
      WiServer.print((h > 12) ? h - 12 : ((h == 0) ? 12 : h), DEC); // Conversion to AM/PM 
    }
    else{
      WiServer.print((h > 12) ? h - 12 : ((h == 0) ? 12 : h), DEC); // Conversion to AM/PM
    }
    WiServer.print(':');
    if(now.minute() < 10){                               // Zero padding if value less than 10 ie."09" instead of "9"
      WiServer.print("0");
      WiServer.print(now.minute(), DEC);
    }
    else{
      WiServer.print(now.minute(), DEC);
    }
    if(h < 12){                                          // Adding the AM/PM sufffix
      WiServer.print(" AM");
    }
    else{
      WiServer.print(" PM");
    }
   
        WiServer.print("<br />");
        WiServer.print(" Winds are:        ");
        WiServer.print (wind);
        WiServer.print(" MPH               ");
        WiServer.print("<br />");
        WiServer.print(" from the:         ");
        //print out the direction according to the voltage
      if ((voltage >= 3.01)||(voltage < 0.10))WiServer.println(" N   ");
      if ((voltage >= 0.11)&&(voltage < 0.25))WiServer.println(" NNE ");
      if ((voltage >= 0.26)&&(voltage < 0.45))WiServer.println(" NE  ");
      if ((voltage >= 0.46)&&(voltage < 0.65))WiServer.println(" ENE ");
      if ((voltage >= 0.66)&&(voltage < 0.85))WiServer.println(" E   ");
      if ((voltage >= 0.86)&&(voltage < 1.00))WiServer.println(" ESE ");
      if ((voltage >= 1.01)&&(voltage < 1.20))WiServer.println(" SE  ");
      if ((voltage >= 1.21)&&(voltage < 1.30))WiServer.println(" SSE ");
      if ((voltage >= 1.31)&&(voltage < 1.55))WiServer.println(" S   ");
      if ((voltage >= 1.56)&&(voltage < 1.76))WiServer.println(" SSW ");
      if ((voltage >= 1.77)&&(voltage < 1.97))WiServer.println(" SW  ");
      if ((voltage >= 1.98)&&(voltage < 2.20))WiServer.println(" WSW ");
      if ((voltage >= 2.21)&&(voltage < 2.40))WiServer.println(" W   ");
      if ((voltage >= 2.41)&&(voltage < 2.60))WiServer.println(" WNW ");
      if ((voltage >= 2.61)&&(voltage < 2.85))WiServer.println(" NW  ");
      if ((voltage >= 2.86)&&(voltage < 3.00))WiServer.println(" NNW ");
      WiServer.println("<br />");
       
        WiServer.print(" RPM:           ");
        WiServer.println (RPM);
       
       
        WiServer.print("</html>");
       
        // URL was recognized
        return true;
    }
    // URL not found
    return false;
}


void setup() {
  // Initialize WiServer and have it use the sendMyPage function to serve pages
  WiServer.init(sendMyPage);
 
  // Enable Serial output and ask WiServer to generate log messages (optional)
  Serial.begin(57600);
  Serial.println("Starting wind speed mesurments");
   RTC.begin(DateTime(__DATE__, __TIME__));
  WiServer.enableVerboseMode(true);
   //----Anemometer Connected to Dig pin 3------------------
  attachInterrupt(1, rpm_fun, FALLING);  //to detect when the switch is opened/closed using 3.3volts to power a reed switch in the anemometer
   rpmcount = 0;
   rpm = 0;
   timeold = 0;
}

void loop(){

  // Run WiServer
  WiServer.server_task();
 if (rpmcount >= 20) {
     //Update RPM every 20 counts, increase this for better RPM resolution,
     //decrease for faster update
     rpm = 15*1000/(millis() - timeold)*rpmcount;
     timeold = millis();
     rpmcount = 0;
     //Serial.println(rpm,DEC);
   }
  delay(10);
}
void rpm_fun()
 {
   rpmcount++;
   //Each rotation, this interrupt function is run twice
 }


7  Using Arduino / Sensors / Re: IR sensor as a cheap lidar on: April 27, 2013, 04:27:32 pm
https://github.com/fmbfla/Arduino/tree/master/radar
Modified from a IR device
8  Using Arduino / Sensors / Re: Pressure Sensor for R134 gas. Air Conditioner. on: April 27, 2013, 04:25:54 pm
I know I am late,
BUT!
You can use any over the shelf R134a P/Sensor(NOT SWITCH) as long as you use one that is suited for the pressure you intend to read.
I.E. Low side would be good (higher resolution) for pressures from  zero up to 150 psi, and high side with a lower resolution up to 450 -500 psi. Use the standard R134a "quick connectors" to attach the sensors to the High and Low side service ports.


OR use the sensors on board the vehicle and incorporate your own "Y" connector to utilize the standard factory installed HI/LOW side sensors with out having to "Pipe into" the system.

Don't forget to add a reading for when the condenser fan should come on and to monitor the RPM's for efficiency
 
You have a Good idea going here
9  Using Arduino / Sensors / Re: Wires from a sensor on a fully rotational servo on: November 18, 2012, 11:01:31 am
https://www.adafruit.com/products/775  for $17.50
Shouldn't be to hard to mount a plate to it, There are larger ones as well.
Hope it helps you!
Pages: [1]