- 12/22/16 - Awaiting board arrival.
- 1/26/17 - AT&T IoT Starter Kit arrived!
- 1/27/17 - Ran quickstart code uploading sensor data to AT&T M2X.
- 3/28/17 - FRDM-K64F board stopped accepting / running any code.
- 3/29/17 - Gave a shot at porting mbed driver code for WNC M14A2A GSM LTE shield over to Arduino as a library, failed.
- 3/30/17 - Still unable to load code onto FRDM board, rest of project more or less complete. [UPDATE @ 20:40 (EST): Managed to solve the mounting problem! Adding the solution to this writeup.]
- 4/2/17 - Ran the board in Austin, TX. (Hence the huge power generation compared to the days in NYC.)
With the upfront costs of solar panels decreasing and mankind's ecological conscience growing ever more aware of the consequences of relying on non-renewable sources of energy, solar energy has become increasingly popular. Private homeowners and businesses alike stand to benefit from installing solar panels on their rooftops; the financial benefits eventually pay for the cost of the panels and the decreased reliance on environmentally-harmful electricity generation helps preserve the world that we all live in.
That being said, getting started in solar power still isn't "cheap," and it is perfectly understandable to be intimidated by the price tag associated with making the plunge. Without knowing just how long it will take for the investment to pay for itself there's no easy way to draft up a cost-benefit comparison. It's essentially a leap of faith.
But what if we could minimize that uncertainty?
Using the AT&T IoT Starter Kit, a solar panel, and some additional hardware for the implementation (waterproof housing, backup battery, charging circuit, etc.) it is possible to build a small and inconspicuous device to test the feasibility of getting a return on one's investment in solar power. We will create a small wireless device that sends occasional data packets to our IoT platform, which can then be used to estimate a particular location's solar power generation potential.
As a minimal proof-of-concept, we are going to pair the IoT Starter Kit with a solar panel and mount it in view of the sun. Because the same solar panel will be powering the microcontroller, our implementation will be entirely wireless. During the day we will occasionally gather data on the power output of the solar panel and then upload this from our microcontroller to our IoT dashboard. At night, we will allow the board to power down due to the lack of sunlight as we expect to have no meaningful data during nighttime anyway.
The data collected over time will give us information such as the average hours of useful daylight that a permanent solar installation would be able to take advantage of, and the efficiency of a solar implementation in that precise location. (The latter being useful for determining the best possible spots for installing panels.)Design
Because our setup is designed to be used in areas where the feasibility of going solar isn't clear, we have to be prepared to be working with the bare minimum amount of power that the IoT Starter Kit requires. Therefore anything above-and-beyond the board itself needs to be kept out of the equation in order to ensure we have enough power to send data to PubNub. Power splitters, multimeters, etc. can't be used without increasing the size of the solar panel being used for the test.
At the same time we need to be able to take a measurement of just how much power is being generated. Luckily, our solar panel is factory-rated to generate 3-amps at max output, while the modem board itself requires 2.7-amps. For the sake of this project we'll therefore assume that the solar panel is at full capacity whenever we receive a data packet from the AT&T IoT Starter Kit.Hardware / BOM
- Allpower 15-watt 5-volt USB solar panel (3-amp output)
- AT&T IoT Starter Kit
- USB-to-Micro-USB cable
- USB Voltimeter (optional, for testing)
This tutorial expects a basic familiarity with the AT&T PubNub platform, which was designed to connect IoT devices to other services and applications, and IBM Bluemix, which hosts our Python Flask webserver and PubNub event listener. You will need accounts for both services before beginning. Both have free tiers allowing anyone to replicate this project on a non-commercial scale.
Having created a PubNub account, one needs to then create a new app from the main PubNub dashboard, along with a new keyset to go along with it. The Publish and Subscribe keys are what we're after... they'll allow our AT&T IoT Starter Kit to publish messages, and our Python app to listen for and capture them. Once you have them, you'll want to drop them into the FRDM-K64F program on lines 9 and 10 of the main.cpp file:
At this point you may as well give a name to your channel, though you can leave it as-is if you'd like. (Note: The code will actually compile and run as-is, but messages will be published to the demo channel which anyone else in the world can also post messages to.) You'll then need to import the entire mbed part of the project into the online mbed IDE in order to compile it unless you plan on compiling it locally with your own setup.
Having compiled the firmware you'll be presented with a .bin binary download. You'll transfer this to the FRDM-K64F board in just the same was as the hello_world example in the board's quickstart guide. If your board isn't mounting correctly or accepting code, then you may need to run the fix described at the end of this project writeup.
With that complete you'll now want to deploy the webserver to Bluemix. First, on your local machine, copy the creds.json.example file and rename it creds.json. Then in your favorite editor drop in the PubNub keys that you acquired earlier. Now you're ready to deploy! Modify all instances of the string "solar-viability-tester" in these three files (bluemix-deploy-solar-viability-tester.sh, manifest.yml, and setup.py) to whatever you'd like as a subdomain, and then you'll be ready to deploy to Bluemix.
If you've never deployed an app to Bluemix before you'll first need to install the command-line tools. It just so happens that there's a handy guide right here that tells you how to do exactly that. Once you've got the tools installed, just follow these instructions from a terminal opened to the root directory of the project repo:
cf api https://api.ng.bluemix.net cf login -u <email_login> -o <email_login> cf target -s dev cf <your_subdomain>
And that's it! Now go attach your AT&T IoT Starter Kit to a solar panel and occasionally refresh the website you created (<your_domain>.mybluemix.net) to see how much power you've generated each day.Code
All of the project code for both the AT&T IoT Starter Kit and the Python Flask server for IBM Bluemix can be found in the linked GitHub repo.(Live) Results
My solar viability tester resides in the window of one of my apartment windows. Assuming it receives enough sunlight- and that I haven't forgotten to open up the window blinds- it publishes a message to PubNub, which is then caught by my listener running atop a Python Flask webserver on Bluemix. You can view live results here:Fix for FRDM Board Not Mounting / Accepting Code
My board decided to stop mounting except for in bootloader mode, rendering it impossible to load any new code onto it no matter what platform of computer I was using to try and do so. After a lot of web searching I stumbled across a solution for the FRDM-KL25Z board that turned out to work with this FRDM-K64F board. Seems like it mounts just fine again on all platforms once flashed with the proper firmware.
- On a Windows machine running something newer than Windows 7 you'll need to activate the feature described here: https://goo.gl/UsGlJw (TL;DR: Open Local Group Policy Editor and activate "Computer Configuration --> Administrative Templates --> Windows Components --> Search --> Do not allow locations on removable drives to be added to libraries")
- Download this firmware: https://goo.gl/ZfwUDd (which can also be downloaded straight from the board's corresponding firmware update page on mbed [https://goo.gl/mctqFf] by clicking the dotted link next to "rev 0226"
- Connect the board in bootloader mode
- Drag and drop the firmware file ("0226_k20dx128_k64f_0x5000.bin") onto the mounted "BOOTLOADER" drive
- Remove power from the FRDM board, reconnect via USB and it should mount properly as "MBED"