Hacker News new | comments | show | ask | jobs | submit login
Show HN: Giving a Broken Barcode Scanner a New Life with Elixir and Nerves (bcarrigan.com)
330 points by carrigan 7 months ago | hide | past | web | favorite | 58 comments

I love these little stories, they always make me want to go out and buy a proper oscilliscope so I can start my own adventures.

I'm surprised by how simple and easy to understand the data serialisation is on some bits of hardware as in this case.

Thank you for the kind words! I will echo slig and say that I have been really happy with the Rigol DS1054Z so far. I love that you can build a really capable electronics lab at home in 2018 for less than $500.

Any guides in getting started with an oscilloscope?

eevblog has an extensive collection of oscilloscope vids.

Micsig scope tablets are great too. Similar price and specs but they're also battery powered and portable!

Having an oscilloscope is great, and it needn't be thousands.

For general tinkering and exploring I picked up the Digilent Analog Explorer 2 with the Ham Radio bundle[1]. They had a coupon deal where 'hamradioworkbench2018' would unlock a $100 discount. Not sure if that still works. While it is a USB scope (so you are dependent on your PC/Laptop for a display) it includes some other useful bench top tools.

Used scopes in the 100 - 200 Mhz range from the 90's are often pretty inexpensive and can usually be calibrated and repaired. This is especially true of the Tektronix 465 and 475 series which were sold in huge numbers. While not as crisp as a digital scope they work well and can be found (at least in the Bay Area) for $50 - $100. About double that on ebay.

The Rigol folks really pushed the price point hard and their DS1054 and DS1102D series are fairly common and inexpensive at $300 - $500.

Scrounge around HAMFests or surplus liquidators and you can often find a deal if you know what you want.

[1] https://store.digilentinc.com/ham-radio-workbench-bundle/

I'm an electronics enthusiast (play with it on weekends) and the Rigol DS1054Z oscilloscope (it's the same used by OP) has a really good cost/benefit, and it's also hackable.

Yes I was just looking at it, £300 seems pretty reasonable. A while ago I was looking at old used stuff but even they are in the thousands. Thanks for recommending it, it's nice to know some HN readers are using it because I don't really know what to look for in an oscilliscope :)

I know Rigol was doing a promotion around the holidays where they'd give you expanded bandwidth, serial decode/trigger, and a few other goodies at no charge.

