Ideas for remote monitoring/control system over 4G

Hello,
I am brainstorming a system that would allow monitoring a remote cabin in Montana. The site has good cell reception. I envision a system using a mega that can, upon request, send data on temperature, battery bank voltage, etc. Data would be floats and ints, and bandwidth is not a consideration, nor latency. I'd also like it to be able to control some relays to do various things. Video and audio would be nice, but not necessary. In your opinion(s), what would be the best way to accomplish this? Ideally, I'd like to use an Android phone to send and receive the data.

1 Like

Programming an Arduino to send data from a remote location via a GSM module is a popular project. A search phrase like "arduino GSM remote data transmission" will turn up many examples.

For photo and sound transmission via the cell network from a remote location, solar powered security cameras can be purchased fairly cheaply on line.

Turning the process around, i.e. to call the module and have an Arduino execute remote tasks considerably increases the complexity of the project.

Thank you. I am perusing some tutorials now. I'll be back if I have some more specific questions.

check the specification of the 4G modem module
many modern modems use 3.3V logic the Mega uses 5V logic so level converters will be required
it may be worth going for a module with microcontroller and modem on the same PCB, e.g. Lilygo T-SIM7600E/G/SA-H - saves interconnecting wires with the associated problems of poor connections and intermittent problems

use a "small" 4G router, then you can connect "anything" you want. You can start with a ESP32 relayboard, add an IP webcam later or any LAN/Wifi based component off the shelf later on.

1 Like

hi i am new here

Thank you all for the suggestions. There is so much to go through! It looks like a 4G router may be the way to go for what I need. I can see so many ways this can be useful.

Ok, so I'm getting there, but have run into a weird problem that I can't find a reason for.
I have the following function, adapted from this site.

void CheckInternet()
{ 
  EthernetClient client = server.available();  
  if(client)
  {               
    while(client.connected()) 
    {         
      if(client.available())
      {
        char c = client.read();
        if (readString.length() < 100) readString += c;      
        if (c == '\n') 
        {
           client.println("HTTP/1.1 200 OK"); 
           client.println("Content-Type: text/html");
           client.println();                
           client.println("<HTML>");
           client.println("<HEAD>");
           client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
           client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
           client.println("<TITLE>Arduino Fan control switch</TITLE>");
           client.println("</HEAD>");
           client.println("<BODY>");
           client.println("<H1>SunTracker Control</H1>");
           client.println("<hr />"); 
           client.println("<hr />"); 
                 
           client.print("<H2>Battery Bank Voltage:  ");
           client.println(volts);
           client.print("  Volts");
           client.println("<br />"); 
                    
           client.print("<H2>Charging Amps:  ");
           client.println(amps);
           client.print("  Amps");
           client.println("<br />"); 
                     
           client.print("<H2>Battery Temperature:  ");
           client.print(battTemp);
           client.print("  Degrees F");
           client.println("<br />"); 
           client.println("<br />");
           client.println("<hr />");  
                
           client.print("<H2>Inverter ");
           client.println("<a href=\"/?on\"\">Turn on</a>");
           client.println("<br />");            
           
           client.print("<H2>Inverter ");
           client.println("<a href=\"/?off\"\">Turn off</a>");
           client.println("<br />"); 
          
           client.println("<H2>Inverter is: ");
           if(inverterOnFlag == false) client.println("<H2>Off");
           else if(inverterOnFlag == true) client.println("<H2>On");
           client.println("<br />");
           client.println("<br />");  
           client.println("<hr />");    
           client.println("</BODY>");
           client.println("</HTML>");     
           delay(1);
           client.stop();
           if (readString.indexOf("?on") > 0) 
           {
            inverterOnFlag = true;  
             digitalWrite(INVERTER_CONTROL, HIGH); 
             mySerial.print('2'); 
             Serial.println(" Inverter On");              
           }          
           if (readString.indexOf("?off") > 0) 
           {
            inverterOnFlag = false;  
             digitalWrite(INVERTER_CONTROL, LOW);
             mySerial.print('3'); 
             Serial.println(" Inverter Off");            
           }               
             readString="";            
         }
       }
     }
   }
}

The problem is that it works fine for an hour or so (not sure of the exact time), then the site freezes, and I have to restart the server. I vaguely recall a similar problem a few years ago on a tengentially-related project. Does anyone have any idea where I should be looking for the issue?

1 Like

Hello JohnDeere630

Check this:

Using the String class on a board with little memory can cause memory problems if not used carefully. See the evils of arduino Strings for why.

The Evils of Arduino Strings | Majenko's Hardware Hacking Blog

1 Like

@paulpaulson,
I bet you're right. This sketch uses ~70% of the memory. The problem is I have no idea how to get rid of the String class and use a char array, or even if it is possible. Any suggestions?

I think I found a method that gets rid of the String class....

when you really want to use an 8bit AVR controller like an UNO check my proposal of a webserver without String objects:

it should be running stable longer than 42 days.

@noiasca,
Thank you. That's a lot of good information there. It's going to take me a while to go through that.

If I was designing this system, I would put a sequential number in each message sent and have the remote include the number of the last message received in responding with data.

One of many tutorials on using the C-string functions.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.