Marc's Public Blog - Electronics Hacking


All | Aquariums | Arduino | Btrfs | Cars | Cats | Clubbing | Diving | Electronics | Exercising | Flying | Halloween | Hiking | Linux | Linuxha | Monuments | Museums | Public | Rc | Sciencemuseums | Snow | Solar | Trips



Table of Content for electronics:

More pages: May 2020 January 2020 December 2019 April 2019 January 2019 June 2018 May 2018 June 2017 April 2017 May 2016 February 2016 November 2015 October 2015 August 2011 July 2011 May 2011 June 2010




2020/05/04 Hacking Power Supplies and Battery Pack To Get Around ThinkPad P73 Broken Power Supply Design
π 2020-05-04 01:01 in Electronics, Linux
While I wrote this for my Lenovo Thinkpad P73, this is likely equivally relevant to P53, P72, and P52.

Thinkpad P73 vs P70, not a win all around: only one 2.5" drive instead of 2, and a badly designed power system

So, when lenovo came out with the Thinkpad P70, I wasn't very happy because if you had a 90W power supply, it refused to charge from it, at any rate whatsoever. I was not impressed, but eh, at least it would still power the laptop so that its batteries didn't go flat while plugged in.
Well, leave it to lenovo engineers to make things worse the for the P73. The minimum power supply was raised from 135W (170W recommended) to 170W (230W recommended) which is understandable, but lenovo decided to ensure that the laptop will not take any power from any power supply that does not identify itself as 170W or more. This means that even ifit only needs 40W to sustain itself without digging into the batteries, it will completely refuse to use a 90W or even 135W power supply for anything at all, and kill the battery instead. Lenovo, you just plain suck, there is no excuse for this.

P70 vs P73, they look pretty similar
P70 vs P73, they look pretty similar

*Update*: it seems if that if you get a cheaper nvidia chip with the P73, it is then configured to accept 135W power supplies as the minimum required. That said, it will still refuse to work with any regular 90W power supply or external battery back, unless you force it with the center pin resistor swap.

While I have no plans to use windows on that machine, I thought I'd just try it out to see how it does on power. This is where I was impressed, windows can idle at less than 10W for more than 11H runtime, while I'm lucky if I can get linux at 15W. This is definitely a place where linux should do better, of course, it's not as if Lenovo put any work into making linux more efficient on their hardware either:


*Update* : with tlp and using the nouveau driver just enough to turn off the nvidia chip, I'm now able to tune the laptop down to 10W, almost matching windows.
See tlp issue 494 for details on how to setup tlp to run in low power mode when power is plugged in.

Another disappointment is that the P73 is mostly the same size and weight than the P70, but it has less room for storage. It has a bunch of empty spaces that aren't used for anything, and it can't use two 2.5" SATA drives anymore, like the P70 could. Worse, the now single 2.5" slot uses a lenovo only ribbon cable that does not ship with the laptop and basically means you cannot even add a 2.5" drive without that special ribbon cable, which isn't in stock yet. Well done... Ah yes, the battery is also not hot swappable, even if it is replaceable (unlike a Mac laptop where everything is sealed shut).


this shows the unobtanium lenovo cable for the now only single drive that fits, along the unused space
this shows the unobtanium lenovo cable for the now only single drive that fits, along the unused space

Ok, stop complaining, just buy a bunch of 170w or 230W power supplies and move on with your life

