Open Kontrol Gateway

From OpenEnergyMonitor Wiki
Jump to: navigation, search

Open Kontrol Gateway

The Open Kontrol Gateway (OKG) is a very flexible web-connected base station based on the ATmega328 which is totally Arduino IDE compatible (Arduino UNO bootloader). The OKG has been designed and manufactured by our friend Miles who runs Ciseco Plc.

The OKG PCB supports multiple wireless options such as RFM12B, XBEE, XRF, RN-XV Wifi. There is also PCB footprints for expansions like a RTC, SD card and SRAM. The OKG supports both the ENC28J60 and Wiznet Ethernet chips. See our blog post on the OGK for background info and a brief comparison of the two Ethernet chips.

OKG kits with either the Wiznet or ENC Ethernet chips have been added to the OpenEnergyMonitor shop.

There is lots of documentation for the OKG on the Ciseco product support section of the OpenMicros website. A pdf of the OKG schematic can be downloaded here.

Using the OKG as an OpenEnergyMonitor emonBase

With RFM12B wireless to receive data from emonTx, emonGLCD and post to emoncms

OKG PCB populated for use as emonBase - click to enlarge OKG Cased


Using OKG with ENC28J60

Assembled OKG ENC28J60 Ethernet board

Using the OKG with the ENC28J60 Ethernet board and RFM12B makes the OKG (almost!) hardware identical to the NanodeRF. The only differences is that different SPI SS/CS pins are used on the OKG for the both ENC28J50 and RFM12B. This is a bit of a pain but workable. Follow these steps:

  1. Assemble the OKG base board following the Ciseco instructions on the OpenMicros - assembling the OKG. For emonBase operation the position of the jumpers don't matter. When you're done the board should look like the photo above.
  2. Assemble the Wiznet Ethernet board following the Ciseco instructions on the OpenMicro website OpenMicros - assembling the OKG ENC28J60 board
  3. To the NanodeRF emonBase examples with the OKG the line
    if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    needs to be changed to
    if (ether.begin(sizeof Ethernet::buffer, mymac ,10) == 0)
    this is because on the OKG the ENC28J60 SPI SS connection is connected to Dig10 on the ATmega 328 as opposed to Dig8 which is used on the NanodeRF (library default). In the latest emonBase NanodeRF examples this line has been ready inserted commented out. Just un-comment it and comment out the original line.
  4. A change is also required to get the RFM12B on the OKG to work since the RFM12B SPI CS is connected to Dig9 instead of Dig10 (as is the case with other modules), we have made a forked JeeLib library to make implementing this change easy.
    1. Download the OpenEnergyMonitor modified JeeLib library and install in your Arduino folder. Make sure to delete any other JeeLib library folder you currently have in your Arduino library folder.
    2. Download the latest NanodeRF emonBase examples from the OpenEnergyMonitor GitHub. There are currently 3 examples:
      1. NanodeRF_multinode: flexible firmware for posting data up to emoncms, it relays data from up to the 30 nodes that the rfm12 library implementation can handle up to emoncms.
      2. NanodeRF_Power_RTCrelay_GLCDtemp: Build specifically for use with one emontx and one emonglcd with standard packet structure.
      3. NanodeRF_Cosm Firmware for posting data up to Cosm.
    3. Un-comment the line
      rf12_set_cs(9);
      this modified JeeLib library can be used with the emonTx, emonGLCD, Jeenode and NanodeRF just use
      rf12_set_cs(10);
  5. If you would like the OKG front LED indicator to work you will need to change redLED definition to const int redLED = 6; near the beginning of the sketch.

Using OKG with Wiznet W5200

Assembled OKG ENC28J60 Ethernet board

