• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

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

Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • .jpg
    .jpg
    793.8 KB · Views: 653
  • arduino.png
    arduino.png
    67.4 KB · Views: 579
Last edited:
Joined
Jun 27, 2011
Messages
6,680 (1.43/day)
Processor 7800x3d
Motherboard Gigabyte B650 Auros Elite AX
Cooling Custom Water
Memory GSKILL 2x16gb 6000mhz Cas 30 with custom timings
Video Card(s) MSI RX 6750 XT MECH 2X 12G OC
Storage Adata SX8200 1tb with Windows, Samsung 990 Pro 2tb with games
Display(s) HP Omen 27q QHD 165hz
Case ThermalTake P3
Power Supply SuperFlower Leadex Titanium
Software Windows 11 64 Bit
Benchmark Scores CB23: 1811 / 19424 CB24: 1136 / 7687
You sir always have the most interesting projects I must say.
 
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • arduino.png
    arduino.png
    105.7 KB · Views: 667
Last edited:
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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
10,881 (1.63/day)
Location
Manchester, NH
System Name Senile
Processor I7-4790K@4.8 GHz 24/7
Motherboard MSI Z97-G45 Gaming
Cooling Be Quiet Pure Rock Air
Memory 16GB 4x4 G.Skill CAS9 2133 Sniper
Video Card(s) GIGABYTE Vega 64
Storage Samsung EVO 500GB / 8 Different WDs / QNAP TS-253 8GB NAS with 2x10Tb WD Blue
Display(s) 34" LG 34CB88-P 21:9 Curved UltraWide QHD (3440*1440) *FREE_SYNC*
Case Rosewill
Audio Device(s) Onboard + HD HDMI
Power Supply Corsair HX750
Mouse Logitech G5
Keyboard Corsair Strafe RGB & G610 Orion Red
Software Win 10
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,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • DSCF4019.jpg
    DSCF4019.jpg
    490.5 KB · Views: 512
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
this is the soldering to be done
 

Attachments

  • tl-wr703n_top.jpg
    tl-wr703n_top.jpg
    77.3 KB · Views: 499
  • tl-wr703n_bottom.jpg
    tl-wr703n_bottom.jpg
    92.2 KB · Views: 627
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 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
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • DSCF4022.JPG
    DSCF4022.JPG
    994.8 KB · Views: 488

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
8,193 (1.50/day)
Location
Charleston, SC
System Name Tower of Power / Sechs
Processor i7 14700K / i7 5820k @ 4.5ghz
Motherboard ASUS ROG Strix Z690-A Gaming WiFi D4 / X99S GAMING 7
Cooling CM MasterLiquid ML360 Mirror ARGB Close-Loop AIO / CORSAIR Hydro Series H100i Extreme
Memory CORSAIR Vengeance LPX 32GB (2 x 16GB) DDR4 3600 / G.Skill DDR4 2800 16GB 4x4GB
Video Card(s) ASUS TUF Gaming GeForce RTX 4070 Ti / ASUS TUF Gaming GeForce RTX 3070 V2 OC Edition
Storage 4x Samsung 980 Pro 1TB M.2, 2x Crucial 1TB SSD / Samsung 870 PRO 500GB M.2
Display(s) Samsung 32" Odyssy G5 Gaming 144hz 1440p, ViewSonic 32" 72hz 1440p / 2x ViewSonic 32" 72hz 1440p
Case Phantek "400A" / Phanteks “Enthoo Pro series”
Audio Device(s) Realtek ALC4080 / Azalia Realtek ALC1150
Power Supply Corsair RM Series RM750 / Corsair CXM CX600M
Mouse Glorious Gaming Model D Wireless / Razer DeathAdder Chroma
Keyboard Glorious GMMK with box-white switches / Keychron K6 pro with blue swithes
VR HMD Quest 3 (128gb) + Rift S + HTC Vive + DK1
Software Windows 11 Pro x64 / Windows 10 Pro x64
Benchmark Scores Yes
Nice work man! :toast:
 
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • ser2net.jpg
    ser2net.jpg
    168.7 KB · Views: 494
Last edited:
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • DSCF4024.JPG
    DSCF4024.JPG
    1.8 MB · Views: 616
Last edited:
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • DSCF4026.JPG
    DSCF4026.JPG
    693 KB · Views: 449
  • DSCF4027.JPG
    DSCF4027.JPG
    1.1 MB · Views: 564
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • graph.jpg
    graph.jpg
    192.6 KB · Views: 480
Last edited:
Joined
Mar 12, 2009
Messages
1,075 (0.20/day)
Location
SCOTLAND!
System Name Machine XV
Processor Dual Xeon E5 2670 V3 Turbo unlocked
Motherboard Kllisre X99 Dual
Cooling 120mm heatsink
Memory 64gb DDR4 ECC
Video Card(s) RX 480 4Gb
Storage 1Tb NVME SSD
Display(s) 19" + 23" + 17"
Case ATX
Audio Device(s) XFi xtreme USB
Power Supply 800W
Software Windows 10
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

  • DSCF4029.JPG
    DSCF4029.JPG
    911.3 KB · Views: 528
Top