- Joined
- Mar 12, 2009
- Messages
- 1,155 (0.20/day)
- Location
- SCOTLAND!
System Name | Machine XX |
---|---|
Processor | Ryzen 7600 |
Motherboard | MSI X670E GAMING PLUS |
Cooling | 120mm heatsink |
Memory | 32GB DDR5 6000 CL30 |
Video Card(s) | RX5700XT 8Gb |
Storage | 280GB Optane 900p + 2tb 4.0 NVME + 2tb sata ssd. |
Display(s) | 19" + 23" + 17" |
Case | ATX |
Audio Device(s) | Soundblaster Z |
Power Supply | 800W |
Software | Windows 11 |
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.
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: