Partially for learning, partially because it might come handy, I decided to build my own Rasbperry PI cluster that would run HypriotOS and Kubernetes. If you search the web you'll see others doing it and I used them as a knowledge source. Some are outdated and perhaps sharing my experience might help somebody. Anyway, here is my story starting with
- 4x Raspberry PI 3
- 4x 32GB microSD - the faster the better
- 4x network cables
- 4x USB cables
- Anker 5 port USB charger
- Mikrotik hEX router
- partially self-designed, self 3d printed stack (open source)
I've decided to go with 4 Raspberries because I have got hEX router which has 5 ports and 4 of them seem enough for experimenting anyway. Make also sure to get short USB and network cables. The later should be flat to consume less space. Those are sadly hard to get in Slovenia, perhaps your best bet is an online shop somewhere (in the EU). Anker is a good USB charger that shouldn't have problems feeding the hardware but any powerful enough would do. Also if you manage to find an USB powered router, you don't need second 220V outlet for the router (currently I need two of these - one for the router and the other for the USB power charger) and have instead a short USB cable just like Raspberries do.
The biggest challenges
Getting short and flat network cables wasn't easy. Online shops outside of Slovenia will help.
Manufacturing and designing the stack that keeps everything together. I've based it on an existing one, but enhanced Raspberry holder
and created a compatible holder for both Anker USB charger
and mikrotik hEX
. I missed one thing though - replacing microSD cards is not easy - I've ended up using tweezers. If I ever update the design, I'll definitely make it easier. But overall it is a solid stack and should do the job just fine.
Connecting the beast
Not much here, router and USB charger need to be powered trough an outlet, all Raspberries need both network cable connected to router and USB one to the USB charger and that's it. Lights will blink and that's it.
Next post will deal with HypriotOS nad Kubernetes installation.
One of the many uses of an Arduino board is using it as an ISP (In-System Programmer). Which means burning bootloaders or programs without use of a bootloader directly to the ATmega CPU.
Why would somebody need to do that? Here is a real example.
I bought a 9 Degrees of Freedom Razor IMU a while ago. It is an Arduino compatible microcontroller with sensors in reality. Anyway, a small batch of these came with the wrong bootloader and I was lucky to get one of these. So, instead of sending it back and getting a new one I’d chose a simpler way. Burn the proper bootloader. There are ISPs out there that do the job just fine but for me it was an one time gig, thus I decided to go with an Arduino Mega ADK (which I have and I’ll refer to it simply as MegaADK) as an ISP.
A word of caution. This procedure worked for me. You might have a different hardware and it might not work well for you.
- Download ArduinoISP sketch that lives in Examples folder of Arduino IDE (using latest version – 1.0) to MegaADK.
Connect MegaADK and Razor through SPI
. (note: You will need to solder some pins to enable SPI on Razor). Pin 1 on Razor is marked with a white line (here you can find a diagram
for SPI header).
Connect (from MegaADK to Razor) MISO->MISO, MOSI->MOSI, SCK->SCK and SS->RESET. Power for Razor is brought through USB (using 3.3V FTDI Basic Break board
) but you can use other power sources.
Razor with marked pin 1 (blue) and SPI header (yellow)
(original photo taken from Sparkfun
- Using Arduino IDE select Tools/Programmer/Arduino as ISP and a target Tools/Board, which is Arduino Pro or Pro Mini (3.3V, 8Mhz) w/ ATmega328 in my case since ATmega328p is used on Razor.
- If everything worked properly you’d hit Tools/Burn Bootloader. But there is a bug in Arduino libraries that come with version 1.0. For some reason you have to find HardwareSerial.cpp source file (located in [Arduino setup folder]\hardware\arduino\cores\arduino. Edit the 43th line which goes like "#define SERIAL_BUFFER_SIZE 64” to “#define SERIAL_BUFFER_SIZE 128”. If the buffer isn’t set to 64 the burn process will most probably stop when it tries to burn data pages with error like this:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
- Hit the Tools/Burn Bootloader and wait for half a minute and there you go, a fresh bootloader is burned to the Razor and it can be programmed using classic Arduino way again.
Photo of my setup:
On the left is Razor, on the centre is Arduino Mega ADK and on the right is a bread board for three LEDs that signal the status of the ISP (green, red and yellow signalling the burning in progress).
Using Arduino BT
I think that it is quite possibly to use the Arduino BT (Bluetooth version). I am mentioning BT version because it has an interesting quirk and a feature.
A program mode LED mentioned above is attached by default to pin 7. The problem is that pin 7 on BT version is used to reset the bluetooth module and shouldn’t be used for anything else. Even if you don’t connect the LED it will reset the bluetooth module and thus drop the connection between Arduino IDE and ArduinoBT once the burn process begins.
The remedy is quite simple. Before downloading ArduinoISP sketch to the ArduinoBT (step 1) you should modify the sources by changing the pin used for signalling the program mode. There are two occurrences:
#define LED_PMODE 7 and the other in void setup() procedure (not sure why the later isn’t using the former). Change number 7 to any other suitable pin and the Bluetooth connection won’t drop anymore.
Serial port speed
Bluetooth communication in ArduinoBT is supposed to run at 119200 bauds, but the ArduinoISP sketch is using 19200 bauds. Simply change the value in void setup() procedure to Serial.begin(119200);
There you go, ArduinoBT is a functioning ISP now.
Hope this article will help somebody.
Today I’ve presented .NET Micro Framework to the students of Nova Gorica. I demonstrated running the C# code on Netduino by taking photos (on demand from client) using C328R camera, sending the JPG bytes over the wireless PAN provided by the two XBee Pros and showing the image within the WPF application running on the desktop. It was my first semi-hardware talk and it went fairly well I assume.
Attached are Power Point slides (in Slovene) and the demo code.
Note about demo: The client code requires PostSharp (if you compile it) for creating and implementing INotifyPropertyChanged. If you don’t have PostSharp then remove the references to it and NotifyPropertyChangedAttribute class. Then implement it manually for MainViewModel class.
mf.rar (13.00 mb)
I always wanted to do play with microcontrollers but I lacked hardware knowledge. Actually the last time I wanted to play with them was at the very early stages of the internet (during my university time that is). So I let it go for the time being because of lack of the available informations and other more important tasks (like going out with friends).
Now, 15 years later, the very same idea kicked in my head again. I was still hardware ignorant - more or less like I was 15 years ago. But this time there was a major factor in my advantage: Internet. So I went surfing for microcontrollers and soon found a priceless site for beginners and advanced users: Society Of Robots. The author has written plenty of tutorials that even a beginner can understand. The tutorials are excellent. There are also tutorials and other content provided by the author and community. But tutorials don't answer every question one can come up with - yes, there is a forum as well. And again, the forum is excellent as tutorials are - many skilled users are ready to answer (even beginner's) questions and many questions are already answered. The author of the site has even created its own MCU (microcontroller unit) Axon (it can be ordered on-line) - an advanced microcontroller worth checking out (I'll buy it, just to support his efforts if not for anything else, but not right now).
Now, armed with new the new knowledge I had to decide which microcontroller I am going to start with. The first choice was Axon, mentioned above, ATmega640 based one with plenty of in/out pins. I went browsing for alternatives. Soon it struck me: [MS] .net microframework might be a perfect choice. The drawbacks? Expensive compared to the Axon. It is much more powerfull in terms of CPU though. The thing is that I wasn't looking for a powerful MCU. Rather I was looking for two features:
- Bluetooth connection with PC - as a beginner I really didn't want to fry my workstation PC by a shortcircuit. That means no physical connection between two entities can exist to be on the safe side. (so far I didn't manage a shortcircuit anyway). Most of the MCUs communicate with PC via USB or RS232 port.
- It should be cheap - because I am a beginner and I don't want to make too much damage from the start.
After a while I've found Arduino - a cheap MCU and again, great site with a great forum and a huge community. Quote form the web site:
"Arduino is an open-source electronics prototyping platform based on
flexible, easy-to-use hardware and software. It's intended for artists,
designers, hobbyists, and anyone interested in creating interactive
objects or environments."
Society of Robots is friendlier to the beginners while this one has definitely a larger community. The base Arudino MCU (based on ATmega168, a chip from the same family as Axon's.) is dirty cheap (Arduino Duemillenova - 22€) and there is even DIY documentation (how to build it from the scratch). There is plenty of Arduino versions and even variations (Roboduino, RainbowDuino, etc.) The bluetooth Arduino BT (built in bluetooth Class I reciever - 100m range) version is cheap as well - 79€ from Smart Projects. Perfect. I went with it. You can buy from various on-line sellers found here.
So Arduino BT for the start it is. Next, for bringing it to live I needed an energy source. While it runs perfectly well on batteries (5.5V max for this particular version) I opted for a power supply instead. I bought a Voltcraft VLP 1602pro from Conrad in Slovenia. It is a dual channel thing with short circuit protection, voltage and current limitator - meaning it is very safe to use and can provide two different voltages at the same time. I'll use batteries when I'll need to move around Arduino.
Voltcraft VLP 1602pro
At that point I was able to power up Arduino and open the communication with PC via bluetooth.
To be continued...