Well, yes and no:
  • I literally have 10 power supplies between home and work, not really looking at replacing all 10. Lenovo wants $137 per power supply by the way, even if they are $85 from other sellers
  • those 170W/230W power supplies are huge. They also weigh as much as some small notebooks (!)
  • I have 12V to 20V car adapters, those won't work anymore
  • I have external battery packs for extended runtime, and I haven't found a single one that can deliver the amps a P73 tries to needlessly require
  • Tricking the P70 and P73 into accepting a power supply it wouldn't otherwise use

    Lenovo uses the a center pin resistor to know how much power they can draw from the power supply, see: http://www.thinkwiki.org/wiki/Power_Connector .

    For the P70, I built this power supply adapter with a resistor bridge to tell the laptop how big it should think the power supply, is:


    It's basically a configurable version of this. Yes, lenovo, I thank you for the hours I wasted opening up power supply plugs and replacing the center pin resistors:


    Here's how the P73 responds:

    - 230W works fine   4.6k => I have seen power supplies work with 170W but fail at 230W, so the laptop does draw more
    - 170W works ok     1.9k (1.8k also ok)
    - 130W rejected     1k
    - 90W  rejected     550 

    The rejected power supplies will be used to charge the laptop if it is shutdown, but they will not be used in any way otherwise. On the P70 the laptop would at least use the power supply to keep the laptop alive, and use half battery half external power supply. Not so with the P73, it just ignores it entirely.
    This is utter bullshit as I have plenty of 90W power supplies, including 12V car converters, or a 90W external 20V battery pack I can't use anymore.

    You can go read my Hacking a thinkpad slim tip adapter to output more than 90W (required to charge a Thinkpad P70) page for details, including this nice battery pack I couldn't use anymore:


    *Update* : so, actually with some serious tlp hacking (basically I told it to force battery mode even if a power supply is plugged in), I've managed to throttle the laptop enough, even when plugged in, so that it only uses 20W. At that point, I'm actually able to use my old external battery pack, as well as a 90W power supply, as long as I lie to the laptop and pretend they are 230W power supplies with the resistor trick. In my tests with windows, it was not possible to throttle the laptop enough when plugged in, not to have it overwhelm a smaller power supply (not that 90W is small for a laptop that normally uses 20-30W when it's not charging batteries).
    If you scroll to the bottom of the page, you'll also see a terrible buffer lipo hardware hack I did that allows to use the battery pack with higher amp draws, but it's a bit ridiculous (and bulky).
    See tlp issue 494 for details on how to setup tlp to run in low power mode when power is plugged in.

    Without the tlp hack or the buffer lipo hack, when I lie to the laptop and tell it is connected to a a bigger power supply, manage power draw with what I run, and disable battery charging in software, but the laptop will still draw the power supply for over 100W when you plug it in for a fraction of a second, and refuse it if the voltage drops.
    Obviously this would not be a problem if the laptop simply had a 90W power supply mode where it throttle things down and turned off battery charging. This is mostly what the P70 does.

    In the meantme, on top of hacking my power supplies, I also made this for my laptop, it looks silly and makes the thinkpad not look like a professional laptop, but well, that's lenovo's fault:


    this takes any power supply and replaces the center tip resistor with a 1.9k one to emulate a 170W power supply
    this takes any power supply and replaces the center tip resistor with a 1.9k one to emulate a 170W power supply

    From talking to Lenovo, they don't think that this is really a problem, so since I'm an engineer, I made my own external battery pack, but I otherwise recommend to road warriors to avoid thinkpads from now on, given the backward power design in this one.

    Making a Thinkpad P73 compatible external battery pack

    I did some testing and confirmed that the laptop is very picky about power supplies. It even rejects a 19.7V 20A power supply I had, because it's 19.8V and not 20V. Same thing for amps, it needs to be able to draw maybe around 5A for a short time to accept the power supply (they sure are putting a lot of effort into making sure the power supply is not under-spec'ed).

    Prototype with 150W step up converter which takes my 16V lipo to 20V while delivering enough amps to make the laptop happy:


    it works, and the laptop thinks it's connected to a 230W power supply thanks to the center pin resistor.
    it works, and the laptop thinks it's connected to a 230W power supply thanks to the center pin resistor.

    Here's a quick demo:

    Version 2 was to have a way to recharge the battery pack while it's being used. I've used this to use the battery pack as a buffer to absorb peaks from the laptop without tripping an external power supply, including in a car limited to 100W or a plane power supply limited to even less:

    this works in theory, but the lipo charger is quite slow and wouldn't keep up for long, but I made a better version shown lower down
    this works in theory, but the lipo charger is quite slow and wouldn't keep up for long, but I made a better version shown lower down

    Lenovo's P73 airplane mode simply stops using the external power supply and reverts to batteries. Sigh...

    Oh yes, let's talk about airplane mode. The lenovo engineers thought of everything: if they detect that the power supply drops a few times in a row, they offer a nice setting which is supposed to make the plane more airplane friendly. How friendly you ask? Well, you could throttle down the CPUs, disable battery charging, do smart stuff like that. Or, if you're lenovo, you can have airplane mode simply refuse to use the power supply altogether. Thank you lenovo, you wrote a feature that saves me the trouble of unplugging an otherwise perfectly good power supply that you refuse to use (to be super clear, my 230W power supply is plugged in and airplane mode just disabled it):


    Making a battery pack to act both as buffer for a smaller power supply, and as emergency external power (even power the laptop from 12v)

    Anyway, back to the battery pack, I found the ISDT H605 Air lipo charger which is small enough and can charge the lipo at 5A, which should be enough to keep up with the laptop when not doing CPU crazy stuff. This also allows using a 12V power supply or a lower wattage lenovo power supply to recharge the pack while it's in use, or not:


    version 1 was a bit bigger than I wanted, 90W power supply shown for scale
    version 1 was a bit bigger than I wanted, 90W power supply shown for scale

    here, the 90W power supply is recharging the battery at 2.5A while it's being discharged at 3A on the output side, using the battery as buffer
    here, the 90W power supply is recharging the battery at 2.5A while it's being discharged at 3A on the output side, using the battery as buffer

    I made version 3 a bit smaller, with a built in 12V lipo to act as buffer for a smaller power supply. Yes, it's a beautiful piece of art, I know :)
    I made version 3 a bit smaller, with a built in 12V lipo to act as buffer for a smaller power supply. Yes, it's a beautiful piece of art, I know :)

    Pushed to the extreme, I can now use my original external battery pack again by having it recharge my lipo+150W step up that can output more amps than the ravpower pack can. Of couse, it's inefficient, the ravpower pack outputs 20V that gets down converted to 12V by the H605 Air lipo charger, which charges the built in 3S lipo in the box, and then gets up converted back to 20V without the amp limitation (the phone used to control the lipo charger also inside the box):


    The really cool thing is that by using tlp, it's actually possible to tune the laptop down to very low power use, even when plugged in, something that windows probably can't do:

    7.3W with the screen off (and around 10W with wifi off and the screen on low dim) is not bad for a laptop that big
    7.3W with the screen off (and around 10W with wifi off and the screen on low dim) is not bad for a laptop that big

    4S Lipo vs 4x 18650 or 26650 batteries

    I do have a few lipos laying around, so that's free energy for my laptop if I'm willing to carry them. I have however found that for higher draws, the step up converter doesn't quite keep up at 20V/5A+ with just 12V input (3S), but is fine with 16V input (4S):


    That said, as I recently found out that 16650 (or better 26650) batteries are both lighter and smaller. The only thing the lipos do, is offer a better discharge rate, but while that's useful for a high power RC plane motor that can empty the batteries in 10mn, it's not needed for a laptop:


    Outside of 26650 batteries, there are other ones like https://www.18650batterystore.com/21700-p/samsung-50e.htm .

    26650s are 195 Wh/kg while the lipo I gave was 184Wh/kg. The 3rd battery listed is supposed to be 260Wh/kg which is much nicer, that said, it looks like those samsung batteries are actually smaller than 26650s, lighter, and yet offer the same 5Ah at 3.6V. If so, that's very impressive.

    As of this writing, I have however not found 26650 battery holders that hold 26650 protected cells that are a bit longer. This seems to the be only one available, and it's too short to hold the batteries: https://www.amazon.com/gp/product/B074GVPWSH


    A few months later, I ended up cutting them and taping them to make them longer. It doesn't work great, but it was enough for a few tests. In the end, I found that somehow I wasn't getting enough amps out of them, which surprised me, so they didn't work that well compared to a lipo:


    Conclusion

    Lenovo, please make the P73 work like the P70, and fix this airplane mode thing that turns off the external power supply. That's embarrassing...
    2020/01/14 Linux.conf.au Open Hardware Miniconf 2020: Dingo Car with Tensorflow Video Analysis v2
    π 2020-01-14 01:01 in Arduino, Electronics, Linux
    Another LCA, another Open Hardware Miniconf. This year was an improved version of the Dingo Car from last year.

    Jon, presenting the miniconf as per how many
    Jon, presenting the miniconf as per how many





    Raspberry Pi running the car
    Raspberry Pi running the car



    This year's dingo car, controlled by the rPi
    This year's dingo car, controlled by the rPi

    All done
    All done

    Andy presenting the software side of the car
    Andy presenting the software side of the car

    We then trained our cars' neural network by manually driving them arount the track:


    and before long, I got my car to drive around on its own
    and before long, I got my car to drive around on its own

    Here is a video of my car driving on its own, including how it learned to drive:

    During the miniconf, I also gave a talk on my recent LED panel/ESP32 work and brought my recent RGBPanels:


    2019/12/01 Using a Tesla Model 3 as Emergency Power Source In Case of Grid Failure
    π 2019-12-01 01:01 in Cars, Electronics
    Iwas interested in getting a decent amount of amps from my car while it's parked at home if I'm in a power emergency situation (i.e. no power) for maybe 2-3 days (as sadly is now a new "normal" in california).

    I knew that this could void the warranty on some parts of the car. I was ok with that. Tesla wants me to buy a powerwall, but I think powerwalls are stupid.

    I'd need to spend $30 to $40K in powerwalls to get the same amount of energy I already have in my car and I already paid for. Sorry, but I'm not spending that much for something I may need once every few years. Load shifting my solar in california is otherwise a straight loss, and PG&E forces some silly rules about not allow using powerwalls for time of use power arbitration if you accept the buying credit for them. You get penalized for helping take the peaks off the grid, yeah bureaucracy!
    If tesla sold a powerwall that would allow using your car as a battery source for emergencies only (car batteries are not designed for daily cycling like powerwalls), I'd be super interested, but they do not, so I decided to make my own answer.

    I knew that I could probably only get 2-3000W out of my car, honestly for emergency use (a couple of fridges and essential equipment), that's good enough. Sure, it wouldn't power all my house lights, or even my furnace for heating (which happens to use over 1000W just to run the fans), but eh, it's for emergency use only, so good enough.

    Plugging into the standby 12V battery

    What I knew from the beginning is that the battery in the car is way too small to power a proper size inverter (I have a 3000W one to be safe but honestly I only plan on using 1000W peak for my fridge and an average of 200W otherwise when the fridge is on). What I didn't know is that the Model 3 only provides trickle charge power to the battery, enough to charge it for normal use in the car, but not enough to recharge it if you plug a reasonable inverter into it (it will discharge quicker than it can recharge).

    My plan was to connect a big GLA 12V battery in parallel with the car's battery, so that it could absorb big peaks and buffer a it longer in case the car's battery recharge didn't kick in quickly enough. I did however confirm that the car's DC-DC system only recharges the standby battery at a slow rate, so it was not adequate for my need.

    Plugging into the cigarette lighter adapter

    For some uses, it would work to use some DC-DC charging system to recharge a big 12V battery external to the car and try to keep the car awake as much as possible so that the 12V CLA port stays on. The only issue with that plan is that you can only get about 12A sustained from it, so if you are planning on using over 100W average, this will not work in the end. In my case, my fridge was more in the 200W range.

    Tapping into the car's DC-DC system

    This is where things get interesting. The car's battery pack is in the 400V range, and 400V DC will definitely kill you (DC is actually worse than AC), so don't even think about messing with that unless you are truly a trained professional.
    For the rest of us, what you need to know is that the car has a DC-DC converter that turns 400V into 14V DC. This is used to power the car's systems when it's not sleeping, as well as recharge the small 12V battery that keeps things alive when the car is asleep. The idea is to tap directly into that 12V system which I'm told can provide up to 200A/2000W (which converted to 120V is really only 20A). A few things to note:
  • The 12V tap is available under the rear seats which you can remove by pushing to clips sideways
  • Connecting to ground is easy, connecting to the 12V pole is a bit more tricky. It's best to leave the current cable in there as it needs a perfect connection to conduct all the amps it's meant to carry. You can however add a 2nd connector on top of it an add a second nut on top (the bolt it long enough for this, and it seems to be purposely so)
  • If the DC-DC senses a short, it will shut down to protect itself. This is good, but also bad. The problem is that after it shuts down, it doesn't reset easily, or at all. Once it's shutdown, your standby 12V battery will discharge without being recharged, until it dies. You can recharge it with a 12V battery charger, but obviously this is only a temporary measure
  • If your DC-DC converter does not reset, you need to disconnect the 12V battery entirely, causing the entire car to shudown and reset. When I did that, my DC-DC converter came back online
  • Where it gets interesting, is that inverters come with a big capacitor to allow for transient loads. Those capacitors will take almost infinite energy when you connect them, causing a big spark, and looking like a short, causing the very undesirable shutdown explained above.
  • The solution is to wire a big resistor in front of your inverter so that it can charge its capacitor slowly
  • Then add a 200A relay to bypass the resistor when the inverter is 'charged'. The relay can be powered by connecting it to the inverter itself on the 12V side, making it so that when the capacitor is charged, the voltage across the inverter poles is high enough to actuate the relay and bypass the resistor.
  • The 2 white holes are where the clips that you need to release. are located. You can also see the black and red tap points:


    Building it up without resistor and protection relay

    Some inverters are actually polite and do not grab 200A+ as soon as you connect the wire. If you have a spare battery, see if the inverter creates a spark when you connect it the first time. If it does, it's bad news and will want to slow down the current with a resistor, and which is tricky (see below). It could be 1 Ohm, or 100 Ohms, really depends on the inverter.

    If you do not see a spark, you may just be able to connect the inverter dirctly to your car with just wires (although if that works wrong, it will trip the DC-DC converter in the car, and require a full car reset to bring it back online).

    Building it up

    If you do have a spark when connected to a battery, you'll have to play trial and error with resistors. If the resistor is too big, too much voltage will drop, you'll never get 12V across the inverter and the relay will never activate (which is what you seem to have). If the resistor is too low, too many amps will flow and the DC-DC may trip, requiring the full reset trip. I used this:
  • 2000W pure sine wave inverter: https://www.amazon.com/SUDOKEJI-Inverter-2000W-Display-Outlets/dp/B07RWHN22W
  • 3000W NOT pure sine wave (cheaper and probably good enough for most loads): https://www.amazon.com/gp/product/B07FK3M6BB
  • 200A 12V relay: https://www.amazon.com/gp/product/B01MYPTVJD
  • 150 Ohm 25W resistor: https://www.amazon.com/gp/product/B07C1VGNFF . Ok, this one is tricky, maybe your inverter will require a 50 Ohm one, or a 25 Ohm. There is no right answer that works for all. You could buy 4 or 6, and by putting them in parallel (4 will drop 150Ohm to 32 Ohm, 6 will drop it down to 25 Ohm).
  • Optional 200A hall sensor meter: https://www.amazon.com/gp/product/B07D35MFBQ
  • Originally I tried those:

  • 100W 1.8Ohm: https://www.amazon.com/gp/product/B01N0XZN1F/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1 (resistor was too small and the inverter charged too quickly, tripping the DC-DC conerter) . But as said above, 150 Ohms may be too much, so you may have to do trial and error as explained above.
  • Optional 100A energy meter: https://www.amazon.com/gp/product/B013PKYILS/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1
  • What happens is:

  • battery gets connected or DC-DC system turns on
  • resistor limits current and starts charging the capacitor in the inverter, slowly bringing the voltage across its poles from 0V to 12V
  • voltage across the inverter starts rising until 10V or whatever
  • once it's enough, the relay is energized and bypasses the resistor. If the resistor it too high, you will not get 12V and this step never happens. you can use a voltmeter to check. If that's the case, add resistors in parallel until it works.
  • now 200A can go to the inverter and no spark/current inrush was created, and your DC-DC converter doesn't shutdown when it turns on
  • This shows the current meter shunt connected to the bypass relay (which is powered by the connectors on the inverter side). You then see the thick 100W resistor connected in parallel with the relay. This allows current to flow more slowly and ramp up the connection:




    I tested a 1300W microwave which worked without issues, so did my fridge and other devices. The pure sine wave inverter is very important for a microwave, but a cheaper inverter worked well enough for my fridge and basic loads.

    Since we're talking about currents of 100A or more, we need to talk about wire gauge. The inverter I got came with 10AWG cables of about 1m. These cables are insufficient for 100A (never mind 200A), but in real life will mostly work for short distances and as long as you don't use the full power continuously (which could technically heat up the cable enough to melt its insulation and cause a short eventually). In my tests with 100A, I lost 0.7V due to inadequate wiring:

  • 0.25V lost in each of the two 10AWG cables (good quality)
  • Extra wire from relay to inverter lost 0.06V
  • 200A relay only lost 0.06V
  • 100A shunt for power meter lost 0.1V (and gets warm)
  • Given that the car outputs 13.5 to 14V, this drop is not big enough to matter since the inverter works all the way down to 10V or so, but be mindful of potential heat. Here is the end result:



    Keeping the DC-DC system awake

    One thing that you still need, it to keep the car from going to sleep if you want the DC-DC converter to stay on. Thankfully a recent software update added camper mode. You can just go in the climate screen/fan icon, set the car in park, and set 'keep climate on' to 'Camp', turn off AC and set the temperature to something low in order to save batteries (i.e. not waste the batteries into climate control).
    If you know of a more battery efficient way to keep the DC-DC system on without having to run climate or even having the control screens on, let me know (contact Email link at the bottom of this page). Hell, if you build one and get it working, shoot me an Email too :)

    Backfeeding your house

    If you really know what you're doing, you could use this with a custom made male-male outlet, to backfeed one or both phases of your house (it won't power anything 240V of course). The advantage is that you don't have to run extension cords and power existing lights in your house. If you do this, you must carefully disconnect utility power so that you don't backfeed the grid, as well as potential solar panels that could decide to sync with your inverter and feed more power than you're using, causing other issues you don't want to deal with. Of course, you'll find that 1000-3000W may not be enough power unless you do careful load shedding
    I'm not going to give more details because there is definite potential for things going wrong in many ways, but if you absolutely know what you're doing, there you go...

    Discussion Threads

    https://teslamotorsclub.com/tmc/threads/how-many-amps-can-you-get-from-the-12v-system-for-emergency-situations.178079/page-3#post-4371607 https://teslamotorsclub.com/tmc/threads/aftermarket-sub-woofer-amplifier-installation-using-dc-dc-12v-power-source.149582/page-2#post-4337510 https://teslamotorsclub.com/tmc/threads/master-thread-powering-house-or-other-things-with-model-3-12v-battery.140567/page-4#post-4371639
    2019/04/09 Trying Diffusers for RGB Panels run by SmartMatrix::GFX
    π 2019-04-09 01:01 in Electronics
    While playing with RGB Panels, I wanted to fix 3 problems
  • protect my LEDs: when transporting the panels in luggage, the LEDs can be ripped out the board
  • add a protection around the board which is has very sharp corners (relevant on my shirt for dancing)
  • act as a diffuser so that the LEDs aren't as "sharp" in the dark, and generally act as a diffuser.
  • The diffuser however had to be:

  • reasonably light (it's for a wearable)
  • somewhat bendable and not easily breakable (again, wearable)
  • After getting recommendations on the FastLED group and SmartMatrix group, I ended up getting two things:

  • Extra Thick Flexible Frosted Clear Plastic Cutting Mat

  • Serenity Foam Underlayment for Laminate Flooring

  • The Frosted Clear Plastic Cutting Mat was good for protection, but didn't offer too much diffusion. Still, it was better than nothing, and that's what I ended up using in the front of my shirt.
    The Serenity Foam Underlayment for Laminate Flooring offered better diffusion, but no protection at all. However, I figured out that if I used that, plus the cutting mat on top, I got extra diffusion and protection.

    If you wonder, the demos below can be had from:

  • https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos
  • https://github.com/marcmerlin/AnimatedGIFs
  • Here are pictures of what it looks like with one and both layers:





    The cutting mat only still provides some diffusion, just not as much:


    Here is what it looks like with both layers and very small wires to hold the mat on top of the 3 32x64 RGBPanels attached together:


    Here is what it looks like side by side, with both, and without any:






    This works pretty well, thank to the people who provided suggestions and help

    2019/01/24 Linux.conf.au 2019: Using Open Hardware from my shirt to OS testing for Google's Fuchsia
    π 2019-01-24 01:01 in Arduino, Electronics, Linux
    I've been going to linux.conf.au for 18 years now (since 2001), and presented a fair amount of linux talks related there, but the big change for me was the open hardware miniconf that started in 2010. Thanks to its projects every year, I got to learn a lot about microcontrollers and some about electronics.
    This talk was my first non linux talk which detailled everything I learned from those miniconfs and projects I worked that stemmed from them. I presented it at LCA 2019 Christchurch.

    you can find the talk pdf here: http://marc.merlins.org/linux/talks/Using_Open_Hardware/Using_Open_Hardware.pdf (you'll want this one to get all the clickable links in the slides)
    you can view the talk slides in html here or below:

    Talk video below:

    I arrived the sunday before the conference and helped out the open hardware organizers with a bit of last minute setup. I also got to do some last minute testing and tuning of my panels:

    hacked up ESP32 with level converters on breadboard to run 3x 64x32 SmartMatrix panels with SmartMatrix::GFX
    hacked up ESP32 with level converters on breadboard to run 3x 64x32 SmartMatrix panels with SmartMatrix::GFX

    64x64 P3.8 SmartMatrix::GFX panel vs 3x 64x32 SmartMatrix::GFX P4 flexible panels vs 4x 16x16 FastLED::NeoMatrix P10 panels
    64x64 P3.8 SmartMatrix::GFX panel vs 3x 64x32 SmartMatrix::GFX P4 flexible panels vs 4x 16x16 FastLED::NeoMatrix P10 panels

    After finishing the code tuning and demos just in time, gave a 20mn miniconf talk on the history of linux.conf.au hardware miniconf. I went through how much I learned from those confs and what I was able to achieve as a result. I sure got to learn a lot about microcontroller and driver programming:




    I wasn't able to bring my burning man 4096 neopixel matrix, it doesn't even fit in my car, but the irony is that my small 64x64 rgbpanel has the same resolution and fits easily in my backpack
    I wasn't able to bring my burning man 4096 neopixel matrix, it doesn't even fit in my car, but the irony is that my small 64x64 rgbpanel has the same resolution and fits easily in my backpack

    The 64x64 compact display is showing the hand X-ray here
    The 64x64 compact display is showing the hand X-ray here

    A few days later, I gave the longer version of my talk at the main conference. By then it had grown to over 160 slides in a 45mn slot, or 16 seconds per slide. Ooops...

  • The full talk went into details on what I learned in the hardware hacking field, a lot of it was simply electricity, U=RI, wires, pre-made components (small inline volt/amp meters, DC-DC converters, and so forth).
  • I also gave a is a quick summary of my hacking an arduino board to turn it into a sleep analysis machine, a longer talk I gave elsewhere in 2012.
  • There is a section on what I learned from Tridge and RC planes with ardupilot
  • I had to mention microcontroller hacking and driver writing for IoTuz on ESP32 given how much I learned from it
  • And IoTuz got me to write a primitive Neopixel driver for ESP32, a very slippery slope that led me to many LED projects
  • http://marc.merlins.org/perso/arduino/post_2015-01-06_Driver-for-direct-driving-single-to-3-color-LED-Matrices-with-software-PWM.html
  • http://marc.merlins.org/perso/arduino/post_2017-04-03_Arduino-328P-Uno-Teensy3_1-ESP8266-ESP32-IR-and-Neopixels.html
  • http://marc.merlins.org/perso/arduino/post_2017-04-24_Adafruit-GFX-on-NeoMatrix-and-RGB-Matrix-Panel-Demo.html
  • http://marc.merlins.org/perso/arduino/post_2017-06-02_LED-Pants-and-Shirt-Programmed-With-Arduino-on-ESP8266.html
  • http://marc.merlins.org/perso/arduino/post_2018-04-23_FastLED_NeoMatrix-library_-how-to-do-Matrices-with-FastLED-and-Adafruit_GFX.html
  • http://marc.merlins.org/perso/arduino/post_2018-05-29_EDM-Party-Shirt-powered-with-FastLED_NeoMatrix-and-Adafruit_GFX_-plus-160Wh-_10Ah-4S_-worth-of-lipos.html
  • http://marc.merlins.org/perso/arduino/post_2018-07-13_AnimatedGIFs-for-SmartMatrix-or-NeoMatrix-_Neopixel-WS2812B_-from-SDcard-or-SPIFFS_-on-Teensy-3_x_-ESP8266_-or-ESP32.html
  • http://marc.merlins.org/perso/arduino/post_2018-07-30_Building-a-64x64-Neopixel-Neomatrix-_4096-pixels_-running-NeoMatrix-FastLED-IR.html
  • https://github.com/marcmerlin/SmartMatrix_GFX
  • and for good measure the talk ends with how I was able to apply some of that knowledge to design simple solutions for hardware testing racks for Google's Fuchsia on arm platforms.


  • Hopefully the talk and/or slides are useful to you. Links:

  • http://marc.merlins.org/linux/talks/Using_Open_Hardware/Using_Open_Hardware.pdf
  • http://marc.merlins.org/linux/talks/Using_Open_Hardware
  • http://marc.merlins.org/perso/arduino
  • https://www.youtube.com/watch?v=YqeBXCCabo0
  • 2018/06/30 DC charging with DC to DC conversions when off the grid
    π 2018-06-30 01:01 in Bm, Electronics
    When you're off the grid (for many, still true at burning man, or Ephemerisle, you can:
  • bring big batteries (Li-Ion USB packs and/or big Lead Acid Batteries (AGM is better than car battery)
  • use solar panels to help recharge the batteries, but most people don't quite realize that panels need to be sufficiently big (and heavy) to charge sufficiently. You also need a charge controller.
  • use a generator. Generators are quite efficient and cheap for occasional use and make way more power than solar panels per unit of weight. Sadly, they are noisy and not environmentally friendly.
  • The ideal solution is batteries only if your event isn't too long and you've done the math that the batteries have enough Wh for your needs
    Next, is usually batteries + generator that you start as needed. Solar is really the best solution, but it requires more complicated hardware and setup (charge controller, MPPT charger, etc...), but more importantly for any non trivial power need you actually need pretty bulky and heavy panels to handle the load (of course this also relies on you being able to count on enough sun during your event at that location, not an issue for burning man, but potentially an issue for a spring festival in some place that could be overcast or maybe even rainy).

    12V Charging

    Anyway, back to charging, your best bet is to use 12V lead acid (marine, or AGM are even better), and use DC to DC converters to power all your stuff. For 12V, well, you're done, just plug into that using the appropriate cabling with fuses. You will likely be happy with those two:
  • DC 1 Female to 8 Male Power Splitter Cable for CCTV: https://www.amazon.com/gp/product/B01JAM6KDY

  • SoulBay 34pcs Universal Laptop Notebook Input DC Plug Set Jack Tips for Lenovo Toshiba Dell HP Asus and most Laptops: https://www.amazon.com/SoulBay-Universal-Notebook-Toshiba-Laptops/dp/B01HORSXZ0 (sadly even some simlar looking barrel connector are not actually the same)

  • Plenty of chargers work off 12V, you may just need to use some barrel adapters:

  • Socket Cigarette Lighter Power Adapter DC Outlet Splitter + 2-Port USB Car Charger: https://www.amazon.com/gp/product/B003RQBKLC
  • small 12V lipo charger for 1S to 4S lipo: https://www.amazon.com/gp/product/B004FGWY54 (cheap but slow)
  • AccuPower IQ338 Fast Charger and Analyzer Tester: Li-Ion + C/AA/AAA battery charger https://www.amazon.com/gp/product/B013HP4N70 (fast)
  • XTAR Xtar-VC4-Charger-T VC4 Li-ion/Ni-MH Battery Charger Premium USB: Li-Ion + AA/AAA battery charger https://www.amazon.com/gp/product/B00U26ONVE (slow)
  • Powerex MH-C9000 WizardOne Charger-Analyzer for 4 AA or AAA NiMH Batteries: https://www.amazon.com/gp/product/B000NLUSLM
  • 20V and other higher voltage high amp charging

    Now, some laptops may charge from 5V USB if you're lucky (but that will be slow). Some will charge from USB-C which may allow 12V charging or even 20V charging, but finding such a charger that works from 12V may not be trivial. In the case of my thinkpad, it just plain requires 20V, and not only that, it requires 20V at 5.5A or it will power itself, but it not charge (yes, it is stupid).
    I wrote this page on how to hack a 20V power connection to look like it's at least 135W so that a thinkpad will charge, however I need to upconvert 12V up to 20V with more than 10A from the 12V source. I used a discontinued version of this boost converter, and I also have a 100Wh Li-Ion battery pack that can output enough power to sustain my laptop, but not to charge it. That one also requires 20V to charge (sadly it won't charge from 12V):
  • 16A DC Boost Voltage Converter 12-60V to 12-80V Step-up Power Supply Transformer Module Regulator: https://www.amazon.com/dp/B00E8D7XYG
  • RAVPower 100Wh USB battery pack, 20V charging, 9 to 20V output for laptops (plus USB): https://www.amazon.com/gp/product/B00HFMUBYG
  • this battery pack can output 9, 12, 16, 19, or 20V
    this battery pack can output 9, 12, 16, 19, or 20V

    You can see the 12V being split and going into the little white box with the step up boost converter. It shows that it's taking 3.5A at 12V and the red display next to the laptop shows it's turned into 1.7A at 20V which goes both into the already charged laptop and the almost charged ravpower battery pack:


    it might not look like much, but this is my new 160W laptop power supply :)
    it might not look like much, but this is my new 160W laptop power supply :)

    5V USB charging

    Now, let's look into 5V charging, i.e. USB devices. There are plenty of ways of turning 12V into 5V, that's what all car phone chargers do, but most don't deliver many amps, and don't allow full speed charging for more than 2 or 3 devices on a good day. As a result, I'l recommend this 14 port anker USB hub where you'll ignore the USB part and simply use the fact that it has 80W of charging capacity from 12V input:
  • USB Power Hub that will provide 14 outlets at 1A each (works off 12V power): https://www.amazon.com/gp/product/B00GSLMTQ8
  • you can see the anker 14 port USB hub next to the powerex battery charger for scale
    you can see the anker 14 port USB hub next to the powerex battery charger for scale

    Then, I personally use this for my trips when I want a lot of USB (5V) power:

  • RAVPower Battery Packs 26800mAh Total 5.5A: https://www.amazon.com/dp/B012NIQG5E (can charge and discharge at the same time)
  • USB C RAVPower 26800mAh: with USB-C support at higher voltage for fast charging: https://www.amazon.com/dp/B01LRQDAEI/
  • And here is the end result, lots of different chargers all from that same 12V source (including all the adapter tips in the upper left)

    2018/05/29 EDM Party Shirt powered with FastLED::NeoMatrix and Adafruit::GFX, plus 160Wh (10Ah/4S) worth of lipos
    π 2018-05-29 01:01 in Arduino, Clubbing, Electronics
    ===>>> See this full article on the why and evolution of my LED outfit <<<===



    After I figured that my previous shirt was getting a bit stale, I wanted to design EDM Party Shirt v2, which both had to be easier to wash (the previous one had LED strips all over it that were too much work to remove, making the shirt not really washable), and I also wanted it to be more special.
    I had been playing with Adafruit::NeoMatrix and figured it would be cool to have a NeoMatrix on my shirt (also it would be easier to remove a whole panel to wash the shirt).

    So, in the great tradition of yak shaving, I first decided that I should be able to use FastLED instead of Adafruit::Neopixel. This was mainly at the time because FastLED allows parallel output and therefore allows updating a screen by segmenting it in smaller pieces that are updated in parallel. With Adafruit::NeoMatrix, my 768 pixel panel would have taken about 30ms to refresh, or only 33 frames per second, which is not a lot. With FastLED, I was able to trivially segment it in 3 and get 10ms/100fps, which is a whole lot better for animations.
    Turns out, switching to FastLED also gave me access to LEDMatrix, an alternate library which while lacking Adafruit::GFX primitives, offers another nice API including better text and basic sprite support.

    So, I started a port of Adafruit::NeoMatrix to FastLED and wrote FastLED::NeoMatrix. It was actually a non trivial port, which took much longer than I thought, but I got it working in the end:


    by then I was already able to display with 3 data lines, one for each 32x8 panel
    by then I was already able to display with 3 data lines, one for each 32x8 panel

    In the process, I managed to plug the wrong power into the panel and blew a pixel. Thankfully I was able to borrow another pixel from a strip and soldering it in place to fix it:


    Once the port was done, came time to get the panels together. Wiring was a bit challenging because I had to ensure that power was injected at a mostly equal value in 9 different points (3 per panel) due to voltage sag at higher amps. I then quickly found out that with 3 data lines at high frequency, there is cross talk between the wires, so I switched to a CAT-5e cable where each data line is twisted with its ground and the remaining 2 wires are used to bring VCC (5V). Technically my 3 panels can use up to 60A at 5V at full power. Obviously many things will melt before that, and I'm using a power converter that tops out at 10A. Even 10A is too much for the wiring, but thankfully my displays don't use that much brightness (it would be blinding to people):


    two 5Ah 16V lipos give about 160Wh, just enough to run 2 panels 10 to 12H
    two 5Ah 16V lipos give about 160Wh, just enough to run 2 panels 10 to 12H

    the fancy energy meter keeps track of how much time I used and how many Ah came out of the batteries. Useful to know how much time I have left. The blue meter is amps at 5V (after the power converter) and the red one amps at 16V (straight from the battery)
    the fancy energy meter keeps track of how much time I used and how many Ah came out of the batteries. Useful to know how much time I have left. The blue meter is amps at 5V (after the power converter) and the red one amps at 16V (straight from the battery)

    on the right, I have a backup ESP8266 if the main one fails, a backup BEC (5V converter) that's technically 10A capable but not meant to do more than 5A continous, and bottom right is my older 3A BEC with in line amp meter
    on the right, I have a backup ESP8266 if the main one fails, a backup BEC (5V converter) that's technically 10A capable but not meant to do more than 5A continous, and bottom right is my older 3A BEC with in line amp meter

    the new tobsun 5V converter is bulky but does 10A without issues
    the new tobsun 5V converter is bulky but does 10A without issues

    For the back of the shirt, I got some fabric and created an inside pocket to hold the panel:




    it then mirrors the front
    it then mirrors the front

    All this crap goes into a fanny pack, and gets wired to my shirt, pants, and glasses:



    the cool part is that my back also has a panel inside the shirt that uses the shirt as a diffuser
    the cool part is that my back also has a panel inside the shirt that uses the shirt as a diffuser

    You can get the code I wrote for the shirt here: https://github.com/marcmerlin/NeoMatrix-FastLED-IR

    This video shows an early version of the code working on a desk:

    This video shows the animations:

    While this video shows the tech a bit more:

    2017/06/02 LED Pants and Shirt Programmed With Arduino on ESP8266
    π 2017-06-02 01:01 in Arduino, Clubbing, Electronics
    ===>>> See this full article on the why and evolution of my LED outfit <<<===

    So, this all started with some LED shoes I hacked to last 12H instead of 4, and it ended with me learning how to program arduino like microcontrollers to control neopixels (aka WS2811/WS2812/WS2812B) while being able to receive Infrared/IR commands. The latter is actually difficult but you go read that page to learn why

    Since I've met plenty of people who complimented for my neopixel shirt and pants combo, and some who asked questions about them, I thought I'd write some quick page to explain how it all works and how you can do similar things, since it's more fun if I'm not the only one lit up at Dreamstate (which has been less of a problem at burning man).

    Here is a video summary:

    Show me the code!

    Sure, it's here: https://github.com/marcmerlin/Neopixel-IR (but go to the end of this page for more details).

    So, I have 3 versions of the shirt, let's go through them depending on how complex you'd like to go:

    Multi Color LED strip, non controllable



    It used a 12V controllable dimmer: https://www.amazon.com/gp/product/B00MHKCTLE which can simply change the brightness of the LEDs, which are of a set color. I bought the LED strip in Akihabara Japan, but I'm guessing something similar can be found elsewhere.

    Tri Color Controllable LED strip



    This version is better in that the LED strip has 3 channels, one for reach of Red, Green, and Blue. I uses a tri color controller like this one: https://www.amazon.com/gp/product/B01410R4KS or remote controlled: https://www.amazon.com/gp/product/B00PBOJNZS
    Those controllers can create any color and flash it at any interval, however:

  • they are a flat trip that doesn't really like being bent
  • all the LEDs are in series, so if the chain fails somewhere, nothing lights up beyond the point of failure (which is why I have extra wires soldered on to make redundant paths and get around breakage
  • I have had some sections of 3 LEDs where one color died
  • All of the controllers I tried have a dimming function, but it fails to work when I use the fade dimming patterns, which means they are full bright, suck battery and blind others. I've therefore had to add a 2nd voltage regulator where I can just dim the voltage sufficiently so that the current is then also capped by each color string and therefore the brightness is controlled (you cannot limit the global current fed to the LED controller because you don't know whether it's all fed into a single color, or shared amongst 3).
  • Of course the last thing is that all the LEDs for a color are in series in a single circuit, so you light up all the reds, or all the blues or greens, or none. You can't turn on one LED individuallly. This is where the next solution comes in.
  • ESP8266/Arduino Controlled Neopixels



    To fix the issue of not being able to have custom multi color LED patterns, where each LED/pixel can be controlled separately, the solution is neopixels (aka WS2811/WS2812/WS2812B). Each LED/pixel is controllable separately, which is done by a computer, in this case the ESP8266 can run my own programs to control all the LEDs.
    The ESP8266 is a 3.3V based microcontroller for low power use (good when battery powered) while the neopixels are 5V powered, but thankfully the neopixels can use 3.3V signalling from the ESP8266 while being 5V powered to light up properly. The one thing to keep in mind is that neopixels use some power even if they are not lit. In my case 200 neopixels, take about 120mA when they are off, and 4.5A when they are all lit in white on full brightness.

    Neopixels are almost infinitely versatile, instead of having them in single line strips like on my shirt and pants, you can also make display matrices out of them:


    I've then written code that receive the IR commands from the remote and execute different code that creates different light patterns, which is explained in more details and available on this page and you can get the code from github.

    Here is a video that shows all 3 modes, jump to 3:50 for the neopixel bit:

    2017/04/03 Arduino 328P Uno Teensy3.1 ESP8266 ESP32 IR and Neopixels
    π 2017-04-03 01:01 in Arduino, Clubbing, Electronics
    ===>>> See this full article on the why and evolution of my LED outfit <<<===

  • Why my pants needed IR controlled neopixels :)
  • Why IR and Neopixels at the same time, is hard
  • Concurrent IR + Neopixels solution #1: be fast (Teensy 3.1)
  • Concurrent IR + Neopixels solution #2: don't use the CPU for neopixels (ESP8266 (I2S) and ESP32 (RMT))
  • New ESP32 FastLED drivers
  • Software and Libraries
  • Video with the whole story and details
  • Show me the code!

    Sure, it's here: https://github.com/marcmerlin/Neopixel-IR (but go to the end of this page for more details).

    See also the newer https://github.com/marcmerlin/NeoMatrix-FastLED-IR (from http://marc.merlins.org/perso/arduino/post_2018-07-30_Building-a-64x64-Neopixel-Neomatrix-_4096-pixels_-running-NeoMatrix-FastLED-IR.html )

    Why my pants needed IR controlled neopixels :)

    I mean, don't everyone's pants need neopixels? :)

    I started with a silver shirt, I added a few LEDs, and then more I got from a swap meet, and later added some LED shoes I hacked to last 12H instead of 4



    The end goal was adding neopixel strips on my shirt sleeves and pant legs:


    Here is a 6mn clip showing the shoes and shirt if you'd like the details:

    The problem with my shirt, though, is that the colors you see on the picture are actually due to broken traces, causing the colors you see. It's better than nothing, but not what I was trying to do, and no way to create streaming effects. This is of course where neopixels come in.

    I'm not going to repeat the excellent Adafruit Neopixel Uberguide here, but I have a 3mn video clip showing a standard IR RGB LED controller, compared to a neopixel strip. It also shows how I use standard remote control servo cables to wire neopixels, and how to watch out for:

  • signal wire being in the center, so you must not feed 5V on the middle wire like you would with RC and servos
  • how if you have a neopixel strip that doesn't work right, you can only connect to the first LED, and you have to start cutting off LEDs from the strip one by one until you get to the first one that works
  • before you start cutting, make very sure you aren't connecting to the last LED (DO vs DI)
  • Why IR and Neopixels at the same time, is hard

    So, the main point of this page is however to look into the issues of controlling Neopixels and receiving IR signals at the same time.

    It's easy to listen for IR, and then change neopixels, leave them alone, and listen for IR again. It's hard (or near impossible on some chips) to actively update neopixel strips for animations and listen for IR commands at the same time.

    Why? This video explains the issue:

    What's going on is on low end arduino chips (328p, leonardo, or even AT mega and all other 16 bit AVRs), neopixels are controlled by stopping chip interrupts and sending a very precisely timed signal to the neopixels. If the timing is off just a little bit, the wrong colors get sent, or nothing works at all. This is why interrupts must be disabled


    Now, there are actually many other addressable multicolor LED types. The nice ones are 4 wire and work via SPI, which allows the CPU to control the timing and the clock, removing this exact bit banging timing issue. The cheaper 3 wire ones have a set clock and require that the CPU sends a very precisely timed signal, usually done while disabling interrupts. See https://github.com/FastLED/FastLED/wiki/Overview

    But since neopixel strips (aka WS2811/WS2812/WS2812B) is what I already had, I now had to deal with this precise timing issue. As you can guess, disabling interrupts causes issues with the IRRemote library because it has its on interrupt handler timer that also requires being run at a special timing, or it doesn't capture proper IR signals.
    The end result is that you cannot disable interrupts and receive IR signals, and if you don't disable interrupts, the neopixel signal is unstable and the colors flicker (demonstrated int the video above).

    So, unless you use some special hardware to drive neopixels strips on an AVR chip, concurrent IR + neopixels is just not going to work.

    an arduino nano v3 running neopixel strips
    an arduino nano v3 running neopixel strips

    my 328p arduiny chip (equivalent to arduino nano) and anti plug backwards toothpicks :)
    my 328p arduiny chip (equivalent to arduino nano) and anti plug backwards toothpicks :)

    because my 328p chip was unprogrammed, I had to figure out direct ISP programming pinout for it and I flashed a bootloader on it
    because my 328p chip was unprogrammed, I had to figure out direct ISP programming pinout for it and I flashed a bootloader on it

    Concurrent IR + Neopixels solution #1: be fast (Teensy 3.1)

    a few chips for comparison (uno, leostick, nano v3, arduiny, and Teensy 3.1 in green)
    a few chips for comparison (uno, leostick, nano v3, arduiny, and Teensy 3.1 in green)

    Thanks to better FastLED hardware support, when I moved my code to a Teensy 3.1 32 bit ARM CPU, the CPU was fast enough that it had time to re-enable interrupts in the middle of updating neopixels. This in turns allowed the IR Remote interrupt handler to just barely run in between pixel updates, and capture IR codes. Success!

    See this video for details:

    The magic code that makes this work, is here: https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/clockless_arm_k20.h#L34
    sei(); delayMicroseconds(WAIT_TIME); cli();

    Thanks to this re-enabling of interrupts, things work.

    So at this point, someone sensible would have declared victory. However, I felt bad wasting a Teensy 3.1 on something as simple as driving a single neopixel strip (it can drive 8 in parallel) and reading from an IR receiver, when it has around 32 I/O ports. This is why I checked if I could get this to work on ESP8266 chips which are even cheaper and have much fewer I/O pins (but add Wifi)

    Concurrent IR + Neopixels solution #2: don't use the CPU for neopixels (ESP8266 (I2S) and ESP32 (RMT))

    I had more 32bit chips, so I thought I would give them a try. I tried the ESP8266 and ESP32:


    First, the ESP8266 mostly worked with FastLED + IRRemote, but not quite. The FastLed code, just like on Teensy, is nice enough to re-enable interrupts for a short while: https://github.com/FastLED/FastLED/blob/master/platforms/esp/8266/clockless_esp8266.h#L45

    os_intr_unlock();
    delayMicroseconds(WAIT_TIME);
    os_intr_lock();

    However in my tests, the IRremoteESP8266 library was maybe a little bit too slow and caused occasional visible neopixel glitching (this has been fixed in FastLED since I originally wrote this). This is where I found this interesting library: https://github.com/JoDaNl/esp8266_ws2812_i2s/ which manages to drive the neopixels without doing bit banging with interrupts disabled ((ab)-using the I2S hardware support). It's not a very fancy library in what it offers, but it works perfectly with interrupts enabled.

    There is another DMA library using the UART instead of I2S interface, that also works without affecting interrupts: https://github.com/Makuna/NeoPixelBus
    Same thing for ESP32. Actually ESP32 is even more difficult to get a perfect timing out of using bit-banging given that it's a dual core CPU running on top of an RTOS, and no matter how precise your code is, you just cannot guarantee that it'll run perfectly at the timing you need all the time. I did add ESP32 support to the Adafruit Neopixel library, but it only works most of the time, which isn't really good enough.
    This where its built in RMT support comes in. It can generate 8 precise signal waves, which are perfect for neopixels, so this is the way to go to animate neopixels without disabling interrupts (making IR receiving trivial). IRremote was missing ESP32 receive support, but I added it recently, so it's all working.

    FastLED now supports RMT on ESP32, so you can run interrupts while talking to Neopixels.

    Here's a video summary of ESP8266 and ESP32:

    Software and Libraries

    So, here's a summary of all the libraries I went through, 2 for IR, and 4 for Neopixels:
  • To receive IR signals, we'll use the excellent IRremote lib: https://github.com/z3t0/Arduino-IRremote
  • ESP8266 currently uses a fork of IRRemote, IRremoteESP8266 which may soon be in the process of being merged in the main Arduino-IRremote. See https://github.com/markszabo/IRremoteESP8266/issues/148 and https://github.com/z3t0/Arduino-IRremote/issues/400#issuecomment-294446261 .
  • For neopixels, most people use the adafruit lib: https://github.com/adafruit/Adafruit_NeoPixel . It works ok, but it requires disabling interrupts (and is therefore incompatible with IRRemote for concurrent operation)
  • FastLED is a more complete library with better hardware support (both in pixels and CPUs): https://github.com/FastLED/FastLED . The big plus of this lib is that it support re-enabling interrupts on 32bit chips, allowing the IRremote ISR to run.
  • Instead of FastLED (which does work), on ESP8266 you can use https://github.com/JoDaNl/esp8266_ws2812_i2s/ . The support is bare, but uses an inventive (ab)use of the I2S subsystem (I2C for audio) to generate neopixel signals using an onboard co-processor unit without tying up the main CPU or requiring the disabling of interrupts.
  • On ESP32, FastLED wasn't supported when I wrote this blog (I added support in Adafruit-Neopixel but it require disabling interrupts at least temporarily and it's hard to do anything real time on a dual core ESP32 running on top of an RTOS). The good news however is that it has 8 RMT channels which are designed to handle precise signals like this without tying up the CPU. See this code that supports Neopixels with exact timing: https://github.com/MartyMacGyver/ESP32-Digital-RGB-LED-Drivers . After I wrote this, FastLED added RMT support on ESP32, so it "just works" now.
  • And here is my code again: https://github.com/marcmerlin/Neopixel-IR

    The big plus from that example code is that it supports 4 different Neopixel backends and abstracts them so that the adafruit (and other) demos can run on all 4 libs. See how it does it here: https://github.com/marcmerlin/Neopixel-IR/blob/v1.0/Neopixel-IR.ino#L275

    New ESP32 FastLED drivers

    As of 2018, FastLED now has 2 ESP32 drivers: a software one, and an RMT driver one. See my page on ESP32 8 or 16 Parallel output and driver.

    Video with the whole story and details

    This is a 25mn mashup of all the video clips, including a section on flashing the arduiny via ISP (AVR 328p):

    I also have a video showing the evolution of lights on my shirt from v1 (single non controllable color) to v2 (tri color, but not pixel addressable), to neopixels with cool patterns (jump to 3:50 if you'd like that):

    2016/05/24 Hacking LED Shoes
    π 2016-05-24 01:01 in Electronics
    ===>>> See this full article on the why and evolution of my LED outfit <<<===

    While those shoes are quite cool when they work, and getting them for $50 or less on amazon is quite cheap. Sadly the build is a bit cheap and the hardware could be improved. So I went ahead and did it.

    the lit shoe laces are separate
    the lit shoe laces are separate


  • these are the shoes: https://www.amazon.com/gp/product/B014D20JTM (not great quality, be ready to buy 2 pairs if you want a backup)
  • and here are the lit laces: https://www.amazon.com/gp/product/B00BOK1BRQ
  • This is what you find under the sole: everything is inside a resin and the built it lipo is too small (only 4H runtime). Two sets of 4 wires come out: one is to control the LEDs and the other one has 2 wires for the switch built in the shoe, and 2 wires for the USB power charging (which charges super slowly, about 4X slower than the speed the lipo can charge at):


    The first thing to do is to open the side of the shoe to get to the switch, take it out, and turn it around so that it points away from your foot. Otherwise it's way too easy to trigger. I've also cut the yellow wire and added a small slider switch. This allows me to disable the push switch if I want the shoes to stay off, or not rotate between color patterns each time the switch gets bumped:


    The lipo is totally built in and too small. Adding a second lipo in parallel is a bit difficult, I had to burn off the resin to access the lipo terminals:

    it claimes 450mAh, but I think it's smaller
    it claimes 450mAh, but I think it's smaller

    it's a bit difficult to solder wires on top of the lipo wires without shorting it
    it's a bit difficult to solder wires on top of the lipo wires without shorting it

    I then added a female connector to allow use of bigger lipos from a mobius I wasn't using
    I then added a female connector to allow use of bigger lipos from a mobius I wasn't using

    I had a few lipos to choose from, but the mobius one was the best fit for the hole in the shoe
    I had a few lipos to choose from, but the mobius one was the best fit for the hole in the shoe

    I had to cut off a bit of plastic fit the battery
    I had to cut off a bit of plastic fit the battery

    still a bit of a tight fit
    still a bit of a tight fit

    My shoes now work a bit over 12H, do not turn on or off without my wanting them to, and they come with a real off switch. I did put a very solid sole insert on top though to protect the electronics and the new bigger lipo underneath. There is also a worst case scenario where it could catch fire :)

    I later got another pair of shoes with dual LED pattern, the battery is still quite small (450mA), and on top of that the shoes shut off on their own every 2H. Sigh...


    getting to the battery contacts is still hard
    getting to the battery contacts is still hard

    I added a direct port to the lipo for optional faster charging and charge status check
    I added a direct port to the lipo for optional faster charging and charge status check


    Also, the charging function is slow as crap, but the direct lipo access charging port I added lets me recharge the batteries directly in one 1h by connecting directly to a proper lipo charger. They do suck in several ways, but in the meantime, finding dual pattern LED shoes with LED strips that flex instead of breaking, wasn't trivial either...

    See more images for Hacking LED Shoes

    More pages: May 2020 January 2020 December 2019 April 2019 January 2019 June 2018 May 2018 June 2017 April 2017 May 2016 February 2016 November 2015 October 2015 August 2011 July 2011 May 2011 June 2010

    Contact Email