Skip to content

Remote Units implementation, the software

This post is part of the Temperature monitoring project.

The central node code is spread into several modules:

  • The main module is in charge of driving other modules initialization and synchronizing activity, such collecting data received over local RF sensors and preparing messages to be sent to central server over Internet, manage sending logic, error detection and signaling.
  • The Oregon sensors management module, which is in charge of receiving and decoding RF frames from Oregon sensors (only the “Elements” protocol).
  • The networking module in charge of all Ethernet exchanges: HTTP POST to central server, embedded WEB server management, DNS lookup. The code that manages settings persistence into EEPROM is also here (for historical reasons, as it may have been placed into the misc module). See screen shots of local management WEB pages in previous post to get an idea of the embedded WEB server.
  • The Jeenodes local temperature sensors module in charge of receiving and decoding RF frames from other Jeenodes sensors local to the same site. The RF12 library was not used at its full capability. As the need here is only being able to receive from 3 different nodes, they is some hardcoded settings such as netGroup & nodeID.
  • The DS1820 module in charge of managing the DS1820 temperature sensor locally attached to this central node.

One of the conclusions of this development: the ATMega 328 limits were bordered, especially on RAM resource. There is a fairly large buffer for Ethernet frame, but it was mandatory to not reduce it as HTTP frames sent by browsers may be a little bit long, because they add sometime a lot of headers. I noticed that particularly on POST requests using a network analyzer.

So, being tight in memory, two main actions were taken:

  • Having as few as possible “standard” constant strings (I mean without using PSTR macro), because they are copied into RAM upon startup.
  • As said before, central Internet server is Pachube for the first try. As Pachube API URL and KEY are long strings, I chose not to store them into RAM, but use them directly from EEPROM. That implied to patch the Arduino Ethernet library because functions inside are not prepared to use EEPROM address space, only RAM or FLASH.

May be it would be worth having a few words on TCP & DNS settings.

When starting using Ethernet Arduino library, I found a bug into the DNS request logic. By the way, I had to use a network analyzer for tracking the problem, and had to buy an old HUB in order to be able to see the Jeenode Ethernet frames with a PC. Otherwise, with Ethernet Switches everybody has now, it’s highly more complex to sniff frames.

The patched Ethernet Arduino library available below for download include the fix. For information, the maintainer of this lib is noticed and correction will be officially available in the future. My fix is not very neat, but I wanted to go ahead without investing too much time on that.

Now, coming to TCP/IP settings.

It seems that the usage of a netmask is not implemented into the arduino Ethernet library (at list the one that comes with ENC28J60), and that TCP sending always goes through the local gateway… (to be confirmed, not well documented yet). But in that case it was OK, we have to send to internet, not to local network.

So taking this into account, the parameters setting interface does not provide a netmask setting, and other IP settings are simplified (see more in code comments):

  • The beginning of all local addresses is hardcoded as 192.168.
  • We can change A, B & G individually in the following:
    • Central node local IP is 192.168.A.B
    • Gateway is 192.168.A.G

Another consideration on DNS: the main purpose of the central node being to send HTTP requests to a central server on internet, we can set a DNS name for the server address. But to enable tests in which we want to send to a host not being declared in DNS, the interface provide the capability to set an IP address for the server, which, if specified will inhibit any DNS request and will be used as is.

Here is the code for the central node (Arduino IDE Sketch).

And here is the patched Ethernet library.

Next post will detail local “home made” temp sensors based on Arduino Jeenode and Dallas DS1820 sensors.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *