Unmanned vending machines are usually deployed in outdoor or semi-outdoor environments. Remote monitoring and fault warning of lighting equipment are urgent pain points in operation. Next, I will combine Thingboot’s open interface capabilities to write a practical solution.
Background and pain points
Let’s first talk about why this is worth doing. There are usually many ways of lighting in unmanned vending machines: shelf lights on the product display floor, ambient lights at the pickup port, and sign light boxes outside the cabinet. After all, 12-way lighting equipment is actually very common.
Where is the pain point? Think about it, if a certain street light is broken (for example, the middle display light does not light up), the glass window of the machine will be pitch black at night, and users will not be able to see the products clearly, and sales will be directly affected. The traditional method either waits for operation and maintenance personnel to conduct regular inspections before discovering it, or waits for user complaints. This is very passive.
Our goal is to:Realize remote status monitoring of 12-channel lighting equipment through Thingboot’s intelligent hardware and open interfaces——Whether the current of each street lamp is flowing, whether the lamp tube is burned out, and whether the relay is stuck can be clearly seen in the background.
Hardware selection
To achieve 12-channel control and monitoring, one controller alone is not enough. Here are two combination options, depending on your vending machine internal space and cost budget:
Plan A: Cascading plan (recommended, cost-effective)
use3 Core Steps "Intelligent Controller 4 Ways"cascade.
Why 3? Because this controller happens to have 4 outputs. 3 in series, exactly 12 channels.
Each controller supports WiFi 2.4G networking, so there is no need to buy an additional gateway.
The rated current of each channel is Max 10A, which is more than enough to carry lights and even small compressors.
focus: This controller hasindicator lightandstatus feedbackFunction. If the indicator light is always on, it means power is on; if it goes off, it means power is off.. What we want is this "status" data.
Plan B: Industrial module plan (suitable for high-end models)
Use third-party 12-channel intelligent lighting module (Modbus-RTU protocol)+ Thingboot 4G gateway.
This module has its own current detection function, which can measure the specific current value of each channel (such as 0.25A or 0A).
Connect to Thingboot's gateway through the RS485 line, convert the data into JSON format and push it to the cloud.
colloquial: If you just want to see "on/off", option A is enough, and the wiring is simple; if you want to see the "aging degree of the lamp" (current dropped from 0.5A to 0.2A), choose option B.
Interface integration logic
Thingboot’s open interface logic is very clear and consists of two main steps:Control deliveryandStatus reporting.
1. How to issue commands (turn on/off lights)
When you want to remotely turn off the 3rd light in the background, callDevice control interface.
According to the official documentation, you need to askhttp(s)://api.thingboot.com/{AppID}/device/control/Send request.Here’s a little trick: If you are using the three cascaded controllers, be sure to fill them in correctly.deviceparameter.
Request example (control the opening of channel 2 of the first controller):
Let me explain here. The document mentions that if you want to pass complex commands to the device, it is best to usePOSTway, and inorderinside biographyJSON. If you are worried about network packet loss, you can alsoorderRigaextraThe order number is included in the field to facilitate subsequent reconciliation.
2. How to obtain status (the core of "monitoring")
This is our focus today. What you want is not to "issue a command", but to "confirm that the light is really on."
Thingboot platform has two ways to obtain status. Monitoring must useThe second kind
Method 1: Synchronous return (not recommended for status monitoring)After issuing the command, the interface returns 200, but the document clearly states:"200 only means that the platform has received the command...the device may be offline". In other words, if you tell it to turn on the light, it will say "command received", but it will not care if the light cord is broken.
Method 2: Asynchronous message push (this is what we want!)When the device status really changes (for example, you press a physical button, or the light burns out and reports offline), the device will actively report the status.
You need to set up a receiving address (Webhook) on your own server, or use MQTT to subscribe to the topicapi/{AppId}/message/state.
The JSON structure actively reported by the device is as follows:
Actual combat logicIf you click "Turn off lights" in the background, thendatashould receive it"power": "0".if you receive"power": "1", that meansRelay stickingIf the light is not turned off, the alarm should be triggered to notify maintenance.
Specific implementation configuration of 12-channel monitoring
Suppose you have 12-channel lights, we need to give it a name to prevent confusion.
device mapping
In the background of Thingboot, name the three controllers respectively.
Light_Module_01(Corresponding to No. 1-4),Light_Module_02(Corresponding to No. 5-8),Light_Module_03(Corresponding to routes 9-12).Record the uniqueness of each device
DeviceID.
Data processing logic (the code you need to write on the backend)You need to create a status table to record the latest status and last update time of each channel.
lighting channel Associated device ID Status KEY Current status Last heartbeat time decision logic Shelf light 1 ID_01 power1 1 10:00:01 normal Shelf light 2 ID_01 power2 1 09:30:00 Alarm (not reported for more than 1 hour) ... ... ... ... ... ... Heartbeat keep-alive mechanismEven if the light does not change, the machine should report the heartbeat regularly. If a certain channel does not send any message to the background for more than a certain period of time (such as 5 minutes), you should suspect that the power supply module of this channel has crashed, or the communication module has dropped offline.
Tips for actual wiring scenarios
After talking about the code, let’s talk about some real on-site construction experience.
What is used in unmanned vending machines12V/24V LED light stripThere are many, but the 4-way controller of Thingboot is220V ACOutput.Never connect the LED light strip directly, it will burn!
The correct connection method should be:220V mains power -> controller -> switching power supply (12V) -> LED light strip.
Because the controller is only responsible for "on and off" and controls the input end of the switching power supply. This not only protects the light strip, but also allows us to know whether there is a short circuit at the rear end through the feedback of the switching power supply. The "power status" you want to monitor is actually monitoring whether there is power coming from the 220V side.
Summarize
The benefits of using Thingboot to do it are visible to the naked eye:
Remote fault location: There is no need to send people to the scene to turn on the lights one by one and check the lights. The background log directly showed "The 5th channel lighting feedback is abnormal". The operation and maintenance guy directly brought the accessories and replaced them, and it was done in one go.
Energy saving in business: You can create a scheduled task through the interface. For example, when the passenger flow is low from 2 a.m. to 5 a.m., a command is issued through the interface to turn off half of the display lights; they will be turned on automatically at 6 a.m. This kind of instruction is passed through the core step
scheduled tasksFunctions can be configured in the cloud.Strong scalability: Thingboot’s interface not only controls lights, but also supports sensor linkage.. In the future, you can add a body radar sensor to the machine, which will automatically brighten the lights when someone approaches (send instructions through the interface), and dim the lights when someone leaves. This will have a great power saving effect.
Following this idea, the lighting system of unmanned vending machines can be transformed from "silly light" to "intelligent brain", saving both electricity bills and manual inspection costs.