Sunday, November 20, 2016

IPv6, Arduino, and temperature

Referring to what I learned last time, I installed the SparkFun library for the HTU21D. Then I did a simple mash-up of MiniHTTPServer and SparkFun_HTU21D_Demo, and it worked on the first try. I think I spent so much time starting two years ago being frustrated with the uIP library that I guess I don't expect Arduino to be simple, or even to work. However, I can now read temperature and humidity over IPv6 for around $25 from eBay, now that I found a working IPv6 (single-stack) library in EtherSia. I'm not complaining, but it just feels anticlimactic after all those months of arguing with the first Ethernet library to have the second Ethernet library work right away with minimal effort.

Lesson (re)learned: Always use the right tool for the job.

For future reference, this sketch would not work with an Arduino with less memory than the Nano v3; it needs that 2kB of SRAM. My hardware is HTU21D for temperature and humidity, NanoShield and EtherSia for IPv6 Ethernet, and Arduino Nano v3.

My code with EtherSia_ENC28J60:
Sketch uses 12,162 bytes (39%) of program storage space. Maximum is 30,720 bytes.
Global variables use 1,263 bytes (61%) of dynamic memory, leaving 785 bytes for local variables. Maximum is 2,048 bytes.

My code, but claiming EtherSia_W5100:
Sketch uses 11,864 bytes (38%) of program storage space. Maximum is 30,720 bytes.
Global variables use 1,259 bytes (61%) of dynamic memory, leaving 789 bytes for local variables. Maximum is 2,048 bytes.

SparkFun_HTU21D_Demo:
Sketch uses 5,656 bytes (18%) of program storage space. Maximum is 30,720 bytes.
Global variables use 460 bytes (22%) of dynamic memory, leaving 1,588 bytes for local variables. Maximum is 2,048 bytes.

Packet Printer (EtherSia_ENC28J60):
Sketch uses 7,406 bytes (24%) of program storage space. Maximum is 30,720 bytes.
Global variables use 1,053 bytes (51%) of dynamic memory, leaving 995 bytes for local variables. Maximum is 2,048 bytes.

Mini HTTP Server (EtherSia_W5100):
Sketch uses 8,112 bytes (26%) of program storage space. Maximum is 30,720 bytes.
Global variables use 1,025 bytes (50%) of dynamic memory, leaving 1,023 bytes for local variables. Maximum is 2,048 bytes.

4 comments:

  1. Hi!

    Delighted to find someone using my EtherSia library! So glad that it is working for you.

    Until now I wasn't very sure if anyone else had tried it, or if it actually worked for anyone other than me.

    Let me know if anything can be improved.


    nick.

    ReplyDelete
  2. Honestly, I *love* EtherSia! You tested my hardware combination already, Arduino Nano with Nano Shield; I was happy to see the chart of what has been tested and what worked. I feel the two best features of EtherSia are:

    1: that it just works. I got very frustrated trying other libraries. I've written software in C to control usual hardware, and I was surprised to have so much trouble with Arduino. Your example code was all the boost I needed to get it to do what I wanted!

    and 2: the documentation. I had a very brief moment of wondering where my IPv4 address was (I'm usually dual-stacked), but the documentation reminded me that this is single stack. Then I was asked if I could put it in a VLAN that only supports static IPv6, and a quick scan let me know that SLAAC (yay, simple!) and static are supported, but DHCPv6 is not. I've run DHCPv6 before, and I'm sure your code is much simpler and much smaller without it. I am comfortable with the choices of IPv6-only with only SLAAC or static, and all the more so because I didn't have to figure that out the frustrating way.

    If I run across any oddities, I'll submit them to you on GitHub.

    Thank you, thank you!

    ReplyDelete
  3. Delighted it is working for you :)

    ReplyDelete