Project Curacao2 – Part 8: Solar Power Management / Raspberry Pi

The Project Curacao2 Family

Project Curacao2 – Part 8: Solar Power Management / Raspberry PiProject Curacao2

In the posting, we will be discussing the power management system in Project Curacao2.   But first, we will give a current status of the project.

Status

Two Weeks until deployment time!   We have had the box out in the rain for the past week and we have identified a few issues that need to be addressed:

  1. According to the emails that we are getting from the box, we don’t seem to be shutting down correctly in a low voltage condition.   We are looking in the logs to figure out what is happening. (Fixed:  Uncommented the line in the code to halt the Raspberry Pi)
  2. We moved one of the solar panels to the left side of the box to catch the late afternoon sun.   We are going to look at a profile of a day, if we ever get some sun around here. If we don’t get some in the next day or two, we will bring the box in and use a really bright light to verify each of the panels is working.
  3. It is not clear if our WatchDog timer is wired up correctly.   We are bringing the box in and running a test to make sure that it is working correctly.  (Fixed:  Everything was wired up and working correctly.  Data was confusion because of #1 above).

System Status

  1. Camera system functioning correctly.
  2. Power system functioning correctly.
  3. Sensor subsystems functioning correctly.
  4. Lightning system working.   We used simulated lightning to test it.  Waiting for a thunderstorm predicted later tonight.
  5. Low Voltage recovery working.   Low Voltage shutdown seems to be flaky.
  6. LoRa reception and the two external transmitters are working correctly.   As is the radio hang recovery system.
Solar Power
New Solar Panels on Top of the original Project Curacao Box – WeatherRack in Background

Project Curacao2 is a redesign and rebuild of the Project Curacao environmental monitoring system that was running down on the island nation of Curacao in 2014 and 2015.   It finally died after a loose wire in the solar panel assembly (not in the panels, but in the internal wiring) finally came completely loose.   We are now using a LoRa WXLink wireless transmitters for data collection.

Solar Power Management System

We are using three Grove PowerSaves, one Grove PowerDrive and one USB PowerControl to manage power requirements in the Project Curacao2 design.  The first thing to do was determine how much current could we save by shutting of device.  We measured these currents by shutting devices off one by one and looking at the total system current and subtracting that from the initial power on current.   Using the INA3221 onboard SunAirPlus, we measure 422mA as the starting power.  How to use these devices is explained in this tutorial.

Device Current Consumption in Project Curacao2
Device Comment

Current Consumed

Control Device Used

Grove Air Quality Sensor Samples taken once an hour, 2 minute warm up time

48mA

Grove PowerSave

LoRa WXLink and Arduino Still deciding on timing.  15 minute an hour?

75mA

Grove PowerSave

Grove OLED Display Only used when someone is looking at the unit, which is not often

25mA

Grove PowerSave

5V Ventilation Fan (also for Air Quality Sensor) Used when to box is really hot (above 100F) and when running Air Quality Sample

50mA

Grove PowerDrive

WiFi USB Dongle Turn on WiFi from 10 before the hour until 10 after the hour.  If someone is logged in, then don’t turn off

80mA

USB PowerControl

Total Possible Savings: All Devices Turned Off

280mA Savings

When the system powers up, all devices default to on.  The first thing the Project Curacao2 software does is shut off the power to the devices that it doesn’t need immediately (Air Quality Sensor, 5V Fan, OLED Display).   It leaves the LoRa WXLink system running as well as the WiFi USB Dongle.

Using these power saving devices allows us to cut 67% of the power consumption of Project Curacao (422mA down to 142mA), making our battery power last about twice as long more  (why the difference?   These devices do run some during each hour, cutting down the overall power saving).

All of the code below is located in ProjectCuracao2.py and powercontrol.py on the GitHub repository of ProjectCuracao2.

Grove Air Quality Sensor

This device uses about 50mA and requires 2 minutes to warm up before giving a good reading.    Since we are only planning to take Air Quality samples every hour, it spends most of its time off.   The code for shutting this device off and on looks like this:

 

# Air Quality Sensor On
	myPowerSaveAirQuality.setPowerSave(True)
	config.AirQuality_Power = True
   	pclogging.log(pclogging.INFO, __name__, "Power: AirQuality Turned: %s" % "ON")

and

# Air Quality Sensor Off
	myPowerSaveAirQuality.setPowerSave(False)
	config.AirQuality_Power = False
   	pclogging.log(pclogging.INFO, __name__, "Power: AirQuality Turned: %s" % "OFF")


This sensor is a fabulous inexpensive air quality sensor.   Check out our article on this sensor.

5V Fan

We have a small 5V Fan that serves two functions. First, when doing an air quality sample, we blow air over the sensor from the outside. Otherwise we would just be looking at the air inside the box. The device is not weatherproof, so it is inside the box. Secondly, if the air temperature is significantly higher inside the box than outside, we will blow air into the box.

The code for the 5V fan looks like this:

	# Fan On
	myPowerDriveFan.setPowerDrive(1, True)
	config.Fan_Drive_Power = True
   	pclogging.log(pclogging.INFO, __name__, "Power: Fan Turned: %s" % "ON")

and

	# Fan Off
	myPowerDriveFan.setPowerDrive(1, False)	
	config.Fan_Drive_Power = False
   	pclogging.log(pclogging.INFO, __name__, "Power: Fan Turned: %s" % "OFF")


LoRa WXLink and Arduino

The LoRa WXLink and Arduino takes a significant amount of current (75mA). We would like to turn this device on and off for two reasons. First, the LoRa receiver / Arduino combination can hang in rare situations and has to be powered off and on (POR – Power On Reset) to get it to receive new data. We do this in those cases and it works. Secondly, we would like to be able to turn off the LoRa system to save power and only turn it on maybe every hour for 15 minutes to pick up new samples from the remote sensors (on the close tower and the distant ridge tower).

The problem is that if you power down an Arduino while it is connected to an I2C bus, it hangs the I2C bus. It pulls down the SCL and SDA lines and therefore locks the I2C bus. This is no problem during a POR cycle for the LoRa (it clears the bus as it powers up), but we can’t shutdown the I2C bus for extended periods of time on Project Curacao2. So, at this point, we are forgoing the power saving of shutting down the LoRa system.

One fix for this problem is to disconnect the SDA/SCL lines by using a low capacitance solid state relay (we used our Quad Power Management Board to test – too high of a capacitance for an I2C bus) or a low capacitance latching relay (we used such a device in Project Curacao for a number of applications). An example of a 5V latching relay is here.   You would need to of these relays to switch both lines or find a DPDT relay to switch both at once.

You need to use a latching relay as a normal relay will consume way to much current when energized.   With only two weeks left, we made the decision not to implement this in the initial box.  When we retrofit the device next, we will add this.

def setLoRaPower(value):
	
	if (value == True):
		myLoRaSaveOLED.setPowerSave(True)
		config.LORA_Power = True
   		pclogging.log(pclogging.INFO, __name__, "Power: LoRa Turned: %s" % "ON") 

	if (value == False):
		config.LORA_Power = False
		myPowerSaveLoRa.setPowerSave(False)
   		pclogging.log(pclogging.INFO, __name__, "Power: LoRa Turned: %s" % "OFF") 

def resetWXLink():
	
	print "reset the LoRa reciever"	

	# LoRa Reciever Off	
	myPowerSaveLoRa.setPowerSave(False)
	config.LORA_Power = False
   	pclogging.log(pclogging.INFO, __name__, "Power: LoRa Turned: %s" % "OFF") 
	time.sleep(5.0)
	myPowerSaveLoRa.setPowerSave(True)
	config.LORA_Power = True
   	pclogging.log(pclogging.INFO, __name__, "Power: LoRa Turned: %s" % "ON") 

 

Grove OLED Display

The OLED display is only useful when someone is there to look at it, which will not happen very often when this device is deployed and mounted.   Because of this, we turn off the OLED display during the boot up process in Project Curacao2.

def setOLEDDisplayPower(value):
	
	if (value == True):
		myPowerSaveOLED.setPowerSave(True)
		config.OLED_Power = True
   		pclogging.log(pclogging.INFO, __name__, "Power: OLED Turned: %s" % "ON")

	if (value == False):
		config.OLED_Power = False
		myPowerSaveOLED.setPowerSave(False)
   		pclogging.log(pclogging.INFO, __name__, "Power: OLED Turned: %s" % "OFF")

 

WiFi USB Dongle

The WiFi USB Dongle consumes a lot of current (80mA).  In normal operation for ProjectCuracao, there is no need for an active WiFi link most of the time.   We implemented this “On/Off” switch for the WiFi dongle using a USB PowerControl device since there is no known way of shutting off all the power to a specific USB port on a Raspberry Pi.    The code for this is below:

 

def setWiFiOn(reason):

	# turn on USBPowerControl Controlling WiFi Dongle

	GPIO.output(USBPowerControl_Enable, True)
	GPIO.output(USBPowerControl_Control, True)
	config.WiFi_Power = True
   	pclogging.log(pclogging.INFO, __name__, "Power: %s WiFi Turned: %s" % (reason,"ON"))


def setWiFiOff(reason):

        f = open("/home/pi/SDL_Pi_ProjectCuracao2/WIFISHUTOFF","r")
        command = f.read()
        f.close()
	command = command.replace("\n", "")
	print "command='%s'"% command
        if (command == "False"): 
   		pclogging.log(pclogging.INFO, __name__, "Power: %s WiFi !: %s DISABLED" % (reason,"OFF"))
                # Nothing to do
                return 


	# turn off USBPowerControl Controlling WiFi Dongle

	GPIO.output(USBPowerControl_Enable, True)
	GPIO.output(USBPowerControl_Control, False)
	config.WiFi_Power = False
   	pclogging.log(pclogging.INFO, __name__, "Power: %s WiFi Turned: %s" % (reason,"OFF"))

Note the override to turning the WiFi dongle off. If you put a text “False” in the file /home/pi/SDL_Pi_ProjectCuracao2/WIFISHUTOFF, you disable the WiFi turn-off. This is useful when you are working on the code remotely.

Here is the apschedule code for implementing the top of the hour on and off.

# schedule WiFi On and Off
scheduler.add_job(powercontrol.setWiFiOn, 'cron',  minute=50, args=["Scheduled WiFi On"]) 
scheduler.add_job(powercontrol.setWiFiOff, 'cron',  minute=10, args=["Scheduled WiFi Off"]) 

The graph below shows the affect of switching the WiFi off and on (the green line).

Conclusion

Power management on Project Curacao2 is still important, even in the tropics with a lot of sun.   There are stretches of cloudy weather that will strain the solar power system.   We call this situation a “solar brownout”.    A significant amount of design work has been done on Project Curacao2 to allow the Raspberry Pi to gracefully shutdown and recover without a constant rebooting / shutdown cycle that will kill SDCards on the Raspberry Pi.   We will discuss this system design in a future part of this series.   It involves hysteresis, watchdog timers and USB PowerControls.

By using the above power saving techniques, we reduce  of the power consumption of Project Curacao2 by 49% (422mA down to 220mA), making our battery power last about 80% longer  (why the difference?   These devices do run some during each hour, cutting down the overall power saving).   Adding the latching relays would bring the power saving us to 67%.

2 Comments

    • Mathieu,

      Yes, we did do those things but did not mention them in the article. Thank you for pointing that out. We will add them for completeness.

      SDL

Comments are closed.