The Wiznet W5200 is an advanced Ethernet chip which has an integrated TCP/IP stack. It's almost identical to the Wiznet W5100 which is used in official Arduino Ethernet boards. The Wiznet W5200 works with the standard Arduino Ethernet library with a small change. To use the OKG with the Wiznet W5200 as an emonBase to receive data from an emonTx via RFM12B and post to emoncms follow these steps:

  1. Assemble the OKG base board following the Ciseco instructions on the OpenMicros - assembling the OKG. For emonBase operation the position of the jumpers doesn't matter. When you're done, the board should look like this:
  2. Assemble the Wiznet Ethernet board following the Ciseco instructions on the OpenMicro website OpenMicros - assembling the OKG Wiznet board
  3. Implement the Wiznet reset line fix
  4. Replace the Arduino Ethernet library (in Arduino IDE libraries folder) with an updated library that supports the Wiznet W5200 and has modifications to enable RFM12B compatibility download from OpenEnergyMonitor GitHub
  5. Download the JeeLabs JeeLib library and install in your Arduino folder. Make sure you delete or move any other JeeLib / Ethernet library folders currently in your Arduino library folder (renaming is not sufficient).
  6. Download the OKG Wiznet to emoncms examples. Be sure you set the RFM12B network and frequency, emoncms server and emoncms read-only API key. There are currently two examples:
    1. OKG_Wiz5200_RFM12B_emoncms: A fixed data structure example for use with one emonTx and one emonGLCD.
    2. OKG_Wiz5200_RFM12B_emoncms_multinode: flexible example for posting data to emoncms, it relays data to emoncms from as many as 30 nodes. (rfm12 library maximum).

Wiznet Reset Fix

On the OKG with Wiznet, The reset line is connected to the Atmega328 reset line. On power-up the Wiznet module failed to initialise properly, probably due to a race condition between the Atmega328 and the Wiznet chip. This resulted in the Wiznet module hanging.

The fix is to reset the Wiznet after the Atmega is booted and stable. To do this, we have to separate the Wiznet reset from the Atmega reset. To do this cut off the Wiznet reset header pin as shown:

OKG Wiznet Resetfix1

Solder a wire from the reset pad on the OKG Wiznet adapter PCB, to the fourth connection down on the left side of the left Xbee header. This connects the Wiznet reset to Digital 7:

OKG Wiznet Resetfix2 OKG Wiznet Resetfix3

The latest OKG code examples include a routine to reset the Wiznet via software.

Using OKG with RN-XV Wifi Module

RN-XV

  1. Assemble the Wiznet Ethernet board following the Ciseco instructions on the OpenMicro website OpenMicros - assembling the OKG Wiznet board
  2. Make sure the red jumpers are connected as photo above. The two jumpers on the right hand side are important. They connect the RH Xbee Socket to Digital 5 and 6 (Rx & Tx software serial)
  3. Insert XN-XV Wifi module into right hand Xbee Socket
  4. Add an extra 100nF capacitor to the reset line - this fixes the problem of the W5200 stopping working when the Arduino serial window is opened when the FTDI cable is connected (instructions below)
  5. Download the JeeLabs JeeLib library and install in your Arduino folder. Make sure to delete any other JeeLib library folder you currently have in your Arduino library folder.
  6. Download the RN-XV Wifi module Arduino library and install in your Arduino librarys folder.
  7. Download the OKG RN-XV wifi to emoncms examples. Make sure to set the RFM12B network and frequency, emoncms server and emoncms read-only API key
  8. Enter wifi SSID and WPA password, leave password blank to connect to open wifi network



Using OKG with GRPS - SM5100B-D GSM modem

Thanks to Eamonn O'Brien (EnergyRnR) for this tutorial - currently a work in progress


Reset Capacitor Fix OLD FIX - not required if Wiznet reset fix is implemented (see above)

The fix is only necessary when using the Wiznet W5200 on the OKG, see step 3 above. There is a problem on OKG PCB V1.0 that the reset capacitor C1 does not provide a strong enough reset this results in the W5200 getting stuck in a reset loop when the FTDI cable is connected and the serial window opened in Arduino IDE. This can be fixed by inserting an extra 100nF (0.1uF) capacitor in line with the reset connection from the FTDI cable. To do this, break the track coming from the reset line on the rear of the PCB (see photo below) with a sharp knife then solder a 100nF capacitor between the reset pin and the top of the three solder pads on the bottom right hand side of the board. An extra 100nF capacitor has been included in all OKG kits from the OpenEnergyMonitor shop.

OKG Reset Capacitor Fix


Please feel free to improve, update and correct this wiki at will. For discussion and support please post on the OpenEnergyMonitor forums