Marco's Corner

Just another Software Developer's Musings

Browsing Posts in Arduino

ArduinoADKFront450px My experiments with the different variants of the Arduino family. It’s partially a notebook for myself so that I don’t have to reinvent the same wheel over and over again. But I hope, it’s also helpful or entertaining for the curious browser.

As always, have fun exploring;-)

Our kids are off to college now but I could not stay away from the Science Olympiad fun. So I plan to play the Event Manager for theimg_20161017_235808Division C – Electric Vehicle” @ the San Joaquin County Event.  That will be my first time to run an event, so it will be quite interesting.

The event does not need to much preparation except for a pretty far reaching timing setup. Schools might have the Vernier Photogates which can be used with a laser pointer as a long-range solution. But I wanted to try to build my own `lower cost’ solution for people outside the Vernier eco system;-)

I build some little photogates earlier for testing our Maglev vehicle for 2013. They worked fine for that setup, but they would not work for the Electric Vehicle event because their short range.

So I knew, I needed some laser diodes as light sources and a receiver side which would work with them. For the diodes, I found little diodes @ebay, for instance 5* 5mW for Arduino for < $8 , but there are many choices out there. 5mW is what the normal laser pointers are using and it is more than enough for the distance we need. I did choose a red beam to make the lines visible. With a IR diode, I might have been able to use my original detector, but it would be very hard to aim:-(

laserreceiver_schemFor the receiver side, I choose the SFH 3310 photo transistor. It’s relatively cheap @ $0.83/per and it seems to work pretty well. I added another transistor and some resistors and LED from the parts bin to the receivers to that I can quickly see that the link is closed. The final circuit is shown in the schematic. Overall electronic parts cost for two gates is < $10.

I designed little enclosures for the receivers to hold the electronic pieces and also help to keep ambient light away from the photo transistor.  They were 3d-printed but needed a little bit work to make them fit as I wanted. I also printed little adapters for the laser diodes to fix them to LEGO stands. 3d

On the software side, it’s almost the same as the original gate setup. The receivers interface to an Arduino which does the timing. The laser diodes have an Enable pin, but so far, I left them simply on. The updated sketch is here: lasergate It also includes some local LEDs on the Arduino to see how it sees the receivers and a little display to work without a big laptop/display. Both are not really needed, but nice to have.


I also rebuilt my adapted dclock widget dclock-2-2-2 and it still seems to work on Ubuntu 14.04;-) I was running it on my laptop, but it should be easily buildable on a Raspberry Pi or similar;-)

Overall, I’m very happy with my setup. I tested the beam range to > 4 meters (the length of the wires I was using) and they worked just fine;-) So, that setup should work just fine;-)

As always, have fun exploring;-)

Update 11/09/2016: It turns out, my original scetch was sometimes slow to react. So I updated it to limit the LCD updates to about ten per second. That helped a lot. I now reliably pick up a 6mm (1/4″) obstruction at more than 6m/s (13mph). That’s fast enough for me;-) If it’s still a problem, I would remove the running updates for the LCD completely and show only the final time.

The new sketch is here: lasergate_20161109

IMG_20150705_151534 IMG_20150705_151644This post is way late:-( First I got stuck trying to find or build a Fritzing part for my TSL235R light sensor. I tried to build the part in FreeCAD but that died a couple of times on me, so I got frustrated:-( I constructed other things with FreeCAD and had no problems, but it did not like that little part:-( Then, I had some problems with my WordPress setup, the backup scripts did not want to work and all the sudden it’s five month later than when I wanted to write this post:-(

The colorimeter was actually the first sensor setup I wanted to build for tests. It was the one, I had the least experience with before. The original costs more than $100: Vernier Colorimeter

My colorimeter is basically four light sources, one RGB LED which I use as three distinct LEDs in one housing and one of the near-UV LEDs and the TSL235R light sensor, all driven by the Arduino. I did play with the light sensor for a different project before, so I had some code already;-)

The TSL235R light to frequency sensor costs about three dollars @ sparkfun. The LEDs are pretty cheap when you buy them in larger quantities;-) I usually have enough of those on hand;-) You want to keep outside light out of your device and you want to limit reflexions around your sample, I just built a Lego box and lined it with mat black construction paper. You want some clear cuvettes for your test solutions and maybe some pipettes. Usually those are only sold in packs of 100+:-( I built a little template out of scrap plywood to get the cuvettes in the same spot for each test.

The Arduino code is pretty straight forward. For each colour requested, it turns on the LED at a specified level (calibrated to the particular setup), waits a bit, counts interrupts from the sensor for one second, turns the LED off and calculates the final value. That’s done ten times in a loop just to get more data points.Colorimeter

I tried this setup with different concentrations of fountain pen ink and it kind of worked. But I did not keep a record:-( and now everything is dried up:-( The sketch is here: Colorimeter.tar

That’s it for the 2015 Science Olympiad posts, sorry that this last one took so long. But maybe it will be useful again at some point.

As always, have fun exploring;-)

ForceProbe1_1024 The third sensor in my collection is the force sensor. The Vernier Dual-Range Force Sensor costs around $109. My version was < $20 in parts in addition to the Arduino. Yes, it’s not as nicely calibrated but you should be able to get it close.

What is a force sensor really? A weight scale held sideways. Or the other way around, a scale measures the gravitational force an object exerts and translates it into a weight unit. So I use a scale as the sensor, basically a luggage scale from Amazon with a rating of 40kg. It’s available for around $3.50 (shipping from China) or a bit more from an Amazon warehouse near you. That scale is rated for 40kg which would be equivalent to almost 400N, much more than the 50N of the Vernier sensor.

When you try to push on the hook assembly of that scale, it actually starts to show negative numbers, so it would actually work for both directions. But not really inside the case, the metal parts are held in place by little plastic tabs. They are not indented to carry any force! But it’s easy to remove the strain gauge from the housing and create a new frame for it. An Erector Set or something similar would probably work very well. I did not go that far [yet];-)

The other needed part is an instrumentation amplifier because the strain gauge sensor delivers only very small voltage variations. I decided on the Analog Devices AD620 which I found on Amazon as well. With shipping, it was about $10.

I found a nice video @ the NerdKits site: weighscale that explains the principles very well. My circuit follows the idea pretty closely except I’m using a real Arduino instead of the `bread boarded MCU in the video’.

