Automatic Router Resetter, Made by OpenAI.

by giano2002 in Circuits > Wireless

333 Views, 3 Favorites, 0 Comments

Automatic Router Resetter, Made by OpenAI.

20230306_141811.jpg
20230306_141853.jpg
20230306_142149.jpg
20230306_141936.jpg
20230306_142215.jpg

A project written by openAI.

This project should be useful for automatically restarting a modem/router which, for various reasons, could lose the network or wifi connection with the devices connected to it. This project is particularly suitable for those who are far from the modem/router and cannot intervene promptly to reset it.

Supplies

1 ESP8266 NodeMCU;

1 relay 5 V dc;

1 LM7805;

1 4N35 optocoupler;

1 2N2222 transistor NPN;

1 1N4007 diode,

2 1 K resistors;

1 10 K resistor;

1 510 resistor;

1 LED.

How It Works

Many use a modem/router installed away from their usual home or office, to manage surveillance systems or weather stations, or something else. In such situations, it may happen that, for various reasons, the modem/router disconnects from the network, or loses connection to connected devices, with easily imaginable consequences.

In order to restore the connections, a simple reset could be useful. And if you're not on site, this project might solve the problem.

Indeed, the ESP8266 board connects to the WiFi network and checks that there is an Internet connection, pinging www.google.com every 40 seconds. If there is no network or if there are no ping replies seven consecutive times, the relay is activated, which switches off the modem/router connected to it for 15 seconds and then switches it back on.

In this way, if there are no failures in the network or in the modem/router itself, the reset should serve to restore all connections.

To carry out this project I wanted to test the openAI artificial intelligence service, to which I made the following request:

"Write a code for ESP8266 that should connect to a wi-Fi network, blink a led while connecting, and start pinging www.google.com every 40 seconds. If there is no connection for 5 minutes or if no answer after 7 ping consecutives attempts, a relay will be powered on for 15 seconds before the cycle restarts. The LED on pin D4 will also indicate the Wi-Fi connection status."

The code generated promptly by openAI worked right away. I only had to make small corrections, to the lines that manages the switching on the LED and the relay, to change in HIGH, where was indicated in LOW, and vice versa, to be able to adapt the code to the scheme (that is attached) I adopted to connect the ESP8266 board to the relay.

Based on the tests I carried out, both by disconnecting the optical fiber from the modem (thus losing the internet connection) and by turning off the WiFi, the circuit worked correctly, turning off the modem after about 5 minutes of no WiFi or a few minutes of lack of Internet network and turning it on again after 15 seconds, restarting all the connections and reconnecting the various devices.

The ESP8266 board LED flashes when it is searching for the WiFi network and remains lit when it is connected to the WiFi, while it turns off if there is no connection.

The 12 V dc power supply of the modem/router must be connected to the input of this device and then the modem/router is powered from the output of the device. The relay is normally "off" and thus passes power to the modem. Only when the relay is powered (and this happens if the resetter does not find connection) does it cut power to the modem for 15 seconds and then restore it.

I hope that someone more experienced than me can make this project and test it thoroughly, to understand if there are any bugs, or design flaws and can thus improve it.

It is not obvious that artificial intelligence can write code without making mistakes.