Servers by jDrones

LW20/C Laser altimeter

Hi everyone,

I have bought 3 Lightware LW20/C. With this new version, the user can select Serial or I2C interface. However, from what I can understand, the protocol (serial or i2c) that will be used for the communication between arducopter and the LW20/C relies on the first command received by the LW20/C. I don’t think in the current arducopter implementation that there is any command send to any rangefinder on the i2c bus. Because of that, I get 0.00 readings on the sonar range. Does anyone have the same issue as me ? Should I contact a specific developper that is in charge of the RangeFinders code ?




Maybe the lidar will work with whichever interface is connected? or maybe the interface used can be selected by first connecting to the lidar with the Lightware terminal software?

It’s possible we could make a change to the driver if it’s necessary to send the lidar a message. I’m a little surprised that’s necessary.

@rdesgagn @rmackay9

Interesting. I will notify Lightware.

Here is the limited info that I know (from Lightware) regarding LW20/B and LW20/C:
“users need to “ping” the device first. This switches the LRF into I2C or Serial mode depending on what type of ping it receives."


OK, great, thanks. I wonder what “ping” means in particular. As far as I know, serial and I2C don’t have a “ping” function so I suspect using this term is just a way to make it easier to understand for the lay user… but we probably need to be more specific about what this means if we need to extend the driver…

1 Like


There have been a few bumps with communication on the new LW20, which as you know can either use i2c or serial over the same pair of wires. I will try to clarify some things here.

When the unit is first powered on it will look for either serial or i2c activity to determine which mode to boot into.

I2C activity can be any activity on the bus, and I believe Ardupilot has no issue with this mode as it sends various I2C checks on the bus before attempting to connect to the LW20. This is indeed by luck however, and ideally the driver will issue 2 commands to check if the LW20 is present. One for the i2c interface activation, and one to get a proper response.

Serial activation requires a serial command to be sent that includes at least 8 edge transitions. So it doesn’t matter what data is sent, as long as 8 edges are present. This would definitely need to be an addition to the driver.

Another solution, as Randy suggested, is that the LW20 can be preconfigured so that the interface always boots in either serial or I2C mode. We have an upgrader tool that allows both firmware upgrades, and the switching of interface mode.

@rdesgagn There has been an issue noted where it is possible to receive 0.00 readings over the i2c. I would advise you update the LW20 firmware to V1.1.3.