One word of advise: Be careful when you want to play with something like this. The wires on my  strain gauge were not well attached. So I lost one and had to remove the silicone cover, solder a new wire in place and recreate a cover. Try to prevent it, it’s no fun.

ForceSensor_bbFor the AD620, I selected a gain of about 1000. That means a 49Ω resistor. So I use two, I had laying around. The rest is very similar to the NerdKit circuit, including the reference voltage of 2.5V.

I created a Fritzing part for the AD620 because I could not find one:-( It’s available here: AD620.fzpz (You will have to remove the extra .zip suffix, WordPress did not want to let me upload the file without it:-()

My little sketch is here: ForceSensor.tar It does a zero-point calibration first and then measures the force in the main loop. As always, that can be easily adapted to some data collection/plotting setup on the host computer. The factor to translate the values to Newtons really depends on your sensor and the gain of the AD620. So you will need some known weights and calculate it.

Have fun;-)

— Marco

MotionProbe1_1024 Ok, it took a bit longer than expected. But here is my version of the Vernier CBR2. That sensor is basically a ultrasonic distance sensor. All the other data is calculated based on distance changes over time. I’m using the HC-SR04, which is a very cheap ultrasonic distance sensor. Depending on how long you want to wait, you can get it for less than two Dollars;-) Amazon has many offers which essentially differ in the shipping time(cheap from China or Prime for around $6).

