Productivity Works Data Logger not working

I used Productivity works to implement a basic program and log four temperatures every 5 seconds, but nothing is being added to the .txt file. I was having trouble with logging using IDE, so I tried blocks hoping it would simplify the situation. Can anyone point to where I went wrong?

 

Thanks,

 

#include <P1AM.h>

#include <P1_HSC.h>

#include <SD.h>

 

/******************************************************************************************

 * Automationdirect.com

 * This version of ProductivityBlocks supports P1AM-100 Library V1.0.0

 * To download this library, please visit https://github.com/facts-engineering/P1AM

 * For information on the P1AM-100 hardware, please visit https://www.automationdirect.com

 ******************************************************************************************/

const char _PBVAR_1_ConfigureP104THM_2[] = {

 0x40, 0x03, 

 0x60, 0x05,

 0x21, 0x00,

 0x22, 0x00,

 0x23, 0x00,

 0x24, 0x00,

 0x00, 0x00,

 0x00, 0x00,

 0x00, 0x00,

 0x00, 0x00

};

#define _PBVAR_11_CPU_SDCS_PIN 28

 

double _PBVAR_2_greenhouseTempLast = 0.0 ;

double _PBVAR_3_toteTempLast = 0.0 ;

double _PBVAR_4_bucketTempLast = 0.0 ;

double _PBVAR_5_gardenTempLast = 0.0 ;

int _PBVAR_6_loopStart = 0 ;

double _PBVAR_7_greenhouseTemp = 0.0 ;

double _PBVAR_8_toteTemp = 0.0 ;

double _PBVAR_9_bucketTemp = 0.0 ;

double _PBVAR_10_gardenTemp = 0.0 ;

void __ProBlocksSDWrite(String fileName, String writeString, boolean newLine, int chipSelect) {

 File writeFile = SD.open(fileName, FILE_WRITE);

 if (writeFile){

  writeFile.print(writeString);

  if (newLine){

   writeFile.println("");

  }

 }

 writeFile.close();

}

 

 

void setup()

{

 SD.begin(_PBVAR_11_CPU_SDCS_PIN);

 

 while(!P1.init())

 {

 }

 

 Serial.begin(9600, SERIAL_8N1);

 P1.configureModule(_PBVAR_1_ConfigureP104THM_2, 2);

 _PBVAR_2_greenhouseTempLast = 0.0 ;

 _PBVAR_3_toteTempLast = 0.0 ;

 _PBVAR_4_bucketTempLast = 0.0 ;

 _PBVAR_5_gardenTempLast = 0.0 ;

 

}

 

void loop()

{

 _PBVAR_6_loopStart = millis() ;

 _PBVAR_7_greenhouseTemp = P1.readTemperature(2, 1) ;

 _PBVAR_8_toteTemp = P1.readTemperature(2, 2) ;

 _PBVAR_9_bucketTemp = P1.readTemperature(2, 3) ;

 _PBVAR_10_gardenTemp = P1.readTemperature(2, 4) ;

 if (( ( _PBVAR_7_greenhouseTemp ) > ( 90 ) ))

 {

  P1.writeDiscrete( (uint32_t)HIGH, 1, 1);

  Serial.println("Greenhouse Hot");

 }

 else

 {

  if (( ( _PBVAR_7_greenhouseTemp ) < ( _PBVAR_10_gardenTemp ) ))

  {

   P1.writeDiscrete( (uint32_t)HIGH, 1, 1);

   Serial.println("Outside Hot");

  }

  else

  {

   P1.writeDiscrete( (uint32_t)LOW, 1, 1);

   Serial.println("No Venting");

  }

 }

 if (( ( _PBVAR_8_toteTemp ) < ( 65 ) ))

 {

  P1.writeDiscrete( (uint32_t)HIGH, 1, 2);

  P1.writeDiscrete( (uint32_t)HIGH, 1, 3);

  Serial.println("Tote Cold");

 }

 else

 {

  P1.writeDiscrete( (uint32_t)LOW, 1, 2);

  P1.writeDiscrete( (uint32_t)LOW, 1, 1);

  Serial.println("Tote Warm");

 }

 if (( ( _PBVAR_7_greenhouseTemp ) < ( 40 ) ))

 {

  P1.writeDiscrete( (uint32_t)HIGH, 1, 4);

  P1.writeDiscrete( (uint32_t)HIGH, 1, 5);

  Serial.println("Greenhouse Cold");

 }

 else

 {

  P1.writeDiscrete( (uint32_t)LOW, 1, 4);

  P1.writeDiscrete( (uint32_t)LOW, 1, 5);

  Serial.println("Greenhouse Warm");

 }

 __ProBlocksSDWrite("greenhouse.txt", String(_PBVAR_6_loopStart) + "," + String(_PBVAR_7_greenhouseTemp) + "," + String(_PBVAR_8_toteTemp) + "," + String(_PBVAR_9_bucketTemp) + "," + String(_PBVAR_10_gardenTemp), true, _PBVAR_11_CPU_SDCS_PIN);

 while ( ( ( ( millis() - _PBVAR_6_loopStart ) ) < ( 5000 ) ) )

 {

  delay( 1 );

 }

 

}

 

Sorry, when I enter code it will not let me ask, so I put code in line.

 

Thank you!


  • I'm new, so I guess I will have fond memories of this iteration someday. Thanks for the reply!

    Selected as Best