Steffest Digitale Pulptuur

Reacties
Where in Belgium can you buy the Wifi shield? Or where did you get it online? I'm looking for an online store for electronic stuff related to Arduino. Thanks!
Gilles - 13/03/2011 22:50:51

I ordered it from http://www.asynclabs.com/store?page=shop.product_details&product_id=26&category_id=6&vmcchk=1 but apparently it's no longer available...

Op http://www.antratek.nl/Shields.html verkopen ze ook een WiFly Shield. beetje duur wel.

Steffest - 13/03/2011 23:00:25 http://blog.stef.be



Commentaar toevoegen
Je reactie
Je naam
Url (van je website of blog of ....)
Antispam
Om zeker te zijn dat je geen Spam-robot bent, moet je even de volgende vraag beantwoorden:
Wat is geen kleur: groen, auto, geel, blauw

Geef je commentaar op:
The Zen of Hardware Hacking

The 4th Barcamp in Antwerp - And a great one it was.
I gave a talk about "The Zen of hardware-hacking" , indicating that there's a noticeable shift in my attitude towards hardware and software - I still want high-tech everywhere around me, but at the same time it has to be as invisible as possible, completely out of the way if you don't need or want it.

As a hardware demo - to make it a bit more concrete - I made the fantastic KWISKWAT-O-MATIC ! :-)
The technical part is an Arduino with a wifi shield that holds a little webserver.
The beauty is that - once programmed - it runs completely on it's own with VERY low power consummation.
When you access the webserver you can send little commands to control the physical object (the arduino) - in this case toggling some coloured lights.
Physical devices become a part of the web that way and are easy to connect to any webservice out there.
The KWISKWAT-O-MATIC is connected to the Telenet tv.be API I made some time ago: Whenever a new episode of Kwiskwat is aired (and recorded by the Telenet digicorder), the light turns green, if no new unseen episode is available, the light is red.
image image image

Here's the Arduino script - it runs a very (VERY) limited webserver, which is perfect for controlling little hardware devices.

#include

#define WIRELESS_MODE_INFRA    1
#define WIRELESS_MODE_ADHOC    2

unsigned char local_ip[] = {192,168,1,120};    // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1};    // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0};    // subnet mask for the local network
//const prog_char ssid[] PROGMEM = {"Wireless"};        // max 32 bytes
const prog_char ssid[] PROGMEM = {"HTC network"};        // max 32 bytes

unsigned char security_type = 0;    // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"12345678"};    // max 64 characters

// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = {    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,    // Key 0
                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    0x00,    // Key 1
                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    0x00,    // Key 2
                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    0x00    // Key 3
                                };

unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;

int ledPin =  14;

void setup()
{
        pinMode(14, OUTPUT); 
        pinMode(15, OUTPUT); 
        pinMode(16, OUTPUT);
        digitalWrite(14, 1);
        digitalWrite(15, 1);
        digitalWrite(16, 1); 
    WiFi.init();
}

// This is the webpage that is served up by the webserver
const prog_char webpage[] PROGMEM = {"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"};

void loop()
{
    WiFi.run();
}

-------------------------------------------

/******************************************************************************

  Filename:        webserver.h

******************************************************************************

  Based on the TCP/IP stack and driver for the WiShield 1.0 wireless devices by Async Labs Inc.

*****************************************************************************/

#include "uip.h"
#include
#include "webserver.h"
#include "config.h"

static int handle_connection(struct webserver_state *s);

void webserver_init(void)
{
    uip_listen(HTONS(80));
}

void webserver_appcall(void)
{
    struct webserver_state *s = &(uip_conn->appstate);

    if(uip_connected()) {
        PSOCK_INIT(&s->p, s->inputbuf, sizeof(s->inputbuf));
    }

    handle_connection(s);
}

#define ISO_nl      0x0a
#define ISO_space   0x20
#define ISO_slash   0x2f

#define ISO_R   0x52
#define ISO_G   0x47
#define ISO_B   0x42

#define ISO_O   0x4f

unsigned char ch;

const char http_get[5] = {0x47, 0x45, 0x54, 0x20, };    /* "GET " */

unsigned short fill_buf(void* blk)
{
    unsigned short webpage_len;

    webpage_len = (strlen_P(webpage)>uip_mss())?uip_mss():strlen_P(webpage);

    memcpy_P(uip_appdata, webpage, webpage_len);
    return webpage_len;
}

static int handle_connection(struct webserver_state *s)
{
    PSOCK_BEGIN(&s->p);

    // read incoming data until we read a space character
    PSOCK_READTO(&s->p, ISO_space);

    // parse the data to determine if it was a GET request
    if(strncmp(s->inputbuf, http_get, 4) != 0) {
        PSOCK_CLOSE_EXIT(&s->p);
    }

    // continue reading until the next space character
    PSOCK_READTO(&s->p, ISO_space);

    if(s->inputbuf[0] != ISO_slash) {
        PSOCK_CLOSE_EXIT(&s->p);
    }else{
        if(s->inputbuf[1] != ISO_space) {
                if (s->inputbuf[1] == ISO_R){
                   digitalWrite(14, 0);
                   digitalWrite(15, 1);
                   digitalWrite(16, 1);
                }
                if (s->inputbuf[1] == ISO_G){
                   digitalWrite(14, 1);
                   digitalWrite(15, 1);
                   digitalWrite(16, 0); 
                }
                if (s->inputbuf[1] == ISO_B){
                   digitalWrite(14, 1);
                   digitalWrite(15, 0);
                   digitalWrite(16, 1); 
                }
                if (s->inputbuf[1] == ISO_O){
                   digitalWrite(14, 1);
                   digitalWrite(15, 1);
                   digitalWrite(16, 1); 
                }
        }

    PSOCK_GENERATOR_SEND(&s->p, fill_buf, 0);
          }
        PSOCK_CLOSE(&s->p);
    PSOCK_END(&s->p);
}


The slides of my presentation can be found at http://www.stef.be/barcamp/bca4.html  (click for the next slide)
They are not very usefull without the talk, but still ...

 The Tech45 podcast was also present and made a special Barcamp Antwerp4 edition (with a little interview with yours truely, hopefully online soon)
Marco Frissen made some nice pictures
web_BCA4-0026
More here

 


Thanks @cubus and @ichoosr for a very nice Barcamp, and thanks to the sponsors GVA, Sw�rl, Stad Antwerpen, Krimson, Just-Eat, Digiti, Belgian Cowboys, iChoosr