Introduction

This project shows how a GreenPAK design can be tested, debugged, and controlled using a website. GreenPAK ICs come with a register control feature. In this way, GreenPAK registers can be controlled on-the-fly. A GreenPAK and Lolin NodeMcu are used in this project. In addition, some web technologies have been used to create a website. However, this project will not include client-side codes. You can look at this link if you want to review it. This project consists of several sections. These are:

  • Server Side
  • Usage of Website
  • Example: Sharp Sensor Node
  • Settings / Connections

Below we described steps needed to understand how the project was programmed. However, if you just want to get the result of programming, download GreenPAK software to view the already completed GreenPAK Design File. Plug the GreenPAK Development Kit to your computer and hit the program to design the device.

1. Server Side

The server-side code is written with an ESP8266 / Arduino core. In this way, you can use the ESP8266 development boards like the ESPDuino, SparkFun ESP8266 Thing, ESPresso Lite, WeMos and even the Generic ESP8266 Board as a server. In this project, the Lolin NodeMcu will be used, so the expressions will be on the Lolin NodeMcu.

The Lolin NodeMcu was used to communicate with the GreenPAK registers and host the website. The Lolin NodeMcu and GreenPAK are communicated to each other via I2C protocol. Thanks to GreenPAK, device configurations can be changed on-the-fly. With this feature, GreenPAK registers can be controlled via the website.

Operations done by the server side are:

  • Hosting a website and routing incoming request
  • Checking destination I2C address
  • Writing to the GreenPAK registers
  • Reading from the GreenPAK registers

1.1. Hosting a Website and Routing Incoming Request

The HTML and jQuery codes, which were written for the website, take up space in the Lolin NodeMcu's memory. Therefore, the code written for the website is hosted on the remote server. Only HTML, head and body tags are generated as shown in Figure 1. The contents of these tags were pulled from the remote server using jQuery.


Figure 1: Server-Side Html Codes

Each incoming request was directed to the relevant functions.


Figure 2: Routing

1.2. Checking Destination I2C Address

GreenPAKs have 16 selectable I2C addresses. These addresses can be determined using the control code register. The last 3 bits of register are fixed (as 0). The first 4 bits can be changed. The values that the control code register can receive are shown in Figure 3.


Figure 3: Control Code Values

According to these values, the I2C addresses of GreenPAK are shown in Table 1.

Table 1: I2C Addresses according to Control Code

Control Code Padding span class="superscript">2C Address
0000 000 0
0001 000 8
0010 000 16
0011 000 24
0100 000 32
0101 000 40
0110 000 48
0111 000 56
1000 000 64
1001 000 72
1010 000 80
1011 000 88
1100 000 96
1101 000 104
1110 000 112
1111 000 120

The controlGPAK function controls the I2C address that is sent.

It returns 0 if there is a device capable of I2C communication at this address. If there is no device at this address or there is a problem with the communication, it returns a number other than 0. It does this using the wire library.


Figure 4: ControlGPAK Function

The checkDevice function checks all the addresses one by one as shown in Table 1. If there is a device at the target, it adds the address of the device to the response message. Finally, it notifies the suitable devices to the user.


Figure 5: CheckDevice function

NOTE: The checkDevice function only checks whether a suitable device is available at the destination addresses. This device may not be a GreenPAK.

1.3. Writing to the GreenPAK Registers

A GreenPAK can be controlled by changing its registers. The task of each register is different. For the addresses and tasks...

Read more »