I have been tinkering for some time now on creating a pure hardware, highly reliable emoncms base-station solution that isn’t pain in the rear to set-up. The current approach is to use a NanodeRF, but that requires re-programming the unit with the user specific configuration, and that can be non-trivial for many. I decided that for the end user it would be much easier to have all necessary configuration parameters on an .ini file saved to a SD card. Upon powering up the base-station, the configuration from SD card (if available) will be fetched and saved to EEPROM. I use my micro Internet of Things gateway with a RFM12B+SD card shield for this project, the code can easily be adapted for NanodeRF too.
The microSD card can be inserted in a SD card adapter so that its contents can be browsed and files edited on any computer. I use my Android phone instead, when I connect it to my computer with a USB cable, it asks me whether I wish to mount the SD card as a drive, so I chose that option.
The .ini file is fairly easy to understand:
# uIoT gateway .ini file [network] mac = 42:31:42:21:30:31 # use DHCP # (0 means do not use dhcp, 1 means use dhcp) usedhcp = 0 gateway = 192.168.1.1 ip = 192.168.1.88 dns = 22.214.171.124 #hisip contains website resolved website IP address #use when no DNS is available hisip = 126.96.36.199 #use the resolved IP address rather than looking it up via DNS? # (0 means do not use, 1 means use ) usehisip = 0 [rfm] #band 8=868Mhz, 4=433Mhz, 9=915Mhz band=8 nodeid=20 group=210 [emoncms] api = *** API KEY HERE *** website = emoncms.org basedir =
There are three major sections: Network, Radio and emoncms parameters. Pretty self-explanatory I guess.
The code adds on to the multinode sketch, however it was quite a challenge to get this working as per the limited 2K RAM the ATMega328 has. The TCP/IP stack of the ENC28J60, the RFM12B radio module and the SD card code all require that precious resource. I started off by using Steve Marple’s .INI file library, but quickly realized that it won’t work with all the RAM hungry components I have. I then decided to use the Petit FAT fs Arduino wrapper that I used earlier with my early ATTIny84 projects and made my own .INI file reader on top of it. The Petit FAT fs had a nasty bug that made it hang on SD card not ready condition, spend couple hours scratching my head until I found what was causing it.
Anyway, it is working nicely now, upon power up, the code will see if it can find a file named “uiot.ini” in the root of the SD card. If it finds it, it scans thru it for configuration key/values and compares them against those saved in EEPROM. If changes are found, the new settings are saved. The SD card is no longer needed after that as settings are preserved in EEPROM.
I think this makes it quite easy to get started, you just punch in the parameters, insert the SD card into the micro IoT gateway and start it. Hopefully this project will make it easier for the non-experienced to join the exciting OpenEnergyMonitor community.
Of course, setting the base-station is half the job, remote wireless sensor nodes must also be easy to configure without need of re-programming. Funky v2 has USB connectivity that allows them to appear as a virtual COM port when plugged in to the USB port of a computer and can be configured using a terminal program like PuTTY, minicom. I have a serial configuration menu run for 30 seconds upon power up, that allows setting up the parameters needed for the node, below is a screenshot of the DS18B20 temperature sensor sketch configuration menu:
My next step is to adapt the 2boots bootloader for 8Mhz/38400baud so that new unit firmware could be distributed as a pre-compiled .HEX file that when saved on the SD card will initiate a firmware update. Easy for those that don’t want to get hands dirty with re-programming the firmware using the conventional methods i.e. using FTDI or ISP programmer. If time permits, I may extend support to other providers like Xively, SEN.SE and so forth, but I encourage community effort in that direction.