A solar-powered ESP8266 WiFi module joins the IoT

Wiring

An FTDI cable is plugged in to the end of the Adafruit Huzzah ESP8266. Be careful when plugging in the FTDI cable: Align GND with GND on the ESP8266 board as in the picture in Figure 3. The Voltaics Systems solar panel comes with a 1.3mm barrel plug. If you don't want to cut it off and solder a JST2 plug onto the connector, you can buy these two adaptors: 1.33mm plug to 2.1mm barrel plug adaptor [8] and a 2.1mm barrel plug to a JST2 adaptor [9]. Refer to Table 2 and Figures 4 and 5 for more details on the wiring scheme.

Table 2

Wiring List

From

To

Description

Huzzah ESP8266 board (Figure 4)

ESP8266/GND

SunAirPlus JP13-4, GND

Ground

ESP8266/3V

SunAirPlus JP13-3, 3V3

3.3V power SunAirPlus interface

ESP8266/Pin 4

SunAirPlus JP13-2, SDA

SDA for I2C SunAirPlus interface

ESP8266/Pin 5

SunAirPlus JP13-1, SCL

SCL for I2C SunAirPlus interface

ESP8266/GND

SunAirPlus JP22-1, GND

GND for ESP8266

ESP8266/V+

SunAirPlus JP23-1, VDD5

5V supply for ESP8266

SunAirPlus (Figure 5)

SunAirPlus/J5/Battery

JST2 plug on LiPo battery

SunAirPlus/J6/Solar

JST2 plug on solar panel

Figure 3: FTDI cable correctly plugged in to the ESP8266.
Figure 4: ESP8266 wiring. Top (left to right): pin 5, pin 4, 3V, GND; bottom (left to right): V+, GND. Also see Table 2.
Figure 5: SunAirPlus wiring. Left: J5 (top), J6 (bottom); center: JP23-1 (top), JP22-1 (bottom); right (top to bottom): JP13-1 through JP13-4. See Table 2.

Output

The results from the ESP8266 REST interface are formatted as a JSON string. The output in Listing 3 shows the response to entering http://192.168.1.129/RestDataString/ in the browser. The REST response was taken with the Load Power Switch (SW1) in the Off position. The current values look funny because the ESP8266 is being powered through the connected FTDI cable.

Listing 3

SunAirPlus Off, FTDI Cable Connected

{"RestDataString": "38160 | 4684697,4.08,4.08,0.00,3.53,3.53,0.00,4.98,4.98,-0.40 | \
  4685720,4.08,4.08,0.00,3.53,3.53,0.00,4.98,4.98,-0.40", "id": "1", "name": "SolarPowerESP8266", "connected": true}

Each packet of data is delimited by a vertical bar (|). The first value (38160) is the current value of the free heap (RAM available) on the ESP8266. It's put there to help monitor memory leaks, which was of concern initially. However, the latest version of the Arduino IDE ESP8266 SDK is managing memory a lot better.

The next two sections are the data from SunAirPlus, formatted as:

  • timeStamp (milliseconds since ESP8266 boot)
  • LIPO_Battery Bus Voltage (V)
  • LIPO_Battery Load Voltage (V)
  • LIPO_Battery Current (mA)
  • Solar Cell Bus Voltage (V)
  • Solar Cell Load Voltage (V)
  • Solar Cell Current (mA)
  • Output Bus Bus Voltage (V)
  • Output Bus Load Voltage (V)
  • Output Bus Current (mA)

The important values are those that say Load Voltage and Current. The three Output Bus lines refer to the current going into the ESP8266. The values in Listing 3 show 4.08V for the LiPo battery, 3.53V for the solar cell, and 4.98V for the voltage supply to the ESP8266.

Listing 4

SunAirPlus On, FTDI Cable Connected

