Adding non Particle library in Visual Studio Code Particle Workbench

I have searched and searched for the solution and give up.

I have a AHT20 sensor that I am using for temperature. I have used this sensor with Arduino and Circuitpython with good results. The Library that is in Particle Workbench
SparkFun_Qwiic_Humidity_AHT20_Arduino_Library
Causes my Boron to go into SOS mode.
With the Arduino and Circuit Python I have used the Adafruit_AHTX0 library and it works great. I have copied the library into my lib folder in my project and added

dependencies.Adafruit_AHTX0=2.0.3 into the project.properties

I found the version number in the library.properties

The library is showing up under the lib in the explorer.

I have tried both a “O” and a “0” at the end of the AHTX.

I am still getting a “no such file or directory” error. What am I overlooking ? Or should I just scavenge the bits of code from the library to make this work ? I am trying to learn this and the learning curve has been more of a learning cliff.

Thank you all!

The dependencies entry is only valid when that library actually exist in the Particle online library repository - which it doesn’t AFAICT.

However, when you have that library in your local lib folder it should be possible to build as long the folder structure inside lib is correct and you used the correct #include statement.

Seeing your code may also help :wink:

About your SOS it would be good to know how many slow blinks follow the initial SOS code and also which statement in your code precedes the SOS incident.

2 Likes

On the SOS code I was getting 1 blink which told me hard fault.

Be forewarned I suck at writing code and working to improve, there is a lot that still needs to be done here.

Many parts of the code that I was getting SOS out of have been copied from the example for the AHT20

Below is the code that I experienced the hard fault on. I have removed all the code associated with “AHT20” and have been able to get the board to run code with no surprise issues. When it first happened it went into SOS and it was completely locked up. I had to put it in safe mode, then it would startup, run part of the code and hit SOS and reboot. I do not know where in the code it was hitting the problem, my level of frustration that evening was at 11 and I decided it was better to remove what was causing me an issue rather than troubleshoot it and come up with a solution.

Since the “Adafruit_AHTX0” library is not in the Partible online repository I removed the dependencies entry. I still can not get it to build. I may try that AHT20 library again to see if there was something else that was causing me issues.

#include "LiquidCrystal_I2C_Spark.h"
#include "AnalogSmoother.h"
#include "Arduino.h"
#include "Debounce.h"
#include <Wire.h>
#include <SparkFun_Qwiic_Humidity_AHT20.h>

AHT20 humiditySensor;

// DOOR SWITCHES 
const int door_sw = 8;
// int door_sw = 0;
// Water level LOWLOW Water level LOW
const int water_low_sw = 7;    
// int water_low_sw = 0;
const int water_LOWLOW_sw = 6;
// int water_LOWLOW_sw = 0;
// water_level = ("GOOD", "LOW", "BAD")
// Air Pressure sensor input 
AnalogSmoother gas_pressure(A0, 10);

LiquidCrystal_I2C *lcd;

int lastSecond = 0;

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

void setup()
{
  pinMode(door_sw, INPUT_PULLDOWN);
  pinMode(water_low_sw, INPUT_PULLDOWN);
  pinMode(water_LOWLOW_sw, INPUT_PULLDOWN);
  Serial.begin(115200);
  lcd->println("SHOWER TRAILER 0000");
  lcd->setCursor(0,1);
  Wire.begin();
    //Check if the AHT20 will acknowledge
  if (humiditySensor.begin() == false)
  {
    Serial.println("AHT20 not detected. Please check wiring. Freezing.");
    while (1);
  }
  Serial.println("AHT20 acknowledged.");

  lcd = new LiquidCrystal_I2C(0x3f, 20, 4);
  lcd->init();
  lcd->backlight();
  lcd->clear();

}

void loop() 
{
  //If a new measurement is available
  if (humiditySensor.available() == true)
  {
    //Get the new temperature and humidity value
    float temperature = humiditySensor.getTemperature();
    float humidity = humiditySensor.getHumidity();

    //Print the results
    Serial.print("Temperature: ");
    Serial.print(temperature, 2);
    Serial.print(" C\t");
    Serial.print("Humidity: ");
    Serial.print(humidity, 2);
    Serial.print("% RH");

    Serial.println();
    delay(5000);
  }
}


This is the code I have been currently working out of. When I added the include statement I was able to select the Adafruit_AHT0.h file from the dropdown as I started typing it in.

/* SHOWER TRAILER MONITOR 
* Monitor door position, water level low and LOWLOW switches 
* Monitor temperature via I2C sendor and gas bottle pressure via analog input
* Send information to cloud 2 times a day at 0400, 1200
* Board to sleep mode between transmissions turning off LCD and cellular. Will wake on door switch or wake button 
* When board has been woken up it is to stay awake for 20 minutes, transmit status when woken up and prior to returning to sleep. 
*/ 

#include "AnalogSmoother.h"
#include "Arduino.h"
#include "Debounce.h"
#include <Wire.h>
#include "Adafruit_LiquidCrystal.h"
#include "Adafruit_AHTX0.h"

// WAKE BUTTON
const int wake_sw = 4;
// DOOR SWITCHES 
const int door_sw = 8;
// int door_sw = 0;
// Water level LOWLOW Water level LOW
const int water_low_sw = 5;    
// int water_low_sw = 0;
const int water_LOWLOW_sw = 6;
// int water_LOWLOW_sw = 0;
// water_level = ("GOOD", "LOW", "BAD")
// Air Pressure sensor input 
// AnalogSmoother gas_pressure(A0, 10);
int led = D7;
// int temperature();

LiquidCrystal lcd(0x3f);

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

void setup()
{
  pinMode(door_sw, INPUT_PULLDOWN);
  pinMode(water_low_sw, INPUT_PULLDOWN);
  pinMode(water_LOWLOW_sw, INPUT_PULLDOWN);
  pinMode(led, OUTPUT);
  Serial.begin(115200);
  Serial.print("no idea");
  Wire.begin();
  lcd.begin(20, 4);
  lcd.print("WTF");
}

void loop() 
{
 // int gas_pressure = analogRead(A0);
  Serial.println("SHOWER TRAILER 0000");
  Serial.println("TEMP:100");
  Serial.println((digitalRead(wake_sw)));
  Serial.println((digitalRead(water_low_sw)));
  Serial.println((digitalRead(water_LOWLOW_sw)));
  Serial.println((digitalRead(door_sw)));
  Serial.println((analogRead(A0)));
  digitalWrite(led, HIGH);
  delay(5000);
  digitalWrite(led, LOW);
  delay(1000);
  Serial.println();
    delay(5000);
}


Something is rather fishy here.
You statement is #include "Adafruit_AHTX0.h" but the error message argues that you’ve tried to include without the .h.

Can you open the ST_0000.cpp file and see whether the .h extension is missing there?
Also try to (re)type the header name rather than using a drop-down.

In order to locate the position where the SOS comes from you could add this line before and after each “suspect” statement.

  Serial.println(__LINE__); delay(10);

Since the preprocessor may slightly “shift” line numbers in the final code you may want to add this line at the top of each of your functions to get a reliable baseline.

  Serial.printlnf("%s: %d", __FUNCTION__, __LINE__);

The include statement match in both the .ino and .cpp files. I had tried to type the header name with no luck. I had tried it without the .h at some point, I tried lots of things. At this point I think I need to find another library to get moving forward again, or figure out what I need to use from the library and have it in the main code file instead.

Thank you for the information on finding the cause of the SOS!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.