# How to build a solar panel table to keep your beer cold using the sun

By Anton Bengtsson (**ab225ug**)
Imagine you're sitting outside in the sun relaxing. You feel the urge for a cold beer but you don't want to get up from the chair and walk all the way to your fridge. This is a sticky situation. I've built the solution to this problem, a table that powers a 12 volt fridge - *with solarpower!*
A diy solar panel integrated into a table. The solarpanel charges a motorcycle battery and powers a cooling box. It has also got two USB ports for charging devices and a Pycom LoPy4 that measures the voltage, current and power the solar panel produces. It also measures the temperature inside the table on two different places and sends all this data to the cloud using WiFi.
Estimated time: ~ 70-100 hours. I spent at least 100 hours but if you get all the material in beforehand and follow this guide it should go quicker. If you got woodworking machines and knowledge, probably even faster. And if you buy a table and solar panel instead of making it yourself, it will go superfast and you will probably cut down the time by around 80 %.
# Objective
I chose this project because I wanted to learn more about solar power and also improve my general practical skills. That's why I built the table and solar panel myself instead of buying it. The table also serves a real purpose and can be quite useful since it provides relatively much power. In theory it should provide 162 W in perfect conditions but I've got around 90 W in direct sunlight. The fridge uses only half of this power so the rest goes to charging the motorcycle battery and/or phones/LoPy4. I think this project will teach you a lot about how solar power works and also improve your general handcraft skills a lot. It will also teach you how the internet of things work and how to collect data and send it to the cloud using WiFi.
# Material
## The table
I've used a ton of different tools, screws, glue etc to assemble the table. Which tools or material you use for this is optional and depends on what you already have. I've used a lot of handtools where it would be much easier and faster to use machines. Therefore I will only include the material that I **bought** to build the table.
| Material | Picture | Price(kr) | Link | |
| -------- | ------------------------- | --------- | ----- | ------------------------------------------------------------------------------------------------------ |
| 1 | Plexiglass 1500x750 mm | -bild | 379:- | https://www.hornbach.se/shop/Plexiglasskiva-GOP-akryl-klar-1500x750x3mm/10405111/artikel-detaljer.html |
| 2 | Plywood 12x2500x1200 mm | -bild | 349:- | https://www.byggmax.se/konstruktionsplywood-p1005 |
| 3 | Wood for legs and rims | - | - | already had |
| 4 | Woodglue,screws,tools etc | - | - | already had |
1) Clear plexiglass that lets the light through and is resistant to weather and UV-light.
2) Any plywood/other board that fits your wanted size for the table.
3) For this I used different wooden planks etc laying around.
## Electronics
Here I include the specific material that I used for all the electronics, everything is of course interchangeable for something similar.
| | Material | Picture | Price(kr) | Link |
| --- | --------------------------------------- | ------------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1 | DIY solar panel kit with 40 solar cells |  | 500:- | https://www.ebay.com/itm/303849500634Text |
| 2 | PCB-board |  | 49:- | https://www.amazon.se/gp/product/B07CQQK214/ref=ppx_yo_dt_b_asin_title_o07_s01?ie=UTF8&psc=1 |
| 3 | on-off switch (15A,250V) |  | 100:- | https://www.amazon.se/gp/product/B082B2HCNF/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1 |
| 4 | Solar charge controller |  | 170:- | https://www.amazon.se/gp/product/B01MU0WMGT/ref=ppx_od_dt_b_asin_title_s00?ie=UTF8&psc=1 |
| 5 | 10 AWG cable |  | 180:- | https://www.amazon.se/gp/product/B07568S1KT/ref=ppx_yo_dt_b_asin_title_o06_s00?ie=UTF8&psc=1 |
| 6 | INA260 current and voltage sensor |  | 149:- | https://www.electrokit.com/produkt/stromsensor-ina260-36v-15a-i2c/ |
| 7 | TMP36 temp sensor |  | 19:- | https://www.electrokit.com/produkt/tmp36-to-92-temperaturgivare/ |
| 8 | MCP9700 temp sensor |  | 8:- | https://www.electrokit.com/produkt/mcp9700-e-to-to-92-temperaturgivare/?gclid=CjwKCAjwo4mIBhBsEiwAKgzXODBn8RWZdeyybnCnxN5ar3_QDx7v10eYoU6ZhUZbKdAVXr0PejhcKhoCtUwQAvD_BwE |
| 9 | 12 volt 20 Ah GEL motorcycle battery |  | 799:- | https://www.biltema.se/bil---mc/mc/mc-reservdelar/mc-batterier/mc-batteri-gel-12v-20ah-2000029889 |
| 10 | 12 volt cool box |  | - | - |
| 11 | ***2x*** diod (200 V 10 A) |  | 11.30:- | https://www.electrokit.com/produkt/10a03-r-6-200v-10a/ |
| 12 | LoPy4 + expansion board 3.1 |  | ~570:- | - |
| 13 | Wires,breadboards etc |  | ~50:- | - |
| 14 | Multimeter |  | ~150:- | - |
| 15 | Electrical tape |  | 18:- | https://www.biltema.se/bygg/tejp/eltejp/eltejp-2000038167 |
| 16 | Powerbank with USB port | - | - | - |
| 17 | Soldering station |  | 306:- | https://www.amazon.se/gp/product/B08D6SJMZT/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1 |
| 18 | 12 volt cigarette plug female |  | 60:- | https://www.kjell.com/se/produkter/el-verktyg/biltillbehor/bilbatteritillbehor/12-v-uttag-med-batteriklammor-p67305 |
| | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | | |
1) Solar panel kit with 40 solar cells, 3 flux pens, tabbing wire and thicker bus wire to connect the cells.
2) PCB board to solder the sensors on.
3) Switch to disconnect the solar panel from the charge controller.
4) Solar charge controller that takes the power from the solar panel and charges the battery in a correct way.
5) Thick cables to handle the power from the solar panel without heating up and having much power losses.
6) INA260 sensor that can measure current,voltage and power from the solar panel.
7. and 8. Temperature sensors, you need two and these are the ones I already had, doesn't matter which one you use.
9) 12 volt battery, I used a GEL battery because GEL batteries can handle being discharged and charged more times than regular car batteries. Car batteries are not built for being drained to much since they are supposed to always be charging when in use. Instead of buying a small motorcycle battery like I did you can also buy a bigger solar power battery but they are also more expensive.
10) A load of some kind, I used a 12 volt fridge I already had at home.
11) Diods that can handle at least 10 A for making the solar panel more efficient when partially shaded.
12) LoPy4 + expansion board 3.1. The brains of the system that collect and send all the data to the cloud using WiFi.
13) Wires,breadboard etc to connect the circuits.
14) Multimeter is super helpful and I would say it's needed in this project.
15) Electrical tape to help hold things in place better.
16) Some kind of powerbank with USB connection to give the LoPy4 power.
17) Soldering station of some sort is needed since you will do a ton of soldering.
18) A 12 volt female cigarette plug for connecting the cooling box to the charge controller.
# Computer setup
Before you can start coding your device there are some steps you must do. First you need to connect your LoPy4 to your expansion board like this. 
If you bought a new expansion board you shouldn't have to update the firmware on it, but you need to update the LoPy4 device firmware. Then you have to set up your computer by installing Node.js and your IDE (*integrated development environment*) of choice (Atom or VS Code) and then install the PyMakr plugin in your IDE. [This](https://hackmd.io/@lnu-iot/rk4qNlajd) tutorial goes through all of the steps no matter what OS you are on. I used Atom as my IDE for this project and it worked great! You upload your code to the device with just a click and that way you can try your program step by step as you build it. In the linked tutorial they show you how to program a LED diod to blink and I recommend doing that just to see that everything works before going on with this project. Some additional information on how sensors work and how you connect them etc can be found [here](https://hackmd.io/@lnu-iot/BJnuGmJh_). There is an example using a temperature sensor that will be used in this project as well.
# Putting everything together
## The table
I won't go into too much detail of how to build the table for this project, since I'm a total amateur and it can be done however fits your equipment. But here is a few pictures of the steps I did.
Cut the plywood sheet to fit the plexiglass with some extra space at the edge where the electronics will sit later.

Glue and screw a frame around the underside of the plywood sheet on which the legs will be fasten.

Cut four legs out of some wood and plane them until they get a rounder shape and then polish them with sandpaper.

Fasten the legs with a couple of bolts so they are removable.


Turn the table around and glue a wooden frame on three sides of the table. The last piece that will be put at the bottom of the solar cells is easiest to glue in place after the solar cells are all soldered together.

A top view of the table with some measurements.

## Solar panel
This is a time consuming and repetitive task. You will first have to solder tabbing wire onto every solar cell and then solder all 36 cells in series. Since ebay claims that every cell can provide 0.5 V and 9 A under perfect conditions, then our panel should be able to give $0.5*36=18$ V since they are all connected in series. If each cell provides 9 A they should be able to produce $18*9=162$ W. This is however under perfect conditions and I have gotten 120 W of power as most, around 12 o'clock for a brief time. I am located in Sweden and did my tests in early August so it's not the strongest sun. I bet you would get better results closer to the equator since then the sun is stronger. This panel also lays horizontal so it's better the higher the sun is on the sky.
When handling the solar cells you must be extremely cautious because the cells are very brittle and shatters super easily. This can be seen on the pictures of the final result where a few of my cells have missing pieces. I highly recommend watching this two videos by GreatScott to get a better understanding of what I'm doing here. In [this](https://www.youtube.com/watch?v=6_3gK83bePQ&t=425s) video he builds a solar panel and in [this](https://www.youtube.com/watch?v=sU-hSFFwSmo&t=216s) he explains more theory behind how the panel works and for example what the diods are doing.
Before soldering on the tabbing wire you have to apply the flux onto the white lines, this makes the tabbing wire stick better.

Now you solder the tabbing wire onto all the white lines. The tabbing wires are coated with a thin layer of solder so you don't have to use any additional solder when applying them. Just heat them up with the soldering iron. The length of the tabbing wire should be double the length of the solar cell, since later we will connect the solar cells together with the tabbing wires.

Now do this 35 more times without going crazy and you should have something like this.

This is how you should connect the solar cells to make the solar panel. The top side of the solar cell (blue side) is the negative side and the bottom is the positive side. To make the connection between the cells you put flux on the bottom side and then solder on the tabbing wire from the previous cell to the next one. The connections at the ends are made using the thicker bus wire as you will see on the pictures. The diods will be soldered on like shown here and they are helping to make the solar panel more resistant to partial shading. This are better explained in the two videos I linked by GreatScott.

I found that the tabbing wire didn't want to stick very well to the bottom side and I therefore applied some solder to the cell before soldering on the tabbing wire. Like this.

After I soldered the four rows I applied some electrical tape to make the tabbing wire more secure and then turned the rows around and put them in place. Be very careful when moving the cells so they don't crack.


Now connect the rows like the schematic using the thicker bus wire.

Use the multimeter frequently to see that everything works. If your panel is connected correctly you should get around 13-15 V in the shadow and around 20-21 V in the sun.

Now solder on the diods, the positive and negative wire and also glue in place the last wooden frame with slots cut out for the wires. Then solder on an additional thin black wire on the negative side (this will be used for the current sensor) and also put one of the temperature sensors through the slot in the frame with wires soldered to it.

Here is the negative thick wire, a thinner wire and a temperature sensor. If you look at the corner of the solar panel you can see some glue around the edge. I put a little glue around all four corners of the solar panel to help hold it in place so it doesn't slide around.

Fasten the plexiglass on top of the solar panel. I used 38 screws in total with an old rubber sealing strip in between the glass and the wood to make the panel sealed from dust and water.

## Pycom
The measuring system with the lopy4 should be put together according to this schematic. The "solarpanel-" that is connected to the ground is the small wire we soldered to the negative terminal of the solar panel before.

I soldered the INA260 sensor and one of the temperature sensors onto a PCB board to make it more permanent like this.

Here is a picture of the whole measuring system. The white powerbank to the left is used to power the LoPy4.

## Electronics
Now make a hole for the switch and then put on the wires, I clamped them on using a couple of wire clamps which I screwed in place using the screws on the switch. You can also solder the wire directly to the switch.



After that, screw the solar charge controller in place and make a hole for the 12 volt cigarette plug in the table. Connect the battery, cigarette plug and solar panel to the charge controller. Keep the switch off until you have set up the solar charge controller to charge your battery with the correct voltage etc. You have to check your battery's data sheet to see what voltage it should be charged with and at what voltage it's empty etc. Then you set the charge controller to the right settings. You should always have the switch off when the battery is not connected to the charge controller, if the solar panel is connected but not the battery, the charge controller can get damaged. Now you are done and the final electronics should look like this. The solar charge controller has two USB port outputs, one can be used to charge the powerbank so your LoPy4 always has power and the other can be used to for example charge your phone.

## Platform
The cloud platform I'm using is the [Ubidots](https://ubidots.com/) platform. This platform is really easy to use and has got a lot of different options for presenting your data with different graphs and tables. I first tried using the Pybytes platform but I found it really limited in the amount of options for presenting the data. Ubidots also has functions to set up alarms when different events are triggered, it's for example possible to get alarmed by e-mail if the temperature exceeds some value in the solar panel. I haven't done this yet but I might do it in the future. Follow [this](https://help.ubidots.com/en/articles/961994-connect-any-pycom-board-to-ubidots-using-wi-fi-over-http) guide to learn how to send data to Ubidots.
## The code
In the linked [Ubidots](https://help.ubidots.com/en/articles/961994-connect-any-pycom-board-to-ubidots-using-wi-fi-over-http) guide you can just copy & paste the code for the library and boot file. The main file looks like follows:
```python=
from network import WLAN #ubidoft
import urequests as requests #ubidoft
from machine import I2C
from machine import Pin
import machine
import time
import utime
import struct
############################################################################
TOKEN = "BBFF-mRmNZPGQtaMzfnx80VB04Rk2SumnFD" #Put here your TOKEN
DELAY = 1 # Delay in seconds
wlan = WLAN(mode=WLAN.STA)
wlan.antenna(WLAN.INT_ANT)
# Assign your Wi-Fi credentials
wlan.connect("TrdlsHemma", auth=(WLAN.WPA2, "TrdlsHemma6165879804"), timeout=5000)
while not wlan.isconnected ():
machine.idle()
print("Connected to Wifi\n")
# Builds the json to send the request
def build_json(variable1, value1, variable2, value2, variable3, value3, variable4, value4, variable5, value5):
try:
data = {variable1: {"value": value1},
variable2: {"value": value2},
variable3: {"value": value3},
variable4: {"value": value4},
variable5: {"value": value5}}
return data
except:
return None
# Sends the request. Please reference the REST API reference https://ubidots.com/docs/api/
def post_var(device, value1, value2, value3, value4, value5):
try:
url = "https://industrial.api.ubidots.com/"
url = url + "api/v1.6/devices/" + device
headers = {"X-Auth-Token": TOKEN, "Content-Type": "application/json"}
data = build_json("current", value1, "voltage", value2, "power", value3, 'temp_box,', value4, 'temp_panel', value5)
if data is not None:
print(data)
req = requests.post(url=url, headers=headers, json=data)
return req.json()
else:
pass
except:
pass
####################################################################
# INA CONSTS
INA260_ADDR = 0x40
REG_CONFIG = 0x00
REG_CURRENT = 0x01
REG_BUS_VOLTAGE = 0x02
REG_POWER = 0x03
REG_MASK_ENABLE = 0x06
REG_ALERT = 0x07
REG_MANUFACTURER_ID = 0xFE
REG_DIE_ID = 0xFF
# TMP36 constants
adc = machine.ADC()
apin = adc.channel(pin='P16')
bpin = adc.channel(pin='P17')
i2c_0 = I2C(1, mode=I2C.MASTER, baudrate=100000, pins=('P7', 'P8'))
utime.sleep_ms(500)
def read(i2c, address, register, bytes):
res = i2c_0.readfrom_mem(address, register, bytes)
return bytearray(res)
#returns voltage in V
def get_voltage():
voltage = read(i2c_0, INA260_ADDR, REG_BUS_VOLTAGE, 2)
voltage = struct.unpack('>H', voltage)[0]
voltage *= 0.00125 # 1.25mv/bit
return voltage
#returns current in A
def get_current():
current = read(i2c_0, INA260_ADDR, REG_CURRENT, 2)
current = struct.unpack('>H', current)[0]
if current & (1 << 15):
current -= 65535
current *= 0.00125 # 1.25mA/bit
return current
#returns power in W
def get_power():
power = read(i2c_0, INA260_ADDR, REG_POWER, 2)
power = struct.unpack('>H', power)[0]
power = power/100 # to get in W
return power
while True:
millivolts_box = apin.voltage()
millivolts_panel = bpin.voltage()
celsius_box = (millivolts_box - 500.0) / 10.0
celsius_panel = (millivolts_panel - 500.0) / 10.0
print('temp electronics :')
print(celsius_box)
print('temp panel :')
print(celsius_panel)
print(get_current())
print(get_voltage())
print(get_power())
print('-----')
post_var("pycom",get_current() ,get_voltage(), get_power(), celsius_box, celsius_panel) #Sends to Ubidoft
print('sent signals')
time.sleep(5)
```
Rows 64-72 is the registers for the INA260. Since this is a I2C sensor it is a bit more complicated and needs some additional code. In the while-loop there is some code that prints stuff to the console. This is for checking that everything works when you are still connected to your computer. The post_var function at row 126 is what sends the data to Ubidots.
## Transmitting the data / connectivity
The data is transmitted to Ubidots using the internal antenna on the LoPy4 device. It's sent every 5 seconds using WiFi with *webhook* transport protocol. Since the solar panel is at our house we can use WiFi as range isn't a problem. WiFi uses more power but we can use this and also send data how often we'd like since the LoPy4 gets powered by the sun and won't get discharged anyways. If the system were to be used in let's say a off-grid house in the woods, then LoRa would be better for the improved range.
## Presenting the data
The data is saved in Ubidots everytime we upload, in our case every 5 seconds. The data is stored on the website for 1 month. Here is how my dashboard looks:

As we can see the panel produces around 90 W of power when the sun is shining. When clouds cover the sun it drops drastically down to around 10-20 W. Unfortunately at the time I recorded this data the weather was not very good and I only got sun for a couple of minutes at a time since it was pretty cloudy. We can see that the power peaked over 100 W a few times and I think on a better day it's possible to consistantly get around 100 W of power. As mentioned before it's possible to set up alarms for events. This is done by going to Data -> Events. I haven't done this yet because I need to experiment more how much the temperature can increase in the solar panel when the sun is shining for longer periods of time. The reason I chose Ubidots is because of how good this dashboard looks and I also wanted the possibility to set up the alarms later.
## Finalizing the design
Here is a few pictures of the final product:





I'm very satisfied by how it turned out. The only problem is that when the sun is heating up the solar panel, it creates some condensation on the inside of the glass as can be seen on the video below. I don't think this is a big problem though. I'm not finished yet and I have a few more things I will do. First of all I need to build a cover for the electronics that is sealed good so the table can handle rain. Then I will build some kind of hanger for the battery so it can sit under the table instead of on the ground. I will also put some kind of finishing oil on the table and neat it up to make it look better. I've also been filming the process of doing this project and I will put that together into a video, not in time for this course unfortunately but soon in the future.
Here is a short video demonstration of the table. It works and it keeps my beer cold using the sun, as planned :sunglasses:
{%youtube t8SSgiYp21w %}