tag:blogger.com,1999:blog-84751278906023040182024-02-20T15:52:02.253-08:00[kontroller]embedded and robotic makes and hacks!Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8475127890602304018.post-57955857102387919892013-04-17T16:55:00.002-07:002013-04-17T17:03:32.229-07:00Zigbee for Raspberry PiThe hardware setup I'm using is explained in <a href="http://kontroller.blogspot.co.uk/2013/04/wirelesszigbee-for-pic-micros.html">Wireless/Zigbee for PIC Micros</a>. If we can use this as a USB dongle for PC (shown in <a href="http://kontroller.blogspot.co.uk/2013/04/zigbee-for-c.html">my previous post</a>), it should be simple enough for using it with our hot favorite Raspberry Pi. FT232R is a very widely used chip with good driver support for Linux as well.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-WjMLwWKWq08/UW8yKUrjX9I/AAAAAAAAAD4/TK1g44bmvt4/s1600/pi_rf.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="http://3.bp.blogspot.com/-WjMLwWKWq08/UW8yKUrjX9I/AAAAAAAAAD4/TK1g44bmvt4/s320/pi_rf.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
USB-Zigbee Dongle connected to Raspberry Pi (left breadboard), peer being debugged (right breadboard) and Zena analyzer in the background.</div>
<br />
For the software side on Raspberry Pi, we have plenty of options, C/C++, python, shell or even the C# application (haven't tried mono on Pi yet). Later this month, I'll post an assembled version of the dongle and with some code examples too.<br />
<br />
I'm really excited about this one and keen to show you how I'm using this as the internet gateway for my micros, sensors and robots.<br />
<br />
Stay tuned!Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com1tag:blogger.com,1999:blog-8475127890602304018.post-77419685493614140642013-04-17T16:27:00.000-07:002013-04-17T16:27:33.490-07:00Zigbee for C#Utilizing the setup I have in the <a href="http://kontroller.blogspot.co.uk/2013/04/wirelesszigbee-for-pic-micros.html">Wireless/Zigbee for PIC Micros</a>, I just needed an USB-UART interface to make a Zigbee adapter for the PC. FDTI's USB-Serial IC FT232R has been my favorite for sometime for the serial interface for PICs. And that in fact completes the hardware setup of my USB-Zigbee dongle: a PIC18F26K20, MRF24J40MA and FT232R.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-AS7VB3TAYm4/UW8jHcZUZxI/AAAAAAAAADw/JRM7BbGDX64/s1600/IMAG0774.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="256" src="http://2.bp.blogspot.com/-AS7VB3TAYm4/UW8jHcZUZxI/AAAAAAAAADw/JRM7BbGDX64/s320/IMAG0774.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
The USB can easily power this micro and radio.</div>
<br />
On the firmware side, we can take several approaches to support PC side (a C#, C++ or any application) to send message to and receive message from a Zigbee network. One good approach is to make the RF layer transparent so that PC side using the dongle doesn't have to think about the RF network. It'll simply send message to UART and same message (maintaining the baud rate) will be delivered to the target node. It'll be a good abstraction of the physical RF network.<br />
<br />
However, that approach will be a future blog post and for now I'm using a much simpler implementation where PC sends predefined 'commands' with parameters to the dongle and the dongle processes them. Purely for an example, PC can send "light1 on" to the dongle (which is more like a Zigbee gateway device in this case) and dongle will send message to "light1" device to turn it on.<br />
<br />
Next week, I'll show how this hardware setup can be used to control devices, sensors or robots wirelessly from a PC or even the internet. By the way, a cool robot is coming up later this month! :)Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com0tag:blogger.com,1999:blog-8475127890602304018.post-51538968962516161612013-04-08T15:02:00.000-07:002013-04-08T15:02:42.961-07:00Wireless/Zigbee for PIC MicrosBack in 2009, my professional work involved leading the firmware project of a low power wireless network of sensors collecting temperature and humidity data. Wireless gateways accumulated the information and sent to a data center over the internet. During that project, I fancied my own Zigbee network for my robots and setting up a network of home monitoring sensors. I eventually bought some Microchip MRF24J40MA modules (which is a completely different platform than my professional work). Unfortunately, the modules had been siting idle for more than 3 years and until very recently, I didn't get a chance to play with them.<br />
<br />
Microchip has a great library called Miwi which provides out of the box Zigbee like infrastructure based and P2P protocols. There are plenty of demo boards available as well. However, to fit wireless into projects where space is a luxury, you need to get your hands dirty.<br />
<br />
I prefer building my own platforms from the scratch rather than using ready solutions like the microchip demo boards or even the Arduino and Zigbee shields. While Arduino and its sheilds are excellent kits for beginners, I feel I have a different taste. Arduino + Zigbee shields are insanely expensive as well. For example, a set Arduino + Zigbee shields will cost £40 or more while PIC + its radio modules are less than £7. So you can easily have a whole network of PICs with the price of one bulky Arduino Zigbee :). I'm happy with any low level programming challenge the PIC solution will through at me (In fact, that's what I really enjoy doing).<br />
<br />
I'm using the PIC18F26K20 for the network. With 64KB ROM, 4K RAM, 16 mips/64 MHz and XLP, it has been adequate for my hobbits works for some years. Here's how my prototypes look like:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-qzOs4DVLxvk/UWM4FtucvPI/AAAAAAAAADY/eEv0Br_C6a8/s1600/rf_send.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="http://2.bp.blogspot.com/-qzOs4DVLxvk/UWM4FtucvPI/AAAAAAAAADY/eEv0Br_C6a8/s320/rf_send.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Sending data to the Zena network analyzer.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-3B_sJ6HkF8s/UWM4GNweoeI/AAAAAAAAADg/BH4vfcnfiO8/s1600/rf_recv2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="http://2.bp.blogspot.com/-3B_sJ6HkF8s/UWM4GNweoeI/AAAAAAAAADg/BH4vfcnfiO8/s320/rf_recv2.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Sending and receiving tests with two sets of modules.</div>
<br />
So my Zigbee network is ready to be plugged in (to my next projects). The assembled version of these prototype boards will look very different. I'll introduce the PCB version soon.<br />
<br />
Later this week, I'll present how to talk to a micro wirelessly from C#, how to add wireless internet to a PIC and how to add Zigbee support to a Raspberry Pi. Sounds interesting?<br />
<br />Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com10tag:blogger.com,1999:blog-8475127890602304018.post-8601295008379584772013-04-07T15:56:00.002-07:002013-04-08T13:15:28.376-07:00Wifi router/dongle for TV using Raspberry PiLike most connected TVs, mine is ethernet only. The lack of wifi and moreover the price of the propitiatory wifi dongle bothered me a bit. With couple of Raspberry Pis collecting dust, I thought of a new place for them. It's behind the TV working as a wifi to ethernet adapter/router. One of the USB ports of the TV can power it (and thus the adapter turns on and off with the TV). Here's how simple it can look.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-8FEYhRxwADY/UWH1hfbQ5RI/AAAAAAAAADI/MelCQSjzMyQ/s1600/lan_adapter.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="http://3.bp.blogspot.com/-8FEYhRxwADY/UWH1hfbQ5RI/AAAAAAAAADI/MelCQSjzMyQ/s320/lan_adapter.JPG" width="320" /></a></div>
<br />
Raspberry Pi with the cute Asus N10 wifi dongle gave me everything I needed for the adapter. I just needed to set up the DHCP host for ethernet and the routing. Not being an expert of routing, troubleshooting it was a bit distressful but the hour was well worth. HD streaming was smooth and BBC iPlayer never felt so delightful! :)<br />
<br />Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com0tag:blogger.com,1999:blog-8475127890602304018.post-44024260842017009702013-04-04T17:59:00.000-07:002013-04-07T12:33:51.670-07:00Raspberry Pi Weather station (in 5 mins)Here is an example of how small scripts can give you amazing makes. Here's my weather station using the LCD display I mentioned in my previous post: <a href="http://kontroller.blogspot.co.uk/2013/04/an-lcd-display-for-raspberry-pi.html">An LCD display for Raspberry Pi</a>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: center;">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-E97_WtVlcfE/UWHJZwgmGLI/AAAAAAAAACw/X_YvoF1mM7o/s1600/weather2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="http://2.bp.blogspot.com/-E97_WtVlcfE/UWHJZwgmGLI/AAAAAAAAACw/X_YvoF1mM7o/s320/weather2.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-Cm6cJqOqi3o/UWHJZ9n7jpI/AAAAAAAAAC0/h1UJK62oAvo/s1600/weather1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="http://3.bp.blogspot.com/-Cm6cJqOqi3o/UWHJZ9n7jpI/AAAAAAAAAC0/h1UJK62oAvo/s320/weather1.jpg" width="320" /></a></div>
<br />
(Photos updated: April 7, 2013)</div>
<br />It's displaying weather forecast for Cambridge, UK. <strike>That's a miserable weather indeed :).</strike> As you can guess, the first line is the current condition followed by next two day's forecast which includes high and low temperatures (in Celsius). The last line is the date and time of update.<br />
<br />
The awesome bit is you can make this with 20 lines of scripting and in less than 5 mins. Here is how it works:<br />
<ol>
<li>Grabs the weather data from Yahoo weather feed.</li>
<li>Extracts key weather data from the xml feed, and</li>
<li>Displays the data to the LCD.</li>
</ol>
The whole thing is done with this shell script (which I'm sure can be further reduced a lot):<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-xZE90UboCoA/UV4TiQU89DI/AAAAAAAAACQ/dWBrA8JrJnA/s1600/weather-sh.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-xZE90UboCoA/UV4TiQU89DI/AAAAAAAAACQ/dWBrA8JrJnA/s1600/weather-sh.png" /></a></div>
<br />
Most of the script above is for converting the rss weather feed xml into those few lines to display. It writes the information in a file which is then read and displayed to LCD by a python script. Here's the python script to display the info in green color only:<br />
<pre class="python" name="code">#!/usr/bin/env python
from pylcdsysinfo import BackgroundColours, TextColours, TextAlignment, TextLines, LCDSysInfo
from time import sleep
d = LCDSysInfo(); d.clear_lines(TextLines.ALL, BackgroundColours.BLACK)
d.dim_when_idle(False);d.set_brightness(127);d.save_brightness(127, 255)
d.set_text_background_colour(BackgroundColours.BLACK)
f = open('yw', 'r'); col = TextColours.GREEN; c = 1;
for line in f:
d.display_text_on_line(c, line, False, TextAlignment.LEFT, col)
c = c + 1
</pre>
<br />
That's 20 lines of scripting doing it all! Yet another example of how awesome shell and python scripts are.<br />
<br />
You can run this every hour simply by adding a cron job. There is a bit of details involved before you can use this code. You need the python lib for the LCD and also a bit of info on how Yahoo weather feed works: <a href="http://developer.yahoo.com/weather/">http://developer.yahoo.com/weather/</a>. To get the forecast for your location, you need the WOEID (Google: WOEID finder) and to pass it to the Yahoo weather feed url.<br />
<br />
I understand I should provide detailed steps for beginners, perhaps as an instructable. If you want to see the detailed steps, do let me know in the comments :).<br />
<br />Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com36tag:blogger.com,1999:blog-8475127890602304018.post-2065798269011366152013-04-03T08:34:00.001-07:002013-04-03T15:09:56.777-07:00An LCD display for Raspberry PiHooking up a portable lcd display to Raspberry Pi can open up tons of ideas. PC or network status monitor, notifier for email, tweets, comments or feeds, weather station or a display for a robot are just a few ideas one could think of in about ten and half seconds :).<br />
<br />
With too many options to pick from, I suddenly came across this one.<br /><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-C6jKUwSALQQ/UVxJjFOC3JI/AAAAAAAAABM/L8gsCvh0Q8Y/s1600/LCD1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="http://1.bp.blogspot.com/-C6jKUwSALQQ/UVxJjFOC3JI/AAAAAAAAABM/L8gsCvh0Q8Y/s320/LCD1.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-E79ClgFa6XY/UVxJkZtKInI/AAAAAAAAABc/0xZf4hImhjs/s1600/LCD2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="http://2.bp.blogspot.com/-E79ClgFa6XY/UVxJkZtKInI/AAAAAAAAABc/0xZf4hImhjs/s320/LCD2.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-dtds4IsrX5w/UVxJkZ5sl6I/AAAAAAAAABk/mWL_nQCScbg/s1600/LCD3.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="http://4.bp.blogspot.com/-dtds4IsrX5w/UVxJkZ5sl6I/AAAAAAAAABk/mWL_nQCScbg/s320/LCD3.JPG" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-1AyesL017IQ/UVxJkYVAB8I/AAAAAAAAABg/QtMRxKpZFdI/s1600/LCD4.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="http://1.bp.blogspot.com/-1AyesL017IQ/UVxJkYVAB8I/AAAAAAAAABg/QtMRxKpZFdI/s320/LCD4.JPG" width="320" /></a></div>
<br />
It's an assembled 2.8 inch color graphics LCD with on board LCD controller and a resolution of 320x240. Found on ebay and it's almost a brand-less product.<br />
<br />
What caught my attention is the USB interface, good looking form factor and the software support. It's based on libusb, so can be programmed from many languages. There are code examples using C# and a python port is also easily found. It should be simple to plug this into the Raspberry Pi or the PC and displaying some text in python or c# in a couple of minutes. No soldering or jumper wire required. It also works as a tiny photo frame with an on board 2 mb flash. For the downside, it has a poor refresh rate.<br />
<br />
In the next post, I'll show how to build a Raspberry Pi weather station using this LCD under 5 minutes. If you had this display, how would you use it? Do share you ideas. If it is an easy one, I might give it a try.Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com14tag:blogger.com,1999:blog-8475127890602304018.post-90791405472227712432013-04-02T09:04:00.000-07:002013-04-07T12:48:36.615-07:00[Kontroller]: A bit of intro!Setting up this blog simply to share my works on embedded, robotics and vision. I try to play with these when I get a chance. Here's the list of the first few entries coming up:<br />
<br />
<b>Tomorrow, 3rd April:</b><br />
An LCD display for Raspberry Pi<br />
<br />
<b>Later this week:</b><br />
Raspberry Pi Weather station<br />
Wifi router/dongle for TV using Raspberry Pi<br />
Portable Wifi camera using Raspberry Pi<br />
<br />
<b>And, for next week:</b><br />
Wireless/Zigbee for PICs<br />
Wireless/Zigbee temperature monitor<br />
Zigbee for C#<br />
Zigbee for Raspberry Pi<br />
Internet connected PICs<br />
<div>
<br /></div>
<div>
Interesting enough for bookmarking the site? Thanks for your time!</div>
<br />
Edited: April 7, 2013, the original intro was a bit boring :)<br />
<br />Anonymoushttp://www.blogger.com/profile/00380260414372977573noreply@blogger.com1