三瓶可乐不过岗

三瓶可乐不过岗

| ω・´) 可乐的文章在这里 threkork.me
github
pixiv

Make a small UPS by yourself.

Recently, due to personal needs, there is a device in the dormitory that needs to be connected to the internet 24 hours a day, so I came up with the idea of making a homemade UPS to provide uninterrupted power supply to the dormitory WiFi.

All the components and materials are readily available, so it is very easy to DIY. The only thing needed is simple soldering.

  • One UPS module
  • Depending on the requirement, buy several 18650 batteries
  • One power adapter with output power greater than charging and power supply
  • Wires
  • A set of soldering iron tools

Since the WiFi device in my dormitory is a combination of optical modem and router, it requires an input of 12V 1.5A. Although the actual power consumption is not that high, in order to prevent the UPS module from overheating due to high load, I had to purchase a slightly more expensive 24W version.

For a regular router, even 5W power is sufficient, so there is no need to buy such a large one. Depending on the actual needs, it is better to purchase one with lower output power, which is also cheaper.

Oh, and this UPS module comes with battery protection.

The total cost of the main components for me is: UPS module 24 + four batteries 36 + battery box 10 = 70, while the rest are surplus. If I have to calculate, it's a lot, so let's deceive myself a little.

This module requires two batteries to be connected in series, you can refer to the introduction diagram on a certain online marketplace. So I used two parallel battery packs.

By the way, connecting batteries in parallel increases capacity, while connecting them in series increases voltage.

First, connect the power adapter and output, then connect the wires, and finally connect the batteries. Just follow the diagram and solder them.

Finally, it's done.

Waiting for the red light to turn green...

In short, it's a very simple thing.

In terms of calculation, these two battery packs can last for at least 2.6 hours. If you want to test it, the best way is still to actually measure it.

Recently, I learned Rust, so I wrote a ping program in Rust to see how long this UPS can last.

use chrono::Local;
use rand;
use reqwest::Client;
use std::fs::File;
use std::io::Write;
use std::thread::sleep;
use std::time::Duration;
use tokio;

async fn check_internet_connection() -> bool {
    let client = Client::new();

    let response = client.get("https://www.baidu.com").send().await;
    let foo: bool;
    match response {
        Ok(_response) => foo = true,
        Err(_error) => foo = false,
    }
    foo
}

#[tokio::main]
async fn main() {
    let path = "time_log.txt";
    let mut output = File::create(path).unwrap();
    writeln!(output, "wait start:)").unwrap();

    loop {
        let mut rng = rand::thread_rng();
        let duration = Duration::from_secs(rand::Rng::gen_range(&mut rng, 60..180));
        let local_time = Local::now();
        if check_internet_connection().await {
            let txt = local_time.to_string() + ": true";
            writeln!(output, "{}", txt).unwrap();
        } else {
            let txt = local_time.to_string() + "::false::\n:(";
            writeln!(output, "{}", txt).unwrap();
            break;
        }

        sleep(duration);
    }
}

I found that it can easily last until the dormitory loses power and the internet is disconnected, with more than enough battery power.

That's all, the end.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.