Using an i2c RTC with the Carambola2 (or any OpenWRT modified router)

Apr 27 2015

Using i2c with a modded router is simple enough, if you have two spare GPIO then the module package kmod-i2c-gpio-custom allows selected GPIO pins to be bound to SCL and SDA respectively when the module is loaded.

However for inexplicable reasons the ability to bind an i2c RTC module to the Linux hardware clock is disabled by default by the OpenWRT configuration mechanism for ar71xx and other consumer router architectures, and there is no way to turn it on without patching!

Regardless, here is how to use an i2c RTC with the Carambola2 or any other ar71xx architecture router (e.g. WRTnode, etc.)

  • Patch the file target/linux/ar71xx/generic/target.mk as follows:
  • Patch the kernel configuration target/linux/ar71xx/config-3.xx where (xx depends on your version of OpenWRT) as follows:
  • Note: the kernel configuration can be modified via the kernel build system using the command make kernel_menuconfig
  • Note: add other kernel i2c RTC modules as required
  • Add the module to your image:
  • If you have previously built OpenWRT then remove the tmp/ directory, or the change ‘+rtc’ will be ignored and the DS1307 module will not be included in your image
  • Run make defconfig
  • Build your image: make -j2

If everything worked, then the the file /lib/modules/3.xx…/rtc-ds1307.ko should be in the resulting image

Following is an aggregation of information I was already able to find elsewhere on the net.

  • Ensure that i2c-tools package is installed as well. This may require the ‘oldpackages’ feed.
  • Configure the module as follows by creating a file /etc/modules.d/99gpio-i2c-rtc
  • You can also put this file into files/etc/modules.d/99gpio-i2c-rtc for it to be automatically added to your image
  • Create the following content, where in this example 18 == SDA pin id and 19 == SCL pin id
  • There are additional arguments controlling delays, etc.; refer to package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c
  • Create a script, /etc/init.d/rtc-driver to load the device driver and set the time.
  • Create a symlink…
  • Note, if you are running ntp that will take over anyway, but for system with an intermittent or no network connection, or if the network is down on boot, the RTC will provide a better time than 1 Jan 2012 or whatever…

You can test the above out before scripting it by booting the system and manually stepping through:

Enjoy!

PS Dont forget pullup presistors, and take care interfacing between 5V and 3.3V systems and peripherals…

No responses yet

Why is the Arduino IDE so stupid?

Apr 23 2015

If I perform the following actions:

  • File, New
    Opens a new editor window. Reasonable enough, although I would have preferred a default single-window GUI model like QtCreator or even gedit.
  • File, Save
    Opens a save as dialog. In spite of the Arduino ‘sketchbook’ directory, it opens in my home directory.
  • New Folder
    Creates a directory New Folder, but doesn’t shift the focus to it, leaving you confused when this is done in a directory with a lot of files…
  • Click on ‘New Folder’ and rename it, say, Test123
  • Navigate into Test123/
  • Type in a filename for the project, say, TestTest1
  • Hit save.
    So now Arduino IDE dutifully ignores what I typed and proceeds to create a tab called ‘Test123′.
    It will even do this if ‘Test123/’ already existed.
    What?
  • File, Save As.
    It forgets where you where in the hierarchy and starts in the home directory again(!)
  • Navigate to Test123/ intending to use it as a container for multiple projects
  • Type in a filename, say Hello, then hit Save
  • The sketch is _still_ called Test123.
    What?

So insanely enough, it seems you essentially create a director and thats where the sketch gets its name.  Within that directory it creates a file with the same name with the extension ‘.ino’

Lets try something else:

  • From the shell, create a directory, Test456 and create a readme.txt file, and a directory Test456a and a file Test456a/readme2.txt
  • File New
  • File save
  • Navigate into Test456
  • Type in helloworld for the name
  • Again, the project gets called Test456
  • But take a look in the directory Test456: the contents are now gone (all, including the sub directory Test456a) and replaced with Test123.ino
    Wait, what? THIS SHOULD NEVER EVER HAPPEN!!!!

Luckily I discovered this in a directory in a git working copy with no modifications so I didn’t lose anything important.

Testing done using Arduino1.5.8 amd64 for Digispark. So its a little out of date but not exactly the oldest either.

