CATALOG

The pain point of power management for shared massage chairs is "the power must be controlled when no one is present". Using Thingboot's open interface to connect to a 25A remote control circuit breaker actually involves three steps: getting the device online, adjusting the interface, and connecting the business logic in series. Next, I will explain to you clearly how to take each step and what pitfalls you need to pay attention to according to the actual development sequence.

1. Why do you have to use a remote control circuit breaker?

The business of sharing massage chairs seems to be about making money while lying down, but in fact it is "with the intention of selling white powder". It is impossible for operation and maintenance personnel to be around 24 hours a day. If a chair in a certain venue is maliciously occupied, or the equipment is stuck, the traditional method has to send someone to run over and unplug the plug, and the cost is too high.

At this time, the 25A remote control circuit breaker comes in handy. It is equivalent to installing aSwitch that can be toggled remotely. Once the system detects an abnormality, just click "Power off" in the background, wait a few seconds and then "Power on", which is equivalent to a physical restart and the problem is solved.

And the function of Thingboot is that"telephone line". It connects the circuit breaker to your software project, so that you don’t need to understand the hardware circuit. Just like calling the Alipay interface, you can send a command to cut off the power.

2. Core preparation work (don’t step into pitfalls)

Before typing the code, there are three things that must be confirmed at the hardware level, otherwise it will be useless to adjust the interface:

  1. Confirm device model: That circuit breaker in your hand must be4G versionorInternet versionof. The one that only supports Bluetooth connection will not work. You must have a unique device ID to register to the Thingboot backend.

  2. Wiring (important!): A 25A circuit breaker is generally connected in series to the main circuit. Remember, it controlsLive line. If the wrong wires are connected, the circuit breaker goes out, and the chair is still powered, then this solution will be in vain. If you are really not sure, ask an electrician to take a look and spend dozens of dollars to buy safety.

  3. Backend registration: Power on the circuit breaker. In the developer backend of Thingboot, you can see that it is in "online" status.

3. Practical practice of software docking (three steps)

Here we take the open interface of Thingboot as an example. Assuming that you use Java/PHP/Python to write the backend, the specific process is the same.

Step 1: Get the key (Sign algorithm)

Thingboot's interface security is good. You have to calculate the signature first, otherwise the server will not recognize it.

  • formulasign = md5(md5(your AppSecret) + ts)

  • Practical exercises

    1. Assume yourAppSecretyesabc123.

    2. Calculate MD5 first:md5(abc123)Get string A.

    3. plus current timestampts(such as 1712345678), becomes the string A + 1712345678.

    4. Calculate MD5 for this combination again.

    5. Notice: It is very easy to make mistakes here. Directly copying the official Demo is the most stable. Do not splice strings by hand..

Step 2: Issue the "power off/power on" command (core code)

This is the most core step. It is equivalent to clicking the "off" button in the software, and the circuit breaker will actually trip with a "click".

Interface information:

  • addresshttp(s)://api.thingboot.com/{your AppID}/device/control/

  • method:POST (recommended)

How to fill in the request parameters (key):

  • device (device ID): Go to the background to copy, usually pure numbers without letters.

  • order: This is the core. You need to check the 25A circuit breakerProduct function definition. Generally speaking:

    • Want it to be electrified: pass{"power": 1}

    • Want it to power off: Pass{"power": 0}

    • If you want to check the data with current detection: send{"current": null}.

For example:Suppose there is a switch button in your software. If the user does not pay, you want to turn off chair 1.

At this time, if the status code you return is200, indicating that the platform has received the instruction and sent it.

Step 3: Deal with the "no response" problem

Many novices crash here: the interface obviously returns 200, but the circuit breaker doesn't move.reason: 200 only means that the command was sent to the cloud, not that the device received it (the device may be disconnected or offline).

Solution:Must use core stepPush messageFunction.

  1. Configure a callback URL on your server.

  2. After you issue the command and the device executes successfully, it will proactively send a notification to your server: "Report to the boss, my power has been cut off."

  3. Your software logic should be: Issue a command -> wait for callback notification (for example, set a 5-second timeout) -> success will only be considered when a confirmation notification is received. If no notification is received, the interface displays "The device is offline and the operation failed."

4. Don’t forget to do these three layers of insurance logic

Light energy remote switch is not enough. For shared projects, we need to"Fool-proof"The mechanism is adequate:

  1. Time lock (automatic recovery after timeout)Suppose you cut off a user's power because he timed out, and he complained in anger. You have to hard-code it into the software:"Automatically restore power after 5 minutes of power outage". This not only punishes malicious occupation, but also does not affect the next user's experience.

  2. Heartbeat detection (automatic restart)Obtain the circuit breaker through the polling interfaceCurrent value. If you find that the current of the device suddenly becomes 0 (not during a power outage), it means that the fuse inside the chair is burned out or the wiring is loose; if you find that the current is abnormally high but the motor does not rotate, it may be stuck. At this time, the system automatically triggers a restart command, which can often revive the stuck chair..

  3. Physical tamper protectionEven though you're using software control, a bad guy could just press the physical button on the circuit breaker.During docking, call the interface to obtain the circuit breaker'sCurrent status. If the software shows "power on" but the physical switch status you read is "off", the system should immediately call the police - someone wants to have sex for nothing!

5. Summarize

Connecting the 25A circuit breaker to the core step is actually just one sentence:Replace manual labor with HTTP requests.

  • to users:Scan QR code to pay -> callpower upsInterface->Chair Startup.

  • to operations:Monitor exception->callpower outageInterface->wait 5 seconds->callpower upsInterface (restart completed).

Two little ones for you:

  1. testing phase: First connect the circuit breaker to a desk lamp or electric fan for testing. Do not connect it directly to 380V power. Safety first.

  2. read log: Thingboot’s backend hasDevice log, if the command cannot be sent, go there to check "offline" or "timeout". It is very fast to locate the problem..

After this solution is put into operation, you will find that the operation and maintenance efficiency has been greatly improved. Sitting in the office, you can turn on the power grid of the whole city. The sense of control is still very solid.