• We've upgraded our forums. Please post any issues/requests in this thread.

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

Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#1
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.



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

int analogInPin = A1; // Analog input pin that the carrier board OUT is connected to
int sensorValue = 0; // value read from the carrier board
int outputValue = 0; // output in milliamps

int LDR_Pin = A4; //analog pin 0

int hightemp = 13; // choose the pin for the LED
int lowtemp = 12; // choose the pin for the LED

float amps = 0.0;
unsigned long msec = 0;
float time = 0.0;
int sample = 0;



void setup()
{
Serial.begin(9600); // setup serial
pinMode(hightemp, OUTPUT); // declare LED as output
pinMode(lowtemp, OUTPUT); // declare LED as output
}

void loop()
{
// Voltage Calculation
val = analogRead(voltPin); // read the input pin
volt = map(val, 0, 1023, 0, 29); // map 29v range
delay(50);


// temp calculaton
int reading = analogRead(tempPin); // read the input pin
float voltage = reading * 5.0;
voltage /= 1024.0;


//current monitor

// read the analog in value:
sensorValue = analogRead(analogInPin);

// convert to milli amps
outputValue = (((long)sensorValue * 5000 / 1024) - 500 ) * 1000 / 133;
amps = (float) outputValue / 1000;
float watts = amps * voltage;

//light dependsnt resistor
int LDRReading = analogRead (LDR_Pin)/10 ;

//uptime
msec = millis();
time = (float) msec / 1000.0;


//Fan control
{
float temperatureC = (voltage - 0.5) * 100;
if (temperatureC > 40) {
digitalWrite(hightemp, LOW); // turn LED OFF
} else {
digitalWrite(hightemp, HIGH); // turn LED ON
}
if (temperatureC < 10) {
digitalWrite(lowtemp, LOW); // turn LED OFF
} else {
digitalWrite(lowtemp, HIGH); // turn LED ON
}


// serial output
}
Serial.print(voltage);
Serial.print(" volts");
Serial.print("\t Current (amps) = ");
Serial.print(amps);
Serial.print("\t Power (Watts) = ");
Serial.print(watts);
float temperatureC = (voltage - 0.5) * 100;
Serial.print("\t degrees C = ");
Serial.print(temperatureC);
Serial.print("\t Solar output % = ");
Serial.print(LDRReading);

Serial.print("\t Time (hours) = ");
Serial.println(time/3600);


delay(500);
}
 

Attachments

Last edited:
Joined
Jun 27, 2011
Messages
5,626 (2.38/day)
Likes
2,986
Processor Intel I7 4790k (stock)
Motherboard ASRock H97M-ITX/ac LGA 1150 Intel H97
Cooling Prolimatech megahalem
Memory Crucial 2x4gb 1600mhz
Video Card(s) EVGA 1060 3gb
Storage OWC Mercury SSD 240 GB
Display(s) Asus 144hz
Case Raijintek Metis
Power Supply Corsair SF600 600w psu
Software Windows 10 64 Bit
#2
You sir always have the most interesting projects I must say.
 
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#3
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.
 
Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#4
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.
 
Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#5
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.


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
int val = 0; // variable to store the value read
int volt = 0; // variable to store the voltage calculated
int hightemp = 13; // choose the pin for the LED
int lowtemp = 12; // choose the pin for the LED
unsigned long msec = 0;
float time = 0.0;
int sample = 0;
float valueVolt; // We'll need these float variables for calculations
float valueBrightness;


int buffer[20];
float deltaAngle = 3.14/51; //Arbitrary angle increment size
float angle = 0;
int amplitude = 100;


void setup()
{
Serial.begin(9600); // setup serial
pinMode(hightemp, OUTPUT); // declare LED as output
pinMode(lowtemp, OUTPUT); // declare LED as output
}