I have used Arduino before and to be honest I don’t recall it being this stupid, but maybe I just got lucky.

One difference is this time I got sick of the massive latency opening the windows and tried a few different Java JRE (openjdk6, openjdk7, gcc4.7-jre) before discovering that with gcc4.7-jre the menus are as snappy as the openbox right click menu, or even a (*sharp intake of breath*) brand new Windows 7 corporate desktop… maybe there is some API implementation difference between the JRE’s that affects the file save dialog functionality.

I don’t seem to have any issues opening projects.

So my workflow for creating a new project now consists of:

  • From the shell, create a directory in the relevant part of the git working copy I am using
  • Create a new empty .ino text file with the same name as the directory (or copy a template I made)
  • Open it with the IDE and start working

 

No responses yet

Challenge for 2015: hackaday prize competition

Mar 29 2015

So the 2015 Hackaday prize is happening, until at least August.

Somehow I’ve currently ended up involved with not one, but two entries!  The good thing is that with four months to go until the first round submission, I have been careful not to bite off more that can be chewed in the time available on weekends, or after the kids go to bed, etc. with other commitments. Along the way though it should be educational and fun, and with any luck I might at least win a T-shirt or something (some electronics test gear would be nice) … I’m under no illusion we will get anywhere near winning a trip to space!

The themes this year are is “Build Something that Matters”, around environment, agriculture and energy, with the related facet of solving a problem, and not necessarily a world-scale problem.

So my first project, of which I am making good progress, is a farm crop monitoring system for Australian conditions.  This utilises the ESP8266 wifi module and will exercise its deep sleep mode, and solar power, along with a yet to be determined Linux module for a local base station, and hopefully ISM band telemetry over long distances. I will also be helped by my neighbour who is a farmer who can use this system.

The second project, which is not my idea but that of a close friend, (but for which I am presently responsible for maintaining the hackaday.io page), is an Algorithmic Composting machine built out of repurposed parts and cheap electronics.  I’ll probably end up assisting with the embedded electronics, as well as keeping the documentation up to date.

I wont be posting here in a lot of detail as the contest progresses, as there is a project log built into the hackaday.io site intended for that purpose.  So follow along at http://hackaday.io/project/4758 and http://hackaday.io/project/4991  instead! (And please like our projects if you have a hackaday account!)

 

No responses yet

hacksa2015 – we won!

Mar 14 2015

The previous week we were informed that we were the winners of the first hacksa competition!

This was really awesome, we had put in a bit of work that week and it validates my ideas about how to approach a hackathon I blogged about previously . You can see our proof of concept web application at http://phaze.space

I think what helped us over the line was that we had a working web application that actually ‘did something’, or a ‘minimum viable product’ in the parlance: we demonstrated the primary user experience ( generate musical playlists when you don’t know what to choose ) along with various potential features illustrated by button placeholders.

There was a cash prize, and some music, and headphones, and a membership in a co-working space which we donated to the runner-up because we all have day jobs and wouldn’t be able to use it.  For me though the best prize was tickets to the NetWorkPlay conference held in Adelaide last week.  This was a completely different scene, this was a media industry conference (mostly documentary film-makers, and a mix of other film industry and media) and I met some different and quite interesting people.

One takeaway from NetWorkPlay as a software guy was research showing that most younger people directly use youtube as a search engine instead of google when searching for media. This was interesting, my first instinct (habit?)  is using google or other ‘traditional’ search engines even when searching for videos that ends up with me on YouTube anyway. A learned quite a few other interesting things, and more importantly had to move out of my comfort zone and had a good time interacting with people I would never have likely crossed paths with.

So thanks to my team members (you know who you are) for an awesome effort, and I’m looking forward to govhack 2015!

I’d also like to thank the competition organisers, including madeinkatana.com , SA Music Development Office, Musitec and Flinders New Ventures Institute, and the sponsors for the generous prizes.

No responses yet

Expanding Horizons

Feb 16 2015

Looking back, I do seem to blog a lot about the software & open source technology!

I do have wider interests though, I read widely & ponder about space technology, graph theory & network science, open data, math, economics, history, politics, or anything really. I find that taking the time to learn about new and unrelated topics, just like taking the time to meet new people with different interests, tends to increase the chance of serendipitous opportunities, or provide “outside the square” insights into problems I am currently working on.

