Phone Media Centre with a Peltier Cooler

Hi Guys
Pretty much a noob here as it comes to arduino coding, I have a decent understanding of java but sometime the simplest things throw me for a loop. I have started a project with an old phone as a media center and seeing as it overheats in summer as its in full sun on the dashboard I added a Peltier cooler to the back and used an Wemos D1 mini with a soft AP configured, works well using tasker to send http requests to the Wemos.

However I need some default backup as sometimes the phone drops wifi connection and I dont want the peltier to draw full amps for an unlimited time constraint. I have two options I can control the peltier time on on the arduino side or the phone side. but I recently had an instance where the phone sent the ON command and then proceded to disconnect and never sent the OFF command. I have tried to get the Wemos to sense a client is present, which works fine, but when checking if the client is present and status is HIGH then I get an error that i cannot fix. at least from my view.

Hope you guys can help a brother out.
Kind regards
AsaltedPnut

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
extern "C" {
  #include<user_interface.h>
}


/* Put your SSID & Password */
const char* ssid = "AsaltedPnut D1";  // Enter SSID here
const char* password = "25042010";  //Enter Password here

/* Put IP Address details */
IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

ESP8266WebServer server(80);

uint8_t LED1pin = D1;
bool LED1status = LOW;


uint8_t LED2pin = D6;
bool LED2status = LOW;

void setup() {
  Serial.begin(115200);
  pinMode(LED1pin, OUTPUT);
  pinMode(LED2pin, OUTPUT);

  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  WiFi.softAPConfig(local_ip, gateway, subnet);
  delay(100);
  
  server.on("/", handle_OnConnect);
  server.on("/led1on", handle_led1on);
  server.on("/led1off", handle_led1off);
  server.on("/led2on", handle_led2on);
  server.on("/led2off", handle_led2off);
  server.onNotFound(handle_NotFound);
  
  server.begin();
  Serial.println("HTTP server started");
}
void loop() {
  server.handleClient();
  if(LED1status)
  {digitalWrite(LED1pin, HIGH);}
  else
  {digitalWrite(LED1pin, LOW);}
  
  if(LED2status)
  {digitalWrite(LED2pin, HIGH);}
  else
  {digitalWrite(LED2pin, LOW);}
  client_status();
  delay(500);
}



void handle_OnConnect() {
  LED1status = LOW;
  LED2status = LOW;
  Serial.println("Peltier Status: OFF | GPIO6 Status: OFF");
  server.send(200, "text/html", SendHTML(LED1status,LED2status)); 
}

void handle_led1on() {
  LED1status = HIGH;
  Serial.println("GPIO7 Status: ON");
  server.send(200, "text/html", SendHTML(true,LED2status)); 
}

void handle_led1off() {
  LED1status = LOW;
  Serial.println("GPIO7 Status: OFF");
  server.send(200, "text/html", SendHTML(false,LED2status)); 
}

void handle_led2on() {
  LED2status = HIGH;
  Serial.println("GPIO6 Status: ON");
  server.send(200, "text/html", SendHTML(LED1status,true)); 
}

void handle_led2off() {
  LED2status = LOW;
  Serial.println("GPIO6 Status: OFF");
  server.send(200, "text/html", SendHTML(LED1status,false)); 
}

void handle_NotFound(){
  server.send(404, "text/plain", "Not found");
}
void client_status() {

  unsigned char number_client;    //<<<  complains about this variable
  int num = number_client;
  struct station_info *stat_info;
  
  struct ip_addr *IPaddress;
  IPAddress address;
  int i=1;
  
  number_client= wifi_softap_get_station_num();
  stat_info = wifi_softap_get_station_info();
  
  Serial.print(" Total Connected Clients are = ");
  Serial.println(number_client);
  
    while (stat_info != NULL) {
      Serial.print("client= ");
      
      Serial.print(i);
      Serial.print(" IP adress is = ");
      Serial.print((address));
      Serial.print(" with MAC adress is = ");
      
      Serial.print(stat_info->bssid[0],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[1],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[2],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[3],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[4],HEX);Serial.print(" ");
      Serial.print(stat_info->bssid[5],HEX);Serial.print(" ");
      
      stat_info = STAILQ_NEXT(stat_info, next);
      i++;
      Serial.println();
    }
//               HERE IS MY ISSUE
//      if(num=0 && LED1status=HIGH){
 //     digitalWrite(LED1pin, LOW);
 //   }

    
}

String SendHTML(uint8_t led1stat,uint8_t led2stat){
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>LED Control</title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n";
  ptr +=".button {display: block;width: 80px;background-color: #1abc9c;border: none;color: white;padding: 13px 30px;text-decoration: none;font-size: 25px;margin: 0px auto 35px;cursor: pointer;border-radius: 4px;}\n";
  ptr +=".button-on {background-color: #1abc9c;}\n";
  ptr +=".button-on:active {background-color: #16a085;}\n";
  ptr +=".button-off {background-color: #34495e;}\n";
  ptr +=".button-off:active {background-color: #2c3e50;}\n";
  ptr +="p {font-size: 14px;color: #888;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<h1>ESP8266 Web Server</h1>\n";
  ptr +="<h3>Using Access Point(AP) Mode</h3>\n";
  
   if(led1stat)
  {ptr +="<p>LED1 Status: ON</p><a class=\"button button-off\" href=\"/led1off\">OFF</a>\n";}
  else
  {ptr +="<p>LED1 Status: OFF</p><a class=\"button button-on\" href=\"/led1on\">ON</a>\n";}

 /* if(led2stat)
  {ptr +="<p>LED2 Status: ON</p><a class=\"button button-off\" href=\"/led2off\">OFF</a>\n";}
  else
  {ptr +="<p>LED2 Status: OFF</p><a class=\"button button-on\" href=\"/led2on\">ON</a>\n";}
*/
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;
}

A Peltier cooler for a phone!! This sounds like a sledgehammer to crack a nut. Have you tried making a simple heat shield for the phone? Something like a polished aluminium shield, air-spaced away from the phone by a few millimetres, such that the sun cannot shine directly onto the phone.

It's better to protect the phone from overheating in the first place (if you can), than have a complicated system for cooling it and handling failures. Alternatively, try a different phone that is more tolerant of heat?

1 Like

Yip I agree it's a sledgehammer to solve a simple issue, but I have discovered that the phone battery climbs to 40-60c under load (music/maps) and in the sun it gets to the point where android shuts down the phone into cooling mode. And the peltier is just a way of drawing the heat out of the battery and dispersing it with a fan or 2. The peltier only runs for about 40 sec, acting as a heat pump, allowing the fans a 2 minute gap to disperse the heat. Keeps my phone below 39c under full load and in mid summer. Works well! Might have to train think the approach to the cooling solution.

1 Like