void loop()
{


int data1;
int data2;
int data3;
int data4;





// Voltage Calculation
val = analogRead(voltPin); // read the input pin
volt = map(val, 0, 1023, 0, 29); // map 29v range
delay(50);


// temp calculaton
int reading = analogRead(tempPin); // read the input pin
float voltage = reading * 5.0;
voltage /= 1024.0;


//current monitor

float amps = 0;
for(int i = 0; i < 1000; i++) {
amps = amps + (.0264 * analogRead(A1) -13.51) / 1000;
delay(1);
}



//light dependsnt resistor
valueVolt = analogRead(pinLED)*5.0/1024; // Store the calculated voltage in a float var
valueBrightness = map(analogRead(pinLDR),990,645,0,100);

//uptime
msec = millis();
time = (float) msec / 1000.0;


//Fan control
{
float temperatureC = (voltage - 0.5) * 100;
if (temperatureC < 40) {
digitalWrite(hightemp, LOW); // turn LED OFF
} else {
digitalWrite(hightemp, HIGH); // turn LED ON
Serial.println("OVERHEAT");
}
if (temperatureC > 10) {
digitalWrite(lowtemp, LOW); // turn LED OFF
} else {
digitalWrite(lowtemp, HIGH); // turn LED ON
Serial.println("COLD");
}





//graphing




// serial output
}
Serial.print(voltage);
Serial.print(" volts");
Serial.print("\t Current (amps) = ");
Serial.print(amps);
float watts = amps * voltage;
Serial.print("\t Power (Watts) = ");
Serial.print(watts);
float temperatureC = (voltage - 0.5) * 100;
Serial.print("\t degrees C = ");
Serial.print(temperatureC);
Serial.print("\t Solar output % = ");
Serial.print(valueBrightness);

Serial.print("\t Time (hours) = ");
Serial.println(time/3600);



//Generating data that will be plotted
data1 = voltage;
data2 = amps;

data3 = temperatureC;
data4 = valueBrightness;

angle = angle + deltaAngle;

plot(data1,data2,data3,data4);

delay(100); //Need some delay else the program gets swamped with data

}

void plot(int data1, int data2, int data3, int data4)
{
int pktSize;

buffer[0] = 0xCDAB; //SimPlot packet header. Indicates start of data packet
buffer[1] = 4*sizeof(int); //Size of data in bytes. Does not include the header and size fields
buffer[2] = data1;
buffer[3] = data2;
buffer[4] = data3;
buffer[5] = data4;

pktSize = 2 + 2 + (4*sizeof(int)); //Header bytes + size field bytes + data

//IMPORTANT: Change to serial port that is connected to PC
Serial.write((uint8_t * )buffer, pktSize);





}
 

Attachments

Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#6
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.
 
Joined
Dec 6, 2005
Messages
9,800 (2.23/day)
Likes
3,786
Location
Manchester, NH
System Name Working on it ;)
Processor I7-4790K
Motherboard MSI Z97
Cooling Be Quiet Pure Rock Air
Memory 16GB 4x4 G.Skill CAS9 2133 Sniper
Video Card(s) Intel IGP (Dedicated GPU TBD)
Storage WD 320 / 500KS / 500KS / 640KS / 640LS / 640LS / 640LS / 1TBFAEX and a NAS with 2x2Tb WD Black
Display(s) 24" DELL 2405FPW
Case Rosewill Challenger
Audio Device(s) Onboard + HD HDMI
Power Supply Corsair HX750 (love it)
Mouse Logitech G5
Software Win 7 Pro
#7
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.
 
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#8
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.
 

Attachments

Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#9
this is the soldering to be done
 

Attachments

Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#10
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.
 
Joined
Oct 24, 2004
Messages
813 (0.17/day)
Likes
463
System Name $computer$
Processor Core i7 4790K @ 4.4Ghz
Motherboard MSI Z97 Gaming 5
Cooling Alpenföhne Broken 120 + 2 huge coolermaster chassis fans
Memory 2x8GB DDR3 2133Mhz Crucial Ballistix
Video Card(s) Geforce GTX 1080
Storage 2x60gb Kingston SSDnow 320 / 1x120gb Crucial SSD C300 / 1 WD caviar black 1tb
Display(s) 40" Samsung UE40ES5500
Case Cooler Master HAF932
Audio Device(s) onboard realtek audio
Power Supply Corsair AX1200
Mouse Microsoft intellimouse optical
Keyboard Logitech K270
Software Windows 10 Pro
Benchmark Scores https://valid.x86.fr/vmb641
#11
very interesting build !
 
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#12
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.
 
Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#13
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.
 

Attachments

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,583 (2.08/day)
Likes
3,915
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#14
Nice work man! :toast:
 
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#15
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.
 

Attachments

Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#16
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.
 

Attachments

Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#17
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.
 

Attachments

Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#18
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.

//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
float batteryVoltage = 0;


