Here Comes the Sun: A Solar Panel Monitoring System Built With OutSystems and an Android Phone

Ricardo Ferreira
Nov 13, 2018 · 5 min read
Image for post
Image for post

I am a big fan of eco-friendly stuff and activities. I bike to work, I have a green garden on my rooftop, and I also have a 250-watt solar panel. This post is about how I built a crazy monitoring system for it with an old Android phone and an OutSystems app!

Image for post
Image for post
I promise to explain everything.

250-watt is not a big deal, but it is enough to handle most of my power needs during the day — a sunny day means that I get the refrigerator, the stereo, and the laptop running for free since I don’t have to buy power from the electrical company. All thanks to the panel and the grid-tie inverter that connects to a standard wall outlet. Because of that connection, I bought a power consumption meter to measure the production.

Image for post
Image for post
197 watts of production!

How can I build a monitoring system out of this? I thought of:

  • A phone taking pictures of the display of the meter every minute or so
  • The phone somehow recognizing what number was in the picture
  • The phone sending that number to a monitoring app in the cloud
  • A cool monitoring app for me to monitor production
  • Fun and profit (mostly fun, because I get to build everything)

So, this adventure started when my niece abandoned her old Android phone. The next step was figuring out how the phone would recognize the digits after taking a picture. I could have looked for an optical character recognition (OCR) library to do the work, but instead, I did it the fun way.

Image for post
Image for post
Yes, that’s red duct tape.

I put red duct tape on the edges of the display, lining it up with the digits so that it would be easier to spot where the digits are — with a very simple image processing routine running in the phone.

Image for post
Image for post
The meter with the duct tape on it.
Image for post
Image for post
This is what the phone captures. Duct tape helps the OCR.

So, based on this setup, I implemented a basic image processing algorithm and some RGB to luminance conversions. After a few tries to get it up and running, it began accurately reading the number that was on the display.

Of course, for this to work, the phone needed to be motionless and in front of the meter. Here’s how I addressed that challenge.

Image for post
Image for post
Here’s the phone “floating” in front of the meter.
Image for post
Image for post
OMG, this looks like a bomb!

So about the “bomb like” setup around the phone: on the top right is a charger that is controlled by a timer, which turns it on for just 30 minutes every day. Below is a Powerline WiFi adapter, controlled by another timer that sets it on only during a few hours of the day. The piece of wood was a leftover from another project; I used 2 Japanese sticks, zip ties, plus a few metal and plastic brackets to hold the phone. For the curious, the handwritten number on the wood is the wireless adapter key.

Now that I had the phone positioned, I built a native Android App. It uses an AlarmManager to wake up the phone every 2 minutes, take a picture with flash and macro, do the “duct tape” OCR, save the results in the SD card, and if there’s network available, send them to a REST API. Solar panels only work with sunlight, so I used this library to calculate sunrise and sunset in my location to make the monitoring work during daylight time.

Here’s what the phone keeps doing during the day:

The boring life of this phone: Wake up, take picture, duct tape OCR, save and send results, go back to sleep…

As for the monitoring app, I created my own using OutSystems. OutSystems is the low-code platform for building web and mobile apps; you should try it.

Image for post
Image for post
The monitoring app showing a good sunny summer day.

The app exposes a REST API to which the phone sends the readings. These readings are stored in a database, to be displayed in a front-end web responsive app. This also features an integration with OpenWeatherMap API to plot a chart with temperatures in my area. It is known that solar panel output decreases with heat, and with this integration I can visually confirm that.

Image for post
Image for post
A winter day, with clouds, rain, sun, etc.

On top of this, I added functionality that compares multiple days.

Image for post
Image for post
The dashboard also enables me to compare multiple days — here’s a summer day (red) vs. an autumn day (blue).

I live in the northern hemisphere, and I oriented the solar panel south, but unfortunately, I had to orient it a bit to the west. That explains why, in the chart, there is not much difference in the morning, as opposed to the afternoon, where we can clearly see that the daylight time in August is longer than in October.

Could I do this another way? Sure, I could have an Arduino doing all work. I could use other kinds of technology, but that would not have been as fun and rewarding as this was.

Resources:

The ideas shared in this post resulted partially from the research project RADicalize, which was supported by the EU and PT2020.

OutSystems Engineering

Stories from OutSystems Engineering.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store