{"RestDataString": "37968 | 4707212,4.07,4.08,40.00,3.53,3.53,0.00,5.00,5.00,29.60 | \
  4708235,4.07,4.08,42.80,3.53,3.53,0.00,5.00,5.00,29.60 | 4709259,4.07,4.08,42.00,3.53,3.53,0.00,5.00,5.00,29.60 | \
  4710283,4.07,4.08,44.80,3.53,3.53,0.00,5.00,5.00,29.60 | 4701072,4.08,4.08,00.00,3.53,3.53,0.00,4.97,4.97,00.40 | \
  4702095,4.07,4.08,38.00,3.52,3.52,0.00,4.99,4.99,28.40 | 4703118,4.07,4.08,42.80,3.53,3.53,0.00,5.00,5.00,29.60 | \
  4704141,4.07,4.08,40.00,3.53,3.53,0.00,5.00,5.00,30.00 | 4705165,4.07,4.08,42.40,3.53,3.53,0.00,5.00,5.00,29.20 | \
  4706188,4.07,4.08,42.00,3.53,3.53,0.00,5.00,5.00,29.60", "id": "1", "name": "SolarPowerESP8266", "connected": true}

In the output in Listing 4, the SunAirPlus Switch is in the On position and the FTDI cable is connected (Figure 6). Note that only part of the power for the ESP8266 is being supplied by SunAirPlus (29ma).

Figure 6: ESP8266 with FTDI cable.

In Listing 5, the SunAirPlus is switched On, the FTDI cable is unplugged, and a strong light source is directed onto the solar panel (Figure 7). Now the solar panel is generating power. The output shows 66ma from the battery and 43ma from the solar panels, with 82ma supplied to the ESP8266. Perfect!

Listing 5

SunAirPlus On, FTDI Cable Disconnected

{"variables": {"RestTimeStamp": 73667, "RestDataString": "38848 | 64972,4.10,4.10,66.40,4.66,4.65,43.20,4.98,4.99,82.40 | \
  65995,4.10,4.10,62.80,4.66,4.65,42.40,4.98,4.99,91.20 | 67019,4.10,4.10,67.20,4.66,4.65,42.40,4.98,4.99,86.00 | \
  68042,4.10,4.10,69.60,4.66,4.65,42.80,4.98,4.99,86.00 | 69065,4.10,4.10,63.60,4.66,4.65,43.20,4.98,4.99,97.60 | \
  70089,4.10,4.10,63.20,4.66,4.65,43.20,4.98,4.99,82.80 | 71112,4.10,4.10,58.00,4.66,4.65,42.80,4.98,4.99,84.40 | \
  72136,4.10,4.10,64.00,4.66,4.65,42.40,4.98,4.99,82.00 | 73159,4.10,4.10,64.40,4.66,4.65,43.20,4.98,4.99,82.40 | \
  63948,4.10,4.10,64.40,4.66,4.65,42.80,4.98,4.99,82.40"}, "id": "1", "name": "SolarPowerESP8266", "connected": true}
Figure 7: Project on solar power.

For the final test, I turned the bright light off, so the solar panels are not generating power (sitting at 3.6V in ambient light). In Listing 6, you can see that the battery supplies 116ma, with 90ma going to the ESP8266. The system is now operating on battery power!

Listing 6

Operating on Battery Power

{"RestDataString": "39328 | 566634,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,90.40 | \
  567657,4.08,4.09,116.00,3.63,3.63,0.00,4.98,4.99,90.40 | 568683,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,88.80 | \
  569706,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,103.60 | 570730,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,96.00 | \
  571753,4.08,4.09,120.00,3.63,3.63,0.00,4.98,4.99,93.20 | 572777,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,94.40 | \
  573801,4.08,4.09,108.00,3.63,3.63,0.00,4.98,4.99,90.40 | 564586,4.08,4.09,131.20,3.60,3.60,0.00,4.98,4.99,90.40 | \
  565609,4.08,4.09,107.60,3.63,3.63,0.00,4.98,4.99,108.40", "id": "1", "name": "SolarPowerESP8266", "connected": true}

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content