Everyone has Jargon

Along with last months foray into music & content, I have been studying the tech startup economy. I find it fascinating learning how to decode the jargon, and I guess I experienced a bit of what other people probably get when relating to IT / software developer people :-)  One thing I discovered is the extent to which the startup scene itself has spawned an industry built on servicing the startups and the venture capital firms that provide funding. Whether this is an indication of a maturing market since the days of the DotCom boom, time will tell.

The startup industry has a cross-over into open source. Many new businesses are founded using open source: nearly every web app that is not a pure Microsoft build would be using some combination of open source tools (and the Microsoft Azure service supports Linux); many provide premium services related to an open source product which helps spur further development in that product.  I think this is a good thing for open technology generally as it benefits the entire community, not just that business, as would be the case with a purely closed product.  By contributing to open source, the business can concentrate on value adding around its core “thing” whilst leveraging the community in a two-way effort to improve the overall software ecosystem.  Paraphrasing Bob Young from one of the Linux.conf.au keynotes, open source is a long term form of barter benefiting everyone.

Another cross-over is the Lean Startup methodology. A friend dragged me along to a workshop the other week, and it was really interesting to see some of the parallels with agile software development.

In Adelaide there is a growing niche / tech startup community which I think is refreshing and important to the future of this city, for so long  heavily reliant on either the vanishing manufacturing sector, the illusory and fading mining boom, or the defence sector so often cut at the whim of a government.  High technology must form a core of our economy into the future if we are to remain a vibrant state!  I have become more aware of this since participating in the hackathons, which although a fun activity for myself, often cross-over into the startup community.

Sharing the Load

One discovery I made is AngelList Syndicates, a way of letting small investors pool funds and invest small amounts (say, in the order of $1000-$5000) into high tech startups. This is probably not for the novice investor, but I would not be averse to investing a percentage of my superannuation into this area.  I will be doing quite a bit more research first however, to try and get a better handle on the investment risk, and the impact of Australian superannuation law! I found available information about the many small and non-listed technology companies, largely US based, but also in Australia,  opaque to say the least.

As part my research I am subscribed to a few startup sector  mailing lists, interestingly this has led me to discover quite a few new websites or technology services I would not otherwise have found  about.  I try out a lot of free web apps, but usually skip the paid services because I cant justify the cost at this point.  Sometimes there are trial offers for various services though, and I came across one interesting site, Mattermark, that claimed to track private and startup companies, many of the kind found on AngelList.  I asked some questions about whether it was relevant to my interests in Australia and along the way ended up having email conversation with one of the developers which was actually really pretty cool, so I figured I’d give it a go.

Trial Run

After I accessed the web app, obviously the first thing I did was find the Location menu and switch to Australia :-)
This produced a spreadsheet-like display with companies in rows, and various metrics across the columns. I was quite surprised to recognise several businesses I knew, such as CoinJar, muru-D and other companies I didn’t even realise were Australian, such as Canva. Oddly the NSW Greens were reported as a company despite being a political party.  It seems Mattermark uses in machine learning to aggregate data from multiple feeds, and there were not too many other oddities, so having only one or two out of place entries in such a large database is pretty good.

Companies are initially ranked by ‘Growth Score‘ a term I had to research, and it seems to be a metric combining funding and employee count with social media and downloads, all things I presume are important to measuring a business growth in a period where it might not be producing much revenue as yet.

Another search I tried was ‘Space Travel’, which was provided as one of many possible categories.  This was very interesting to me because I keep coming across new space commercialisation ventures on twitter, but seeing a whole pile of them listed in one place was rather exciting. (As in, the future is finally nearly here!)

In fact there are rather a lot of categories!

I have some screenshots but until I get around to posting them there is a video showing how it might be used by its primary customer base on Youtube.

I regularly canvass LinkedIn for interesting & local technology businesses, for networking opportunities and community event promotion, but that can be hit and miss. I think Mattermark could be a helpful complement to that, although the subscription is too pricey for me in my situation as a hobbyist / small investor.  This would likely be a useful tool for anyone working in the startup services industry or dealing with managing investments but if thats your thing you should probably do your own research and take the trial for a spin rather than relying on my opinion as an amateur.

Now, hopefully I’ll find something to blog about in space technology soon!

 

No responses yet

Older posts »