Show Posts
Pages: 1 2 [3]
31  Forum 2005-2010 (read only) / Syntax & Programs / Re: Arduino ethernet webclient php script and mysql on: December 17, 2010, 01:19:16 pm
Here is my latest attempt but it still doesn't work.
database name = 1stClassElec and the table is temp_1
Code:
#include <SPI.h>
#include <WString.h>
#include <Ethernet.h>
#define READING_PIN 0
/*
      Simple Ethernet Test

        Arduino server outputs simple text to browser

      The circuit:
      * Arduino Duemilanove
        * Arduino Ethernet shield
        * Basic FTDI breakout 5V
        *LED connected to GND and digital pin 4 via resistor
      
        By Minde
      http://www.sciencprog.com/
*/

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x11, 0xAC }; //physical mac address
byte ip[] = { 192, 168, 1, 19 };                  // ip in lan
byte gateway[] = { 192, 168, 1, 1 };                  // internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)            
//int ledPin = 4;  // LED pin
//char link[]="http://www.scienceprog.com/"; //link data
String readString = String(30); //string for fetching data from address
//boolean LEDON = false; //LED status flag
//#################################################
    double R1 = 10000.0; //resistance put in parallel
    double V_IN = 5.0;
    double A = 1.129148e-3;
    double B = 2.34125e-4;
    double C = 8.76741e-8;
    double K = 9.5; // mW/dec C – dissipation factor
    double SteinhartHart(double R)
    {
    // calculate temperature
    double logR  = log(R);
    double logR3 = logR * logR * logR;
    return 1.0 / (A + B * logR + C * logR3 );
    }
//#################################################
void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
//  pinMode(ledPin, OUTPUT);  
//enable serial datada print  
  Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
//#############################################
    double adc_raw = analogRead(READING_PIN);
    //Serial.println(adc_raw);
    double V =  adc_raw / 1024 * V_IN;
    //calculate resistance
    double R_th = (R1 * V ) / (V_IN - V);
    double kelvin = SteinhartHart(R_th) - V*V/(K * R_th);
    int celsius = kelvin - 273.15;//was double but changed to int to remove decimal places

    Serial.println();
    client.print("Temp.");
    client.print(" is ");
    client.print(celsius);
    client.println(".C");
    client.print("POST /http://192.168.1.20/ard_log/update_db.php?temp=");
    Serial.print("GET /ard_log/update_db.php?temp=");
    client.print(celsius);
    Serial.print(celsius);
    client.println(" HTTP/1.1");
    Serial.println(" HTTP/1.1");
    client.println("Host: http://192.168.1.20");
    Serial.println("Host: http://192.168.1.20");
    client.println("User-Agent: Arduino");
    Serial.println("User-Agent: Arduino");
    client.println("Accept: text/html");
    Serial.println("Accept: text/html");
    client.println();

    delay(1000);
//##############################################
         //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
32  Forum 2005-2010 (read only) / Syntax & Programs / Arduino ethernet webclient php script and mysql on: December 17, 2010, 08:42:18 am
Hi,

Can somebody help me out as I can't see the answer to my problem.

I'm running an Ethernet Shield with a thermistor and wish to add the values to a mysql database. I know the php script works as I can insert a number instead of (celsius)"); and then run the script and the number appears in the database. My problem is with the sketch which works accept it wont pass the data to the php file which lives at /var/www/ard_log/update.phpThermometer0()
Here is the sketch:
Code:
#include <SPI.h>

#include <WString.h>
#include <Ethernet.h>

#define READING_PIN 0
/*
      Simple Ethernet Test

        Arduino server outputs simple text to browser

      The circuit:
      * Arduino Duemilanove
        * Arduino Ethernet shield
        * Basic FTDI breakout 5V
        *LED connected to GND and digital pin 4 via resistor
      
        By Minde
      http://www.sciencprog.com/
*/

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x11, 0xAC }; //physical mac address
byte ip[] = { 192, 168, 1, 19 };                  // ip in lan
byte gateway[] = { 192, 168, 1, 1 };                  // internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)            
int ledPin = 4;  // LED pin
char link[]="http://www.scienceprog.com/"; //link data
String readString = String(30); //string for fetching data from address
boolean LEDON = false; //LED status flag
//#################################################
   double R1 = 10000.0; //resistance put in parallel
    double V_IN = 5.0;
    double A = 1.129148e-3;
    double B = 2.34125e-4;
    double C = 8.76741e-8;
    double K = 9.5; // mW/dec C – dissipation factor
    double SteinhartHart(double R)
    {
    // calculate temperature
    double logR  = log(R);
    double logR3 = logR * logR * logR;
    return 1.0 / (A + B * logR + C * logR3 );
    }
//#################################################
void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
  pinMode(ledPin, OUTPUT);  
//enable serial datada print  
  Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