UltraSonic_bbThis sensor has so many examples of interfacing it to an Arduino, so that this post does not really offer much new info:-( I just wanted to add it to the list to be complete. I added an extra LED as an visual indicator how quickly the sensor cycles, but that’s about it.

My little sketch just writes the measured distance in cm to the serial port. All the `higher level’ calculations would be done on the computer side. It would also be easy to add a time stamp for each distance. The sketch is here: SonarSensor.tar

The sensor works pretty well;-)

As always, have fun experimenting.

— Marco

It’s this time of the year again and preparations for the regional Science Olympiads are speeding up. This year, I looked a bit at the four sensors/probes to be used in the “Technical Problem Solving” event. I’m just a parent, so I don’t have ready access to the official Vernier probes or software. But with a couple of electronic components and a/some Arduino‘s, something similar can be build and easily interfaced to a computer.

The advantage of using an Arduino is that you can decide what to do with the collected data. It’s easy to print or create graphs or whatever else you want to do. It also allows a little bit more insight into how those sensors work.

I’m planning to create four posts in the next couple of days, one for each probe. All of the designs can be created with any Arduino/clone or whatever you have already. The additional parts cost less than $20/probe and you might find some in your parts-box already;-)

TempProbe1_1024This post is about the temperature probe. The official Vernier Temperature Sensor is not that expensive at $29 as long as you have the `infrastructure’.

My idea was heavily inspired by another blog post: “Building an Arduino Powered BBQ Thermometer”. There are other thermistors/temperature sensors out there, but the `food/cooking thermistor’ is designed for wet environments;-) So it can be safely used around/in liquids. I got a Polder Replacement Oven Probe for THM-362-86 from Amazon for $10. That was the cheapest I could find. But it turns out that it’s nominal resistance @ 25°C seems to be 220kΩ. So I had to adapt the resistor values accordingly.

TempProbeAside from the thermistor, we just need a resistor for the voltage divider, in my case, I use a 220kΩ resistor plus a 100kΩ potentiometer. I found that the resistor alone was a bit too small, so the potentiometer is used to adjust as needed. With some constants, I found for a similar 220kΩ variant of the VISHAY NTCLS100E3 thermistor, I got mine to within 1°C of another kitchen/oven thermometer. That sound be good enough for most experiments where the interesting part is more the temperature differences than the absolute temperature.

The sketch is very simple for now. It just reads the analog voltage every second and calculates the temperature using the formula and constants from the data sheet. It’s here: TempSensor.tar

That temperature probe should work at least from -20°C – 200°C, that should be enough for most experiments;-)

As always, have fun;-)

— Marco

Some Halloween Impressions

No comments

P1000454-1024P1000455-1024Halloween is always a time for me to try different things. So I tried to take some photos and videos of this years displays. Unfortunately, it rained pretty much the whole time, so I had to water-proof the things and did not want to go back in there to fix things:-( But it looked that most things survived the day outside;-)

The first picture is just a static display with some LEDs, EL-Wire and a UV lamp overhead. You can’t hear the sound;-) Speakers and an old CD-walkman are hidden under the cloth;-) This image on the door is a scary fridge;-)

The second image is a skeleton lounging on our bench with just a couple of LED tea lights for illumination. The big spider in the window is probably not happy that there is no juicy flesh left;-)

P1000460-1024The third image is of a little scary grave yard. It’s normally dark until people come by. Then the candles come on one after the other and the eyes of the grave diggers and the skeleton start to glow. The skeleton gets it’s heart beat back;-) and starts moving it’s arms. All of that is surrounded by some nice Halloween sounds. All of that is controlled by two Arduinos, one dedicated only to the sound. I found that the sound shield and the PWM for the RC servos did not play together nicely:-( The candles are the little LED tea lights, but instead of the normal batteries, I soldered wires to the LEDs. The lights are normally driven by 4.5 volts (3*1.5V batteries), but they work just fine on a digital pin on the Arduino;-) The lights got a 4″ nail hot-glued to the bottom, that works pretty well as lawn spike;-) I tried to make a little video outside but there is not too much to see. So I’ll also include a video from an inside test-run;-) I’ll upload the Arduino sketches somewhere, but it looks like I’m doing more and more of those. So I might start a repo or something. Especially since I will probably want to reuse those next year again.

I actually added some potentiometers after that test to dim the eyes a bit;-)

The next little video is of a bush by the side of our driveway. I added some LED eyes into it and some nice sounds of a lion and some kittens which will play randomly. It’s very dark again, so I have a outside clip and again on from a test run. Last year, I tried something similar but with smaller speakers and that was simply too little volume for the outside. This display is again controlled by one Arduino and using a Adafruit sound shield with amplifier. The speakers were 2* 4Ohm, 3W. That was loud enough.

Both displays use passive IR (PIR) sensors to detect people and only start up when somebody is around. They slowly play out when no motion is detected any longer.

As always, have fun playing;-)

— Marco

P1000269_1024OK, so we saw and played a bit with the MaKey MaKey at the Bay Area Maker Faire and it’s a fun little piece to play with. I have a fifth-grade teacher in the family, so the plan is to enrich the class room a bit;-)


P1000265_1024P1000268_1024I always want to look a bit behind the scenes to understand how things work. So after a bit of google-ing, I found that it should not be too hard to implement a DIY MaKey MaKey  with an Arduino Leonardo, some resistors and some alligator clip cables. I did have the Leonardo and some resistors (1 MΩ – a little bit smaller than the 22 MΩ suggested around the web) and found the cables at the local RadioShack. I found the original(?) sources in the sparkfun github ( and tried to adapt it a bit. I pushed my changes to a fork: Overall, the setup worked pretty well, I guess not as sensitive as the original, but OK for mostly parts-bin parts.

So, overall, I would suggest to buy the original MaKey MaKey when you’re interested in something like that or want to attract kids to electronics. I don’t think, the DIY version would save you anything. It’s just a way to see what’s `in the box’ 😉 It’s some thing to read specs but it’s a different thing to be able to create a working setup.

As always, have fun exploring;-)

— Marco


makers   beginnersOK, nobody knew what to expect for our Arduino Day event. But about 20 makers had a good time @ Robot Garden😉 Most knew their way around. But we also had a couple of kids who were new to the idea of `hardware hacking’ and liked the idea of an easy start. So instead of a big presentation, I gave them some 1-2-1 time;-) That worked pretty well.

Just for reference, my prepared presentation as LibreOffice ArduinoDay.odp & ArduinoDay.pdf files;-)

table2table1Some photos (not taken by me;-)

As always, have fun exploring;-)

— Marco

Arduino Day 2014We will have our own event @ Robot Garden in Livermore, CA to celebrate the 10th Birthday of Arduino – The little computer that can;-) I brought it up, so naturally, I got to organize the event;-)

More information is available at the meetup page for the event.

I hope, we will have some interesting people and some good demos, but as always, the Arduino ecosystem lives from the participation of individuals;-)

I hope to see you there;-)


Last night Paul Zander, Bob Smith, and I gave a presentation/demo for the Silicon Valley Linux Users Group on little computers ranging from Arduino to Raspberry Pi and friends. I believe the audience had a good time and we had interesting discussions afterwards. My slides are here SBC_SVLUG_mw (PDF)and most of my demos are described in more detail somewhere below;-)

As always , have fun exploring