summaryrefslogtreecommitdiff
path: root/hw/merkur-board.mdwn
blob: 0a58841d678ee1c89768af4e0b1239d91e650d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# 6LowPAN with the Merkur-Board

In for the [[rpi6lowpan]] to be actually usefull it needs to talk to
some sensors. The [Merkur Board][0] is open hardware:

[[!img merkur-board.jpg size="x150" alt="Merkur-Board"]]

It has digital outputs as well as digital, analog and PWM outputs and
supports attaching Arduino Grove Modules which should make experiments
simple.  In order to test things I use the
[Plant Oberservation Kit][1] set.

One uses USB-Serial converter to flash the device. Details on how to
connect it are [here][2]. Once the converter is attached to the board
it's LED starts to blink (in my case 4 times short, one time long).

Once flushed the board can be run on [battery power][3].

* [Details on the different pinouts][4]
* [Details on how to flash the device][5] with avrdude
* The plant moisture sensor connects to [A5][6]
* [Find A5][] on the Grove Board

Compiling works like

    apt-get install avr-libc binutils-avr gcc-avr gdb-avr simulavr avrdude doxygen
    git clone https://github.com/osdomotics/osd-contiki
    cd ./osd-contiki/examples/osd/arduino-plantobserving
    ./run.sh

The build software can then be flushed to the device.  Note that it uses
/dev/ttyUSB0 by default. This needs to be adjusted. When trying the flash the
merkur-board with the usual USB-serial converter I see:

	$ sudo apt-get install avrdude
	$ cd osd-contiki/examples/osd/arduino-plantobserving
	$ ./flash.sh /dev/ttyUSB4
	INFO: compiling with CoAP-13
	avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB4 -b57600 -e -U \
    flash:w:arduino-example.osd-merkur.hex:a -U \
    eeprom:w:arduino-example.osd-merkur.eep:a
	avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x72
	avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x6c
	avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xc0
	avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x72
	avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x6c
	avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xc0
	avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x72
	avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x6c
	avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x72
	avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6c

	avrdude done.  Thank you.

	Makefile:88: recipe for target 'flash' failed
	make: *** [flash] Error 1

even if I [ground the reset pin][7] (Pin 3). However if I use a [*FTDI basic
breakout*][8] flashing works as expected:

	....

The flashed firmware uses *channel 26* and *pan_id 0xabcd* by default.  This can
be seen on the serial output (you can use the same serial converter as for
flashing). To read the serial console I've so far used the serial console
window from the arduino ide since *screen* doesn't support the 38400 baud used
by the merkur-board ().

While I'm seeing packages looking for a RIPL router send by the merkur-board
when using a Raspberry Pi as described in [[here|rpi6lowpan]], I can't ping the
board on it's link local address yet.

So let's for now use a second merkur board as [edge-router][].

    $ sudo ./tunslip6 -s /dev/ttyUSB4 -B 38400 2001:DB8:c001:f00d::1/64
    $ ping6 -c 1 2001:db8:c001:f00d:221:2eff:ff00:347c
    PING 2001:db8:c001:f00d:221:2eff:ff00:347c(2001:db8:c001:f00d:221:2eff:ff00:347c) from 2001:db8:c001:f00d::1 tun0: 56 data bytes
    64 bytes from 2001:db8:c001:f00d:221:2eff:ff00:347c: icmp_seq=1 ttl=63 time=201 ms
    --- 2001:db8:c001:f00d:221:2eff:ff00:347c ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 201.620/201.620/201.620/0.000 ms
    $ ./coap-client -m get coap://[2001:db8:c001:f00d:221:2eff:ff00:347c]/.well-known/core
    v:1 t:CON c:GET i:8ecd {} [ ]
    </.well-known/core>;ct=40,</moisture/v>;title="Moisture voltage"v:1 t:CON c:GET i:8ece {} [ ]
    ;rt=UCUM:"V";ct="0 5"

We can now query the moisture sensor using [libcoap]:

    $ ./coap-client -m get coap://[2001:db8:c001:f00d:221:2eff:ff00:347c]/moisture/v


## Some Linux, Contiki interop progress

Looking into the above problem in some more detail it shows that using
[[rpi6lowpan]] setup in [monitor mode][] we see all the packages sent
from the merkur boards on Linux but not vice verca. If we
[disable sleep mode][] in contiki we can receive frames from Linux
when pinging the merkur-board from the Raspberry Pi:

    Received NS from fe80::80cd:9a1:845b:4d6a to ff02::1:ff00:3304 with target addressfe80::221:2e��f:ff0N��
    Sending NA to fe80::80cd:9a1:845b:4d6a from fe80::221:2eff:ff00:3304 with target address fe80::221:2eff:ff00:3304
    sicslowpan output: sending packet len 80
    before compression (40): 6000000000283aff
	...

...but the Linux node doesn't see the replies. More to come when we have a second pi that can act as monitor.

[0]: http://osdwiki.open-entry.com/doku.php/de:projekte:merkur
[1]: http://osdwiki.open-entry.com/doku.php/de:projekte:plant_observation_kit
[2]: http://osdwiki.open-entry.com/doku.php/de:tutorials:first_steps_arduino_ide
[3]: http://osdwiki.open-entry.com/lib/exe/detail.php/de:ideen:merkurknoten.jpg?id=de%3Aideen%3Afirststepsmerkurboard
[4]: http://osdwiki.open-entry.com/doku.php/de:projekte:merkur#pinouts
[5]: http://osdwiki.open-entry.com/doku.php/en:projekte:bootloader?s[]=flash
[6]: http://osdwiki.open-entry.com/doku.php/de:products:merkur_grove_board_4#steckerbelegung
[7]: http://www.meetup.com/IoT-Vienna/events/181968432/
[Prolific Pinout]: https://jethomson.files.wordpress.com/2010/02/ca-42_dku-5_pinout.jpg
[8]: http://www.open-entry.com/coxcoon/de/Zubehoer/FTDI-Basic-Breakout-3-3V.html
[edge-router]: http://osdwiki.open-entry.com/doku.php/de:tutorials:contiki:merkur_board_rpl_usb_router
[Find A5]: http://osdwiki.open-entry.com/doku.php/de:products:merkur_grove_board_4
[libcoap]: http://sourceforge.net/projects/libcoap/
[monitor mode]: http://wpan.cakelab.org/#_sniffing
[disable sleep mode]: https://github.com/agx/osd-contiki/commit/5ecf780a4873b6942e50964cfcb3d067b0a60cce