Inspired by the great work going on here - and especially delighted that Zeroday has opened up the lua firmware - I decided to try writing a program in lua.
I needed to start working with i2c so I decided to port a scanner sketch over - see here for an arduino(ish) example: http://jeelabs.net/boards/6/topics/4356
So after a bit of head-scratching here it is (any improvements, suggestions etc welcomed!):
-- Based on work by zeroday & sancho among many other open source authors
-- This code is public domain, attribution to email@example.com appreciated.
id=0 -- need this to identify (software) IC2 bus?
sda=3 -- connect to pin GPIO0
scl=4 -- connect to pin GPIO2
-- initialize i2c with our id and pins in slow mode :-)
-- user defined function: read from reg_addr content of dev_addr
function read_reg(dev_addr, reg_addr)
i2c.address(id, dev_addr ,i2c.TRANSMITTER)
print("Scanning I2C Bus")
for i=0,127 do
if (string.byte(read_reg(i, 0))==0) then
print("Device found at address "..string.format("%02X",i))
I am really starting to enjoy lua - it seems really easy to just do stuff!
Keep up the good work everybody
2015 is gonna be a great year for IoT gadgets!!!