(Please see:


Just tested my SF20/C (same unit without case) on a Pixhawk 2.1:

  • Works on 3.6.0 RC7 ChibiOS (tested gps i2c and secondary i2c)
  • Works on 3.5.7 (latest stable) (tested gps i2c and secondary i2c)

Didn’t do any particular setup excluding the ordinary rangefinder type.



1 Like


Thanks very much for the detailed info. I’ve created an issue pointing back to this discussion so we don’t forget about this request.

I guess the point is that we could send any info to the sensor at startup to make it initialise to use the correct interface. That’s not a big change to the driver I think. We’d probably need to get a developer one of the new sensor so we can test for sure the fix works. I personally have a decent number of LW20 but I don’t think I have any of the really new ones with this change… I’ll check.

Hi Rob, first, thanks for the support.

We’ve used LW20/SER for quite some time, and now are trying to get the 20/C to work reliably on ArduCopter. The upgrade tool is helpful for getting them to work with current firmware, however, I’ve encountered some worrying power-related problems with it.

After installing the 1.1.3 firmware and setting serial or “serial with legacy banner” mode, the 20/C becomes readable on the Telem 1 port. However, it does not work on any other serial port, and I discovered that this is because it overdraws the supply power. The Telem 1 port has a dedicated 1.5A supply meant for radio transmitters, so the 20/C works. However, in this configuration, the Pixhawk fails to boot via USB: the bootloader is not recognized as a device, and the Pixhawk does not attempt to boot normally. I am uncertain yet whether it is overdrawing my USB port, or if the overcurrent is internal to the Pixhawk.

I can boot via USB with the lidar unplugged, then plug it in after the Pixhawk is booted. It works normally in this case.

When the lidar is plugged into any other serial or I2C port, it instantly overdraws the peripheral power supply. This is visible in these disarmed logs:

The only other device plugged into the Pixhawk 2.1 was a HERE GNSS. The 2.1’s peripheral ports share a 0.5A supply, this means that the 20/C is demanding more than 500 mA by itself! This was not true with the previous LW20/SER and /I2C devices. I have tested three 20/C devices on two Pixhawk 2.1s with the same results.

Interestingly, the “wait for interface” mode appears to work with the existing serial driver in Copter 3.5.7. I’ve tested it quite a bit and it didn’t always work, but I think the power issues were confounding my results. I will test further to see if this mode will work reliably, however the power problems seems to be a critical issue.

1 Like

@Anubis I’ve tried my LW20/C on a Raspberry Pi to verify how many amps it is pulling. I’ve got between 10-25 mA. I plugged it back on my Pixhawk 2.1 and I got about the same amp pull. No reading (Mission Planner is displaying 0.00). I’ve tried with the 1.2.0 firmware and same amps pull.

Interesting. Did you do this after setting force serial mode? Also, the reading in MP is total battery current, which may not be able to measure such low draw, depending on your setup.

I have a few older LW20/SER available, I’ll see if I can do some more testing, as I never encountered this issue with the older ones.

By the way, while playing around with the various modes, I set one of my 20/Cs to initialize in I2C mode. And, of course, I can no longer communicate with it over serial using the upgrade tool! Is the upgrade tool compatible with I2C-to-USB devices like the Devantech USB-ISS?

@Anubis I did the same thing as you (force i2c mode and can’t communicate with it with the upgrade tool). I’ve sent a pm to Rob to see if there is a way to revert to the default parameters. All my tests were done in i2c mode and not serial.

I am implementing support for the Devantech I2C to USB into the Upgrader.

I will have more info on the Pixhawk issue soon.

Okay, I finally had some time to experiment with the 20/C and find out why it was overdrawing the Pixhawk output.

TL;DR: The 20/C draws too much current when it boots up, but not when it is operating. I used a ferrite bead (DigiKey link) to choke the initial current spike. The Lidar now starts up properly and does not brown out the peripheral port when it is plugged in or when the Pixhawk is first powered.

I’m no EE, so I reached my solution through experiment rather than by design. I’ll describe how I reached the solution in case it helps someone more qualified in this field to come up with a better one.

First, I measured the current draw of the 20/C, compared to the older LW20/SER lidars, which do not have this issue. The 20/C draws about 60 mA when it is idly waiting for an initial command, and it draws ~100 mA when operating, either after receiving a serial command, or after being forced into serial mode. This current draw is the same across the 1.0 and 1.1.3 firmwares, and is the same as the older lidars. Clearly, operating current is not the problem.

I therefore suspected that the 20/C might be overdrawing the supply when it is first powered up with some kind of current spike. But there was a twist: whenever I hooked up my oscilloscope or multimeter in series with the supply power, the power issue disappeared! Unfortunately, I am not quite skilled enough with an oscilloscope to capture what was going on, so I instead experimented with a few circuit elements. Here are my results:

  • Extra wire length: I added 3 feet of extra wire to the power line. This actually worked - the lidar no longer caused power issues, and is why the multimeter and oscilloscope made the problem go away. I suspected that the extra inductance from the long wire was smoothing out the current spike.
  • 0.1uF, 1uF, or 10uF capacitor in parallel with power: Did not work. To be expected; capacitors will smooth out voltage, but do little for current fluctuations.
  • Ferrite ring with 8 winds: Didn’t work.
  • 2.2uH inductor: Didn’t work.
  • 1.5k mOhm ferrite bead: Works. The lidar starts up and operates reliably, at least so far.

So, my conclusion is that the 20/C draws too much current when it starts up, causing the PixHawk’s peripheral port to brown out repeatedly until it gives up. My hardware hack seems to work, but I suspect that LightWare will be able to fix this with firmware, because the 20/C’s “wait for command” mode doesn’t cause this power problem, so maybe they will be able to change the forced serial or I2C modes to boot softly, possibly by first booting into “wait” mode.

Lidar with the ferrite bead on the power line.


Tagging @RobGowans. Not sure if tags work when edited into a post.

I’ve got the LW20/C on a Pixhawk 2.1, i have it plugged into the I2C 2 port and am getting zero readings. Is there a way to get it working on the I2C 2 port? What does everyone else have theirs plugged into? Thanks

Hi @Gromitvt10,

I’m in the same boat as you. My LW20/C is plugged into the I2C 2 but I only get 0.0 on the sonar range. You can try to change the boot mode to serial and plug it in a free serial port on the pixhawk 2.1 like @Anubis. We are basically waiting for a firmware update by @RobGowans.

Still don’t get any readings after setting it to force I2C mode? If so, it would be worth checking if you’re having the same power issues that I was. It’s easy to check if you have a HERE GPS plugged in, as you can watch the LEDs. Otherwise, you can use disarmed logging to see the state of the peripheral power.

Hi @Anubis,

I’m using a Zubax but I do have some Here GPS kicking around. I’m busy doing work stuff this week and might not be able to try until this Friday. I will keep you posted.


HI, i’ve updated the LW20 firmware, i’ve changed it to Serial and moved it to the GPS2 port on the PH2.1. I get good readings when i hook it up to the computer but nothing at all when it hook it up to PH2.1. I’ve followed all the instructions and settings for serial hookup, using serial 4 for GPS2 port. Any ideas what is wrong?? I’ve got power, tx, rx ,gnd going to power, tx, rx, gnd. Does it need to be powered separately from the PH2.1? This is driving me nuts!

Servers by jDrones