Of course, you can always just see about taking matters into your own hands (http://gotroot.ca/rigol/riglol/)

Test Equipment dot Net is running the Rigol promotion through June:


If you want a cheaper and more portable solution, have a look at Picoscope (UK). Don't believe the guff about USB scopes being garbage. These things have plenty of bandwidth and it's really nice being able to carry around a scope in your pocket.

Unless you do a lot of high speed IO, 25MHz covers pretty much everything (most 8-bit Micros top out at 20MHz, some go to 48-50MHz). Even the 10MHz version is fine if you were just doing audio work or slower digital stuff.

For £300 you could get a 50MHz 2 channel scope (at 0.5Gs/s). If you want 4 channels you're not going to beat the Rigol for price, but portability matters sometimes (other times being able to monitor every SPI line simultaneously is a godsend). I have a Rigol DS1104Z and a Picoscope 2205A, I've used both extensively.

Plus you get a lot of nice features in the software (which is cross platform), including serial decoding for free. Most of them have a signal generator built in too.

Wow, it also has drivers for the raspberry Pi ! https://www.picotech.com/support/topic14649.html

This pairing would make for a trully tiny all in one oscilliscope, i'm tempted to get a picoscope and a tiny LCD just for laughs: project #1

You may not want to do that. The sampling rate is very important on a scope, especially for analog signals because of Nyquist.

Hmm, I was expecting the sampling frequency to have been made independent of the USB bus, (i.e for the sampling to occur purely on the picoscope itself and data merely relayed over USB).

I don't even know what the frequency limitations of USB are I just know it's capabilities are highly dependent on the host so relying on it for precise high frequency sampling seems like a bad idea, and if that is the case for the picoscope then you are correct, I just find it a surprising design decision.

Am I wrong in thinking this? or are you referring to a different reason?

Yes, all the sampling is performed on the Picoscope and then streamed over USB.

This is something that you need to grok when using scopes: you're capturing (often) a teeny-tiny snapshot of time. The waveform on your display might be 50ns wide. You certainly can't process this data in real-time using your eyes (that'd be 20 million frames a second). So you're not seeing a continuous signal, you're seeing short snippets of your signal separated by some dead time. The majority of this dead time is probably just writing to the display. You're not pushing pixels to the display at the sampling rate of the scope, otherwise these would be some of the best monitors in existence!

Usually scopes are triggered somehow and you'll be sent waveforms, typically centred on the trigger point, at some maximum frame rate. So you'll see a little bit before the trigger and a little bit after. Most scopes let you vary the trigger offset, e.g. if care more about stuff that happens before or after. Using an oscilloscope well is all about the triggering!

The scope will have (a) a max. sampling speed and (b) a fixed size sample buffer. You trade off both. You can sample really fast for a short period of time, or slower, but see a longer time period. If you want to see 'all' the signal, then you can set the timebase to something long - e.g. 100ms/div. That's useful for seeing slowly varying signals, but you'll lose resolution. A scope with a nice big sample buffer will let you zoom in on a signal once its been captured.

Once the buffer is full, the scope has to transfer that data to you, either directly to a screen or over a serial connection. Unless you're in single shot mode, this process will repeat every time the trigger condition is satisfied.

I think the idea is to use the Pi purely as a display. Picotech's scopes tend to be well specced with regard to analogue bandwidth/sampling rates - around 5x Nyquist typically.

In this particular case, it's not too surprising. PC-connected barcode scanners traditionally use a relatively-ordinary RS232 (or USB nowadays, usually with support for either depending on which cable you're using), and almost always just pretend to be ordinary keyboards. I'd be more surprised if it deviated from that at all.

I was kinda hoping that this would be someone porting Nerves to run on the barcode scanner itself; quite a few of these scanners actually have reasonably-powerful ARM cores (especially once you get into the 2D scanners).

Watch EEVblog and bigclive on YT for oscilloscope advice.

bigclive works on electric / electronic stuff, and he's sometimes a bit sniffy about cheap hobbyist kit. (Fair enough when he's talking about things you use with / on mains electricity where there's a risk of death.)

For RS232 any 'scope is going to be fine, even a chinese clone knockoff or an ancient second hand scope.

For decoding serial one of those $5 logic analyzers is more than sufficient, you don't really need an oscilloscope at all. I don't really like using protocol decoding on my scope unless I need to correlate timing with an analog signal because it's tedious to set up and use for a simple digital signal.


RS232 is 12V, but a couple of resistors would sort that out.

If you're a beginner I would actually recommend the Saleae Logic Analyser over this scope, unless your routinely dealing with analog or voltages over 5.5V, the Saleae is much more useful, has serial (and other) decoders built in as opposed to having to pay extra on the Rigol, has better capture and triggers plus as a bonus it doesnt have that noisy fan going all the time.

Yeah, in the article he uses a good old MAX3232, which is specifically for doing RS232 to TTL level shifting. Totally agree, the Saleae or one of the cheaper clones I linked is a better choice for most hobbyists. Scopes are indispensable for certain uses, but most Arduino/RasPi projects these days are all digital and you can do everything you need with a logic analyzer + a decent multimeter.

I use my scope just often enough that I'm glad I have it, but I sometimes also regret buying it because it's not that often that I actually need it.

It's worth noting that some of those cheap logic analyser only work with pirated versions of expensive logic analysers software.

While cheap knockoff analyzers often ship with pirated software (e.g. Saleae) many, if not most, work equally as well with the open source Sigrok software.

Saleae gives their software away for free, there's not any need to pirate it but still using their software is morally shady IMO because they put a lot of effort into it. I prefer Sigrok anyway, even with the actual Saleae analyzers.

Also worth noting that Sigrok loads the analyzer with open source firmware, you're not using any pirated code. The hardware is basically a clone of the original Saleae logic analyzer, but the Saleae hardware is just a standard reference implementation of a cheap Cypress chip so that doesn't really bother me.

The laser scanner is kind of fancy, but you can get USB scanners for $10-$20 that present as keyboards. For me, the most interesting part of this is looking at Elixir.

In my previous life I worked on kiosks using POS equipment like this. Scanners are typically just keyboard interfaces. The barcodes are essentially very old school QR codes that actually type the information. Card swipers are the same to a degree. They read up to 3 levels of the magnetic strip and essentially type the card number and cvc into POS systems. Debugging these usually would involve opening up Notepad in Windows and watching it type the information.

The Symbol/Motorola/Zebra/whoever-owns-the-brand-this-month li2208 is cheap and can read a phone display. I think it can decode PDF417 (? The 2D barcode on the back of your driver's license) but Im not sure about QR

I think by default it handles pdf417 but you could enable a few other formats through configuration. QR seemed to be easily supported by even the cheapest models 6 or so years ago. It's like the scanner tech itself kinda stayed the same but what changed was the connectivity to the PC, moving from serial to serial-over-usb. At least that's what it looked like with the sample scanners I had access to.

This all reminds me of the CueCat[0] scanners I picked up for free from Radio Shack so many years ago.

[0] https://en.wikipedia.org/wiki/CueCat

Same! I also remember the CueCat's XOR-based ""encrypted"" output :-) Found an article from 2000 on this! https://www.securityfocus.com/news/89

Do you have any recommendations? I've been looking to get one to play with the same concept as this article but I've never pulled the trigger on buying one as I'm not sure if there any quality aspects I need to be aware of. The shipping costs for my location are a bit too much to just try one. I can also imagine there's no real difference for that price range but I want to be sure before I order one.

Getting whatever is the cheapest one Amazon has listed at any given time has worked for me.

The only differentiation I can see is the really expensive ones can scan the tiny 2d codes that are silkscreened on some ICs, and the cheap ones are limited to about the same resolution that a standard consumer printer can print a barcode at. Unless you have some very specialized requirements, you should be good with just about any cheap barcode scanner.

Motorola are the respected brand, but it doesn't make a great difference. You might be able to get a local secondhand one. The more expensive ones do 2D barcodes, QR etc.

An important thing for secondhand ones is to download the manual; it will contain a set of configuration barcodes so you can factory reset it, turn off beeping, etc.

That's the same problem I have with a lot of hobby projects I think of doing. There's always a cheaper or more time efficient way to do things.

Don't discount the value of learning something new and the enjoyment of working on a hobby project.

Like this guy, build around something you have as a starting point even if it's not what you'd choose from scratch.

I've seen a website that has control codes for a particular scanner, because it doesn't just send digits/letters but the device can be controlled by special barcodes to send/hold Ctrl or Alt on the "keyboard". He was using it to access the OS behind the kiosk UI on a ticket machine.

We've found Wunderlist to be truly amazing as a shopping list app, and my family has been throwing this type of idea around for a while, though instead of using a dedicated scanner we were thinking of just throwing together a simple app that used the camera and available barcode reading software that connected directly to our shopping list.

It's nice to see that someone else came up with this idea, executed it so well.

Most shoppinglist apps we tried when we were selecting our app had barcode scanning but we never used it, it is far faster to just type twi chars and select the too thing. Or just go thru the list of most used items.

My problem with most of those apps is that they're too large and offer way more features than we're interested in, often to the point that they break the way we'd like to do things. Can you recommend an app that you use?

At first I thought it was going to be a :cueCat goes to rehab article, but no... a legit barcode scanner. Nice!

Love this!

I was thinking of something similar, but mostly as an inventory + expiration tracking system, because we often forget what we have in the fridge and cabinets. I love the integration with Wunderlist for adding to the shopping list as well!

I would pay $100 for something like this. I want to just scan something, have it beep, and add to a shopping list. I know amazon has something similar but I don't want to order it, just log it. Excellent project.

The Android app "Out of Milk" will do this for free using the phone's camera.

How good is the scanning speed? I've tried a few apps which will scan a barcode, but they all seem quite slow. If I buy 50 items at the store, I don't want to fiddle with it for 10 minutes to get everything scanned in, I'd like to buzz through them relatively fast.

It is a bit slow, sadly.

This is such a cool little project! I'm planning out a dedicated setup for my kitchen, particularly for recipes, but inventory management is another opportunity I've been wanting to explore.

Great writeup with detail!

Thank you very much! I'd love to hear about what you come up with for recipe management.

Right now I'm going very low tech for recipe management...I send a DM to my SO on slack. That's most of what we use the DM for, an archive of things we've made. We mostly need a bigger screen in the kitchen that stays on while making a recipe. A Microsoft Surface we have laying around will be used for that.

I'd like to do a database of products purchase, purchase date, price paid, scan a barcode and mark it as consumed, and calculate typical consumption rate of the products.

I will keep things pretty simple, either a sqlite database that stays local or a LAMP setup so I've got access to an inventory list at the store along with "price check" functionality.

I'm working on this idea too! Hit me up on gmail! Love to chat.

Apparently many grocery store chains offer APIs where you would be able to download information on what you bought. Anybody know more on this?

I checked Aldi and two regional grocery stores near me...no public API. One does have a delivery service, but that API is closed off it looks like.

Now, if only I can get Wunderlist to stop randomly duplicate my groceries list items or clear the wrong item when checking off... I can see why array indexing is a hard problem..

Where can I buy a scanner like this that is already hooked up to a todo-list?

Maybe you need to find someone to do a Kickstarter

I'm already nervous to try it out.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact