1

This is my code below. Ive tried to identify the errors. For eg: They asked me to put a colon on a line and although I did, the same error occurred. These are my codes, I know it is a little hard to identify the errors but if anyone understands this please let me know I would greatly appreciate it. Im doing this for a project and I have never used this codes before.

#use "1_Wire_Configure.Lib"         // edit this library or make a copy of it
                                                // to define your hardware

void main ()
{   int presence, CRC, i, j, k;
   float Deg, Volts[4];
   char GetROMaddress[10];
   int DevNbr;
   int Resolution;


    OWConfigure();
    i = OWInit();
   i = OWReset();
   if ( i != OW_ERR_SUCCESS )       // only meaningful for DS2480 interface
   {
    printf ( "Failed to initialize the 1-Wire Interface!\n\r" );
    exit(1);
   }

    do                                              // repeat loop
   {

        i = OWSearchROM ();                 // find all the devices on the bus
       if ( i != OW_ERR_SUCCESS )
    {
            printf ( "No units or too many units found on bus!\n\r" );
        exit (2);
    }
        OWDisplayROM();                     // display them

// DS2450
        j = DevNbr = 0;                     // init for the loop
        while ( j < OW_DeviceCount )        // for each device in the table
        {
        if ( OW_ROMtable[j++][0] == OW_F_DS2450 ) // if DS2450
            {
        for ( i=0; i<=3; i++ )      // init each channel: 16 bits, 5V range
               {
                k = DS2450_Init (DevNbr, i, 16 , OW_OPT_RANGE_HI );
                }
                k = DS2450_Convert ( DevNbr, OW_CHA|OW_CHB|OW_CHC|OW_CHD,
                                OW_SETA|OW_SETB|OW_SETC|OW_SETD );
                OWMsDelay (10);             // allow time for A/D conversions
                k = DS2450_ADRead ( DevNbr, Volts );
               printf ( "DS2450  #%d: Volts: ", DevNbr );
               for (i=0; i<=3; i++ ) printf ( "%8.3f", Volts[i] );
            printf ( "\n\r" );
             DevNbr++;                      // next DS2450
       } // if DS2450
       } // for each device in the table

// DS2406
        j = DevNbr = 0;
        while ( j < OW_DeviceCount )        // for each device in the table
        {
            if ( OW_ROMtable[j++][0] == OW_F_DS2406 ) // if DS2406
           {
        DS2406_PIO ( DevNbr, 1 );   // turn on output A
            i = DS2406_Status (DevNbr); // read the status byte
            printf ( "DS2406  #%d: status = 0x%02X", DevNbr, (char)i );
                OWMsDelay (500);
            DS2406_PIO ( DevNbr, 0 );   // turn off output A
            i = DS2406_Status (DevNbr); // read the status byte
            printf ( "   status = 0x%02X\n\r", (char)i );
             DevNbr++;                      // next DS2406
       } // if DS2406
       } // for each device in the table

// DS18S20
        j = DevNbr = 0;
        while ( j < OW_DeviceCount )        // for each device in the table
        {
        if ( OW_ROMtable[j++][0] == OW_F_DS18S20 ) // if DS18S20
           {
            if ( DevNbr == 0 )          // if "1st" unit
            {
                DS18S20_Convert ( -1 ); // initiate a reading on all units
                OWMsDelay ( 750 );      // allow at least 750msec for conversion
             }
                i = DS18S20_Read ( DevNbr, OW_OPT_DEGF, &Deg ); // get temperature
            printf ( "DS18S20 #%d: Temp = %6.2fF\n\r", DevNbr, Deg );
            DevNbr++;                       // next DS18S20
          } // if DS18S20
    } // for each device in the table

// DS18B20
        Resolution = OW_OPT_9_BITS;
        j = DevNbr = 0;
        while ( j < OW_DeviceCount )        // for each device in the table
        {
        if ( OW_ROMtable[j++][0] == OW_F_DS18B20 ) // if DS18B20
           {
            DS18B20_Convert ( DevNbr, Resolution ); // initiate a reading
           DevNbr++;                        // next DS18B20
          } // if DS18B20
    } // for each device in the table

        OWMsDelay ( (1<<Resolution)*100 ); // time for conversion

        j = DevNbr = 0;
        while ( j < OW_DeviceCount )        // for each device in the table
        {
        if ( OW_ROMtable[j++][0] == OW_F_DS18B20 ) // if DS18B20
           {
                i = DS18B20_Read ( DevNbr, OW_OPT_DEGF, &Deg ); // get the temperature
            printf ( "DS18B20 #%d: Temp = %6.2fF\n\r", DevNbr, Deg );
            DevNbr++;                       // next DS18B20
          } // if DS18B20
    } // for each device in the table

       printf ( "\n\rPress 'r' to repeat:\n\n" );
   } while ( getchar() == 'r' );            // repeat loop
 }

//From the bildr article http://bildr.org/2012/11/hih4030-arduino/

  int const HIH4030_Pin = A0; //analog pin 0
void setup(){
  Serial.begin(9600);
}

void loop(){


  //To properly caculate relative humidity, we need the temperature.
  float temperature = 25; //replace with a thermometer reading if you have it
  float relativeHumidity  = getHumidity(temperature);

  Serial.println(relativeHumidity);


}


float getHumidity(float degreesCelsius){
  //caculate relative humidity
  float supplyVolt = 5.0;

  // read the value from the sensor:
  int HIH4030_Value = analogRead(HIH4030_Pin);
  float voltage = HIH4030_Value/1023. * supplyVolt; // convert to voltage value

    enter code here

  // convert the voltage to a relative humidity
  // - the equation is derived from the HIH-4030/31 datasheet
  // - it is not calibrated to your individual sensor
  //  Table 2 of the sheet shows the may deviate from this line
  float sensorRH = 161.0 * voltage / supplyVolt - 25.8;
  float trueRH = sensorRH / (1.0546 - 0.0026 * degreesCelsius); //temperature adjustment

  return trueRH;
}

    enter code here
  • 1
    I'm quite sure "`enter code here`" isn't a valid command. – Paweł Stawarz Mar 28 '14 at 03:13
  • Omg I think it auto formatted that way when i submitted the question omg – user3462252 Mar 28 '14 at 03:15
  • Very minor: confident should be `voltage = HIH4030_Value/1024. * supplyVolt;` (1024 v 1023) – chux - Reinstate Monica Mar 28 '14 at 03:45
  • Can you give us as many of the error messages that you are getting as possible. – Peter R Mar 28 '14 at 04:20
  • line 138 : ERROR 1-WIRE.C : A0 is out of scope/ not declared. line 140 : ERROR 1-WIRE.C : Invalid expression. line 140 : ERROR 1-WIRE.C : Missing character ';'. line 140 : ERROR 1-WIRE.C : Missing character ';'. line 140 : ERROR 1-WIRE.C : Need a function call. line 140 : ERROR 1-WIRE.C : Invalid struct reference. – user3462252 Mar 28 '14 at 06:44
  • line 140 : ERROR 1-WIRE.C : Serial is out of scope/ not declared. line 141 : ERROR 1-WIRE.C : Missing character ';'. line 147 : ERROR 1-WIRE.C : Dynamic C cannot initialize auto variables. Assign on a separate statement. line 148 : ERROR 1-WIRE.C : Dynamic C cannot initialize auto variables. Assign on a separate statement. 10 errors reached; further errors suppressed. – user3462252 Mar 28 '14 at 06:45
  • @user3462252 Don't post code in comment are but paste to your question window. – Jayesh Bhoi Mar 28 '14 at 06:53

0 Answers0