//#############################################
    double adc_raw = analogRead(READING_PIN);
    //Serial.println(adc_raw);
    double V =  adc_raw / 1024 * V_IN;
    //calculate resistance
    double R_th = (R1 * V ) / (V_IN - V);
    double kelvin = SteinhartHart(R_th) - V*V/(K * R_th);
    int celsius = kelvin - 273.15;//was double but changed to int to remove decimal places
    Serial.print(celsius);
    Serial.println();
    client.print("Temp.");
    client.print(" is ");
    client.print(celsius);
    client.println(".C");
    client.println("GET /http://192.168.1.20/ard_log/update_db.php?celsius=");
    client.println(celsius);
    client.println(" HTTP/1.1\r\n");
    client.println("Host: http://192.168.1.20");
    client.println();

    delay(1000);
//##############################################
         //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
and here is the php:
Code:
<?php
//Connect to database
$con mysql_connect("xxxx""xxxx""xxxx");
if(!
$con)
 
   &#123;
 
   die('Could not connect: ' .mysql_error());
 
   &#125;
mysql_select_db("1stClassElec"$con);

mysql_query("INSERT INTO device_1(temp) VALUES (celsius)");

mysql_close($con);
?>
Any help would be appreciated as I've spent hours on this problem
33  Forum 2005-2010 (read only) / Interfacing / Re: Trouble Getting TimeNTP Example Running on: December 19, 2010, 01:48:11 pm
I tried it and couldn't get it to work and then found this thread. Lets hope somebody can help!
34  Forum 2005-2010 (read only) / Development / Re: Using Multiple MCP3208 AtoD chips on: August 05, 2009, 02:54:53 am
Thank you for this code, I have changed a couple of lines and it works has I need.

I have another question regards control of the Arduino board.

When the "Serial Monitor" button is clicked data it sent from the Arduino and the second click stops the data.

Is this a command that is sent?

Why I ask is, I'm using VB.net and wish to know if there is a command I need to turn the Arduino on and off or is it just a case of opening and closing the comm port?

Thank you
35  Forum 2005-2010 (read only) / Development / Using Multiple MCP3208 AtoD chips on: August 03, 2009, 01:34:52 am
Hi,
This is my first real project and it requires the use of 2 MCP3208 AtoD converters. I have used the sketch from the Playground which uses a single MCP3208 but I am unable to get it to work with two chips.

The idea is to have each result from the AtoD seperated by a comma and a new line after the 16th measurement.

I have seperate chip select lines for each MCP3208 but get stumped when it comes to coding the Arduino.

Does anybody have a code example to address multiple MCP3208 chips?

Thank you
36  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino paralel  port programmer issues on: July 05, 2010, 08:39:19 am
I have just bought 3 Deumilanove's and one I couldn't program. By swapping boards and chips I narrowed it down to the board and then used the chip in another project so bought a replacement blank chip and set about trying to find what was wrong.

I first needed to burn the bootloader using this http://arduino.cc/en/Hacking/ParallelProgrammer . I couldn't even burn this without a list of errors. After much work I have found that reducing the external DC supply to a point where pin 7 (VCC) on the Atmega chip is about 3.7 volts, allows burning of the boot loader.

I'd be interested to know if this works for others
37  Forum 2005-2010 (read only) / Interfacing / Re: Web Page with Ethernet Shields on: December 09, 2010, 05:01:00 pm
As Rob says, some tutorial would be of help as so far I have been unable to make any progress. Does any one know of a tutorial close to my requirements?
38  Forum 2005-2010 (read only) / Interfacing / Re: Web Page with Ethernet Shields on: December 09, 2010, 07:41:06 am
Sorry for putting it in the Hardware section.

Ian, thank you for your help, I've never used Ajax before so may be back with more questions.

Tony
39  Forum 2005-2010 (read only) / Interfacing / Web Page with Ethernet Shields on: December 09, 2010, 05:11:07 am
Hi,

I have a couple of ethernet shields collecting data on temperature etc. around the home.

I would like to view the data from both shields in a single page in my web browser so I guess this is an html question.

How do I get my html script to look at each shield in turn , collect the data and display it?

Thanks for any help.
40  Forum 2005-2010 (read only) / Interfacing / Re: Arduino data logger with WDT/RTC on: November 02, 2010, 06:20:18 am
tkbyd

Thanks for info, the nuelectronics board is very appealing as I live in the UK.

Thanks to all for your help.
41  Forum 2005-2010 (read only) / Interfacing / Arduino data logger with WDT/RTC on: November 01, 2010, 05:54:40 am
Hi,
I'm trying to build a single channel data logger which will be battery powered so needs to be low powered.

My idea was to read the AtoD and write the value to a SD card every second for 24 hours. Between reads I hoped to put the Arduino Duemilanove to sleep.

I can put the Arduino to sleep OK but what is the best way to wake it every second to take a measurement? I think there are two options, either the WDT or an RTC.

If I use the WDT are there any problems with the bootloader? A code example would be appreciated.

If I use an RTC (this will be a first for me) how do I control it, by SPI? (I have a DS1305) A code example would be appreciated.

Thanks
Pages: 1 2 [3]