# Modern Robotics Range Sensor Lirbary Port

**URL:** <https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939>\
**Category:** Libraries\
**Created:** [April 5, 2019, 6:22pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939 "2019-04-05T18:22:49Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [April 5, 2019, 6:22pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/1 "2019-04-05T18:22:49Z")

</div>

Hello,

Im trying to use Modern Robotics Range Sensor ([https://modernroboticsinc.com/product/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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [April 6, 2019, 6:20am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/2 "2019-04-06T06:20:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [April 11, 2019, 1:51am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/3 "2019-04-11T01:51:00Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [April 11, 2019, 5:41am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/4 "2019-04-11T05:41:58Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [April 18, 2019, 8:58pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/5 "2019-04-18T20:58:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [April 19, 2019, 7:27am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/6 "2019-04-19T07:27:22Z")

</div>

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

> [@Library List + Porting How To](https://community.particle.io/t/library-list-porting-how-to/8927):
>
> Hi Everyone, After running into some trouble porting libraries to Spark I thought I’d setup a repo to serve as “how to” for porting Arduino/Teensy/etc libraries to Spark. I thought I’d also include a list of ported libraries for easy searching. Here’s the repo: [https://github.com/harrisonhjones/Spark-Ported-Libraries](https://github.com/harrisonhjones/Spark-Ported-Libraries) I’d love some help on the how-to (paging @peekay123) and I could always use some help filling out the library list. Let me know what people think. I’m hoping to get this repo to…

> [@mannydeleon99](#):
>
> At this point I am willing to pay someone to just either put the libraries on to particle

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.

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [May 18, 2019, 1:43am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/7 "2019-05-18T01:43:20Z")

</div>

Hey ScruffR, thanks for your reply.

One of the libs I would like to import is

> **[pololu/vl53l1x-arduino](https://github.com/pololu/vl53l1x-arduino)**
>
> Pololu Arduino library for VL53L1X time-of-flight distance sensor - pololu/vl53l1x-arduino

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [May 18, 2019, 11:11am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/8 "2019-05-18T11:11:39Z")

</div>

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](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](https://community.particle.io/search?q=VL53L1x)

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [May 20, 2019, 5:56am UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/9 "2019-05-20T05:56:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [May 20, 2019, 3:04pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/10 "2019-05-20T15:04:55Z")

</div>

Would you need my code?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [May 20, 2019, 3:33pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/11 "2019-05-20T15:33:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [May 20, 2019, 4:09pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/12 "2019-05-20T16:09:41Z")

</div>

Here is the code. Thanks

```cpp
// 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();
}

}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [May 20, 2019, 5:11pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/13 "2019-05-20T17:11:01Z")

</div>

> [@mannydeleon99](#):
>
> Red flash is SOS maybe 13 blinks

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.

---

<div class="post-metadata">

**Author:** ![mr\_3r](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mr_3r/32/20432_2.png) [@mr\_3r](https://community.particle.io/u/mr_3r)\
**Post date:** [May 20, 2019, 10:38pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/15 "2019-05-20T22:38:46Z")

</div>

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](https://community.particle.io/t/ubidots-causing-sos-1-hard-fault-on-v1-1-0/49890?u=mr_3r)

---

<div class="post-metadata">

**Author:** ![mannydeleon99](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mannydeleon99](https://community.particle.io/u/mannydeleon99)\
**Post date:** [May 21, 2019, 4:07pm UTC](https://community.particle.io/t/modern-robotics-range-sensor-lirbary-port/48939/16 "2019-05-21T16:07:25Z")

</div>

> [@ScruffR](#):
>
> hard fault

Yes I think it is hard fault
