Modern Robotics Range Sensor Lirbary Port

Hello,

Im trying to use Modern Robotics Range Sensor (https://modernroboticsinc.com/product/range-sensor/) and I cant seem to import the library. I tried adding the folder to a new project in virtual studio manually but still get errors. Very new to thing so if anyone can send tutorials or helpful link. Thanks

What errors?
How does your project structure look like exactly?
Have you ported the library? It at least needs an #include <Particle.h>

2 Likes

Sorry ScruffR but I dont know how to do that yet. As mentioned very new to library porting. I just need some resources to figure how to do it. So any tutorials or videos would be much appreciated. I want to learn how to do this because there are other libraries I want to use.

I been using the Web IDE so virtual studio is very new to.
Here are the errors
#include errors detected. Please update your includePath.

cannot open source file “avr/wdt.h” (dependency of…

This thread is old but the priciples haven’t changed
https://community.particle.io/t/tutorial-how-to-port-an-arduino-library-to-the-spark-core/3578

Some known changes:

  • application.h is now called Particle.h
  • Spark.xxxxx() should now be Particle.xxxxx()
  • #include <Arduino.h> is now allowed
  • some more compatibility macros have been added to reduce need for inventing the wheel over and over

As for your error message, since Arduinos are based on AVR chips but Particle devices are not, anything HW specific to the AVRs has to be removed/replaced.

1 Like

Hey ScruffR,

I click the link and says
Sorry, you don’t have access to that topic!

I have a few libraries I need to use with particle but not in the Web ide. I dont no much about how to get this done so any tutorial or youtube videos would be appreciated. At this point I am willing to pay someone to just either put the libraries on to particle or if they will give me a link to easy way of doing this.

Sorry, for that - I didn't notice.
You can also have a look here

If you could provide links to the respective original libraries we could have a look how much effort a port would take. Very hardware specific libraries would be way more complicated than high level libraries.

Hey ScruffR, thanks for your reply.

One of the libs I would like to import is

Any help would be appreciated.

What have you tried so far?
I have just copied the library sources as are into a project and it builds without errors.

Since I have no such sensor I can’t test it, but you can
https://go.particle.io/shared_apps/5cdfe8126d5f4a001535cad9

BTW, for this particular sensor there are aleready some threads going
https://community.particle.io/search?q=VL53L1x

1 Like

Thanks ScruffR,
This was a big help. I got everything to work. I also figured it out using virtual studio. I wrote this little bit of code as a test to send data to particle and ubidots. When I send to particle it works great. When I add the code for ubidots, my argon starts to blink red. Do you know what this is about. I tried TCP and webhook and both gives me red light. When I delete the ubidots part it works fine. Red flash is SOS maybe 13 blinks

Would you need my code?

Yup, having a look at your code would definetly help.
I have a hunch what might be going on but I’d better check :blush:

Here is the code. Thanks

// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>

// This #include statement was automatically added by the Particle IDE.
#include "VL53L1X.h"

/*
This example takes range measurements with the VL53L1X and displays additional 
details (status and signal/ambient rates) for each measurement, which can help
you determine whether the sensor is operating normally and the reported range is
valid. The range is in units of mm, and the rates are in units of MCPS (mega 
counts per second).
*/

#include <Wire.h>
#include <VL53L1X.h>

//Ubidots info
//   //Ubdiots
#ifndef TOKEN
#define TOKEN "BBFF-"  // Put here your Ubidots TOKEN
#endif

const char* WEBHOOK_NAME = "tof";

Ubidots ubidots("webhook", UBI_PARTICLE);


VL53L1X sensor;

int Time_old;
char data[64];



void setup()
{
  Serial.begin(115200);
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C

  sensor.setTimeout(500);
  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1);
  }
  
  // Use long distance mode and allow up to 50000 us (50 ms) for a measurement.
  // You can change these settings to adjust the performance of the sensor, but
  // the minimum timing budget is 20 ms for short distance mode and 33 ms for
  // medium and long distance modes. See the VL53L1X datasheet for more
  // information on range and timing limits.
  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  // Start continuous readings at a rate of one measurement every 50 ms (the
  // inter-measurement period). This period should be at least as long as the
  // timing budget.
  sensor.startContinuous(50);
}

void loop()
{
    


if(Time.minute() % 1 == 0 && Time_old != Time.minute()){
     

  sensor.read();
  float distance = sensor.ranging_data.range_mm;
  
  float distanceInches = distance * 0.0393701;


  snprintf(data, sizeof(data), "%0.2f in",distanceInches);
    Particle.publish("ToF", data, PRIVATE);
     
     
    ubidots.add("level", distanceInches);
    
    ubidots.send(WEBHOOK_NAME, PUBLIC);
  Time_old = Time.minute();
}

}

It is a SOS+1 (aka hard fault) panic signal.
That needs some more looking into since that also happens with the Ubidots example.
So I guess it's some issue with the Ubidots library.

1 Like

I have created a new topic referent to Ubidots giving an SOS+1 panic signal, I have tagged as well jotathebest and mariahernandez from Ubidots.

Here’s the link to that topic SOS+1 Ubidots

1 Like

Yes I think it is hard fault