//current
int analogInPin = A1; // Analog input pin that the carrier board OUT is connected to
int sensorValue = 0; // value read from the carrier board
int outputValue = 0; // output in milliamps
unsigned long msec = 0;
float time = 0.0;
int sample = 0;
float totalCharge = 0.0;
float averageAmps = 0.0;
float ampSeconds = 0.0;
float ampHours = 0.0;
float wattHours = 0.0;
float amps = 0.0;


int R1 = 30000; // Resistance of R1 in ohms
int R2 = 4620; // Resistance of R2 in ohms
float ratio = 0; // Calculated from R1 / R2


//Temperature

int tempPin = A2; // TMP36 data pin
const int pinLDR = A3; // Analog Pin A0 connects across LDR

//Brightness
float valueBrightness;




//graphing
int buffer[20];
float deltaAngle = 3.14/51; //Arbitrary angle increment size
float angle = 0;
int amplitude = 100;


void setup()
{
Serial.begin(9600); // setup serial
}

void loop()
{


int data1;
int data2;
int data3;
int data4;





// Voltage Calculation

int sampleBVal = 0;
int avgBVal = 0;
int sampleAmpVal = 0;
int avgSAV = 0;
for (int x = 0; x < 10; x++){ // run through loop 10x

// read the analog in value:
sensorValue = analogRead(analogInPin);
sampleAmpVal = sampleAmpVal + sensorValue; // add samples together

batVal = analogRead(batMonPin); // read the voltage on the divider
sampleBVal = sampleBVal + batVal; // add samples together
delay (10); // let ADC settle before next 0sample

}

avgBVal = sampleBVal / 10; //divide by 10 (number of samples) to get a steady reading

pinVoltage = avgBVal * 0.00334; // Calculate the voltage on the A/D pin

ratio = (float)R1 / (float)R2;
batteryVoltage = pinVoltage * ratio; // Use the ratio calculated for the voltage divider
// to calculate the battery voltage




// temp calculaton
int reading = analogRead(tempPin); // read the input pin
float voltage = reading * 3.3;
voltage /= 1024.0;


//current monitor

float amps = 0;
for(int i = 0; i < 1000; i++) {
amps = amps + (.0264 * analogRead(A1) -13.51) / 1000;
delay(1);
}



//light dependsnt resistor

valueBrightness = map(analogRead(pinLDR),1024,10,0,100);

//uptime
msec = millis();
time = (float) msec / 1000.0;





// serial output
Serial.print("Volts = " );
Serial.print(batteryVoltage);
Serial.print("\t Current (amps) = ");
Serial.print(amps);
float watts = amps * batteryVoltage;
Serial.print("\t Power (Watts) = ");
Serial.print(watts);
float temperatureC = (voltage - 0.5) * 100;
Serial.print("\t degrees C = ");
Serial.print(temperatureC);
Serial.print("\t Solar output % = ");
Serial.print(valueBrightness);

Serial.print("\t Time (hours) = ");
Serial.println(time/3600);



//Generating data that will be plotted
data1 = batteryVoltage;
data2 = watts;

data3 = temperatureC;
data4 = valueBrightness;

angle = angle + deltaAngle;

plot(data1,data2,data3,data4);

delay(100); //Need some delay else the program gets swamped with data

}

void plot(int data1, int data2, int data3, int data4)
{
int pktSize;

buffer[0] = 0xCDAB; //SimPlot packet header. Indicates start of data packet
buffer[1] = 4*sizeof(int); //Size of data in bytes. Does not include the header and size fields
buffer[2] = data1;
buffer[3] = data2;
buffer[4] = data3;
buffer[5] = data4;

pktSize = 2 + 2 + (4*sizeof(int)); //Header bytes + size field bytes + data

//IMPORTANT: Change to serial port that is connected to PC
Serial.write((uint8_t * )buffer, pktSize);





}
 

Attachments

Last edited:
Joined
Mar 12, 2009
Messages
1,042 (0.33/day)
Likes
153
Location
SCOTLAND!
System Name Machine XII
Processor Phenom II 1155T
Motherboard Asus M4A88TD-M EVO/USB3
Cooling Custom Water Cooling
Memory 8Gb ddr3 1600mhz XMS 3
Video Card(s) HD5970 2Gb
Storage 128Gb Sandisk SATAIII 6G/s
Display(s) 19" + 23" + 17"
Case micro atx case
Audio Device(s) XFi xtreme OEM
Power Supply 750W
Software Windows 7 x64 Ultimate
#19
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.
 

Attachments