Pages: [1]   Go Down
Author Topic: Issue getting data into database from DS1820 temperture sensors  (Read 535 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I am try to get my DS1820 temperature sensor addresses in to a mysql database.
I can get all the required field entries I require, temperature, but for the address I can only get the last 2 digits of the address into the database. smiley-sad

This is the function I have created. I am only using 2 temperature sensors.
addresses are  28DCBD4903000093 and  28B59A490300006F
I am wondering if this has to do with the webClient.print() and something else needs to be added like a char array??
the column in the database is set to Name: TempTag, Type: varchar(16), not null.
In the database column I get 93 or 6F
which is making me very confused...

/* Function */
void writeAddress( DeviceAddress deviceAddress )
{
  if( deviceAddress == insideThermometer )
  {
    Serial.println( "inside" );
    for( uint8_t i = 0; i < 8; i++ )
    {
      if( deviceAddress[ i ] < 16 )
      {
        Serial.println( "0" );
        webClient.print( "0" );
      }
      webClient.print( "&TempAddress0=" );
      webClient.print( deviceAddress[ i ], HEX );
    }
   
  }
  else if( deviceAddress == outsideThermometer )
  {
    Serial.println( "outside" );
    for(uint8_t j = 0; j < 8; j ++ )
    {
      if( deviceAddress[ j ] < 16 )
      {
        Serial.println( "0" );
        webClient.print( "0" );
      }
      webClient.print( "&TempAddress1=" );
      webClient.print( deviceAddress[ j ], HEX );
    }
   
  }
}
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 65
Posts: 3638
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I rather suspect that this:
Code:
webClient.print( "&TempAddress0=" );

should be before the for loop, not inside it.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well spotted bill!

also true for - webClient.print( "&TempAddress1=" ); -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks you so much I just tried it out now and I can see the entries in my database tables .... it works!!!!! smiley
I9 really appreciate the help thanks
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maybe you can post the whole code (arduino & mysql side) so people in the future can find it.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: