# Arduino for managing Solar powered wireless router volts/amps/temp/light



## Geofrancis (Mar 31, 2014)

i have built a solar powered wireless router and to manage it i have designed a system around an arduino board connected to the network via a serial port and SER2NET on openWRT.

the idea is to use the arduino to monitor the battery voltage, solar panel current output, sun brightness, uptime and monitor the battery temperature to turn on the cooler.

so using what  i have picked up from school doing Comal and messing around with flight controllers i managed to google and hack enough code together to almost do what i need it to do. (i think)

does anyone know a better way of doing any of the code ? this is my first time so assume its crap

the solar readout is a bit basic i need to figure out a way of calibrating the LDR so 100% is a sunny day in summer and 0% is darkness

it looks okish on my test arduino with nothing connected but im sure thats why the measurements are a bit whacky.

the fan control will eventually run a small TEC to cool the batteries transferring the heat to the aluminium back plate. i figure if its hot enough to overheat the batteries i can spare some power to cool them.





Geofrancis said:


> int voltPin = A0;  // voltage divider (middle terminal) connected to analog pin 0
> int tempPin = A2;  // TMP36 data pin
> int val = 0;  // variable to store the value read
> int volt = 0;  // variable to store the voltage calculated
> ...


----------



## Nordic (Mar 31, 2014)

You sir always have the most interesting projects I must say.


----------



## Geofrancis (Mar 31, 2014)

i want to mas produce these soon so i am doing my best to keep the costs down so far its:

20W solar panel                                               £32
TP-link wr703n with openWRT                        £14
4s 5800mah lithium pack                                 £30
arduino lillypad                                                £4
4s battery protection pcb                                £4
temperature sensor                                          £2.30
light dependant resistor                                   £2.75
5a current sensor                                              £2.66

if it gets too hot during the summer i will add
5a transistor
30w TEC plate connecting the aluminium plate against the batteries to the backplate of the router.


and a couple of random resistors

I could probably use just one of the batteries during the summer and 1/4 of the solar panel but I live in Scotland  where the days are very short during the winter with sunrise around 8:30 and sunset around 4pm but im on the west coast so it doest get too cold for very long. so i hope to get away with using cheap lithium packs.


----------



## Geofrancis (Mar 31, 2014)

i am replacing the cheap ebay regulator at 4v and the linear regulator in the router with a TRACO TSR 1-2433 - 3.3V/1A switching regulator to try and get power consumption down as low as i can. if i bypass the regulator and run both the arduino and the router direct from the 3.3v switching regulator i should get much more efficiency.


----------



## Geofrancis (Mar 31, 2014)

i have make singificant progress on the arduino software i now have functional voltage,amps,temperature, light, cooling and heating.

i have even managed to add graphing to it using SimPlot http://www.negtronics.com/simplot



im just waiting for some sensors and the routers now.




Geofrancis said:


> int voltPin = A0;  // voltage divider (middle terminal) connected to analog pin 0
> int tempPin = A2;  // TMP36 data pin
> const int pinLDR = A5; // Analog Pin A0 connects across LDR
> const int pinLED = A1; // Analog Pin A1 connects across LED
> ...


----------



## Geofrancis (Apr 1, 2014)

my TP link router arrived today














what i have to do:
install OpenWRT,

configure the serial port to run at 9600 baud rather than 115200 to hopefully save a little more power

install ser2net

setup ser2net to forward the onboard serial port

solder 2 wires from the serial port to the arduino

chop the antenna off the pcb and solder on a pigtail

bypass the onboard 3.3v regulator and run it from a TRACO TSR 1-2433 - 3.3V/1A switching regulator along with the arduino.


----------



## Sasqui (Apr 1, 2014)

A friend of mine built an arduino controlled solar powered hydroponic tower.  The arduino controls the solar charging, pump on/off timing and measures temp (he plans on PH as well), logs all information to an SD card.  The setup looks like a crashed satellite with tomatoes growing out of it 

Needless to say, I'm interested in this!  Can't help much as I was just watching it all.  Subbed.


----------



## Geofrancis (Apr 1, 2014)

my first prototype was a little funky looking it ran from 2x 5v 1A solar panels in parallel charging a 1s 6p rewired laptop battery. everything is mounted to a spare tv antenna that was ideal for adjusting the panels for the optimum angle. but this time im trying to put everything inside a solar panel rather than all the elaborate mounting.


----------



## Geofrancis (Apr 1, 2014)

this is the soldering to be done


----------



## Geofrancis (Apr 1, 2014)

ok using a combiation of the firmware from here and guide here 

I have managed to get ser2net running on openwrt and accepting connections from my pc over the network. when my arduino arrives il find out if it works properly.


----------



## blobster21 (Apr 1, 2014)

very interesting build !


----------



## Geofrancis (Apr 5, 2014)

i have been spending the last few days working out the best way to setup a transparent wireless repeater on DD-WRT or OpenWRT. unfortunately i didn't realise the universal repeater function was only available on broadcom and not on my atheros based routers so eventually after not being able to find an acceptable solution i have got it working using WDS. i didnt want to use it originally because of vendor lock in but since all my ubiquiti and tp-link routers are atheros its not really an issue.

i think i have everything working now. transparent wireless bridging and the serial output for monitoring @ 115200 since that is the routers default speed but i will change that to 9600 once im sure its working.

the key was disabling the console on the serial port  removing "ttyATH0::askfirst:/bin/ash --login" from the /etc/inittab

and adding "1024:raw:600:/dev/ttyATH0/1:115200 NONE 1STOPBIT 8DATABITS -XONXOFF -LOCAL -RTSCTS" to /etc/ser2netconf

and "ser2net" to the startup.


im just waiting for my arduino. and current sensor before i can test it properly.


----------



## Geofrancis (Apr 6, 2014)

i soldered the wires on for the 3.3v voltage regulator and hot glued it in place along with the wires for the serial and a led to make sure the pads were working.


----------



## Mindweaver (Apr 6, 2014)

Nice work man!


----------



## Geofrancis (Apr 6, 2014)

i hooked up my test arduino nano v3 via a couple of 1k resistors to the routers serial port and got it kind of working...

its getting a lot of corruption at 115200 but to change it i would have to compile openwrt from source as the serial baud rate is hard coded into the kernel but i think it should be ok with my new arduino as its also 3.3v .


OK... After some more testing and changing the firmware I have the serial port talking to the arduio at 9600 baud and all the corruption has gone.


----------



## Geofrancis (Apr 6, 2014)

i have got sick of waiting for my arduino lillypad and decided to just convert my arduino pro mini to 3.3v and use it for calibrating everything.

now the ardino is talking to the router i can start connecting sensors.


----------



## Geofrancis (Apr 7, 2014)

i have hooked up a pair of resistors as a voltage divider and calibrated it for my 3.3v arduino, 
10k LDR and 10k resistor to measure sunlight
TMP36 thermistor is working but needs better calibrated

the only thing stopping me installing this in a router just now is waiting for my current sensor.


----------



## Geofrancis (Apr 7, 2014)

everything apart from the current sensor is now working damn slow china post.

next step is to learn about the power management on the arduino so that i can minimise its power consumption.



Geofrancis said:


> //volts
> int batMonPin = A0;  // input pin for the voltage divider
> int batVal = 0;  // variable for the A/D value
> float pinVoltage = 0; // variable to hold the calculated voltage
> ...


----------



## Geofrancis (Apr 13, 2014)

ok some more progress!

done some thermal testing to see if the batteries would overheat but with the 6mm depron between the panel and the batteries they are barely getting warm. then i done some cold testing by sticking the router in my freezer for a week at -20 to see the effect on the battery but it was minimal since im only using 80ma from the batteries.

external rp-sma connector is now soldered to the router.
Light Dependant resistor is now on the front of the solar panel.
Router led now mounted to the outside of the solar panel.

still to do

waiting for the damn current sensor!!
change the charger pcb since this one goes up to 4.35v which is far too high for these lipo batteries.


----------

