The pain points of shared study rooms are very clear: the door has to be opened when someone comes, a reminder comes when someone arrives, and the power is cut off when someone leaves. If the voice notification can be connected to your reservation system, it can save an administrator's labor. Thingboot's interface uses standard HTTP, so there is no need to mess with hardware protocols. The connection ideas are as follows.
Hello everyone!Recently, I was tinkering with a shared study room project, and found that many friends who create study rooms have a pain point:The power is not turned off after someone leaves, the phone is still lingering there when the time comes, or a new user has made a reservation and doesn’t know how to open the door..
The traditional method is to ask an administrator to shout there, but what we want to build an "unattended" study room is automation and a sense of technology.
Today let’s talk about something practical,Let me share step by step how to connect Thingboot’s "smart voice speaker 1" to our own study room system., realize fully automatic voice broadcast. As long as you can adjust the HTTP interface, this matter can be done in minutes.
Special note: Because we are using "Smart Voice Speaker 1", theHTTP protocol, so whether your backend is Java, Python or PHP, even if you write a front-end script, you can adjust it directly, which is very flexible..
Step One: Preparation - You have to get these three things first
Before writing code, let's go to Thingboot's backend to do some preparation work, just like you have to prepare the dishes first when cooking.
Register an account and log in: Go to Thingboot official website to register an account.
Get keys (AppID and AppSecret): After logging in, find "Development Settings" in the background. These two things are equivalent to your "account password", and you will need to bring them with you when you call the interface later.
Add device: Add our "Smart Voice Speaker 1" distribution network to your account. After the network configuration is successful, you will see aDevice ID(usually a string of numbers). Write down this ID, that is the "soldier" you want to command.
Core technical parameters
Before starting, there is a small detail that needs to be clarified:Signature calculation methodyesmd5(md5(AppSecret) + ts). Here'stsIt is a timestamp in seconds. Thingboot uses this mechanism to prevent the interface from being called maliciously, so your code must generate signatures according to this rule.
Step 2: Core logic - what instructions should I send to it?
Many novice friends think that the Internet of Things is difficult, but it is actually not that mysterious.The so-called "voice broadcast" essentially means that you use your computer/server to send it an express (HTTP request).
For "Smart Voice Speaker 1", the most commonly used command (Order) format is as follows
Ordinary broadcast:
{"play:gbk:16":"what you want to say"}scene: When someone takes a seat, shout "Welcome"; or remind "It's time to renew".
Announcement with a prefix ringtone:
{"play:gbk:6":"what you want to say"}(The numbers represent different beep IDs)scene: When the time is almost up, please "ding dong" first before speaking. The reminder effect will be better.
adjust volume:
{"volume":"5"}(Level 0-9, the bigger the number, the louder)
Step 3: Practical drill - how to answer it specifically?
Let's take "The user scans the QR code to select a seat and pays successfully"Take this scenario as an example. We hope that after the user successfully pays, the loudspeaker in the study room will immediately shout: "New order, seat X has been reserved, please check your seat."
Assume you have obtained the following parameters:
AppID:
123456AppSecret:
abc123Device ID:
LB001What to report: "New order, seat 8 has been reserved, please check your seat"
1. Calculate the signature first (Sign)
This step is a bit convoluted, but just follow the formula.Assume the current timestamptsyes1712345678
Calculate first
md5(AppSecret):md5('abc123')=e99a18c428cb38d5f22e03...(hypothetical value)Splice the above results with timestamp:
e99a18c428cb38d5f22e03...+1712345678Do this again with this long list
md5, get the finalsign.
2. Spell URL and Body
Request address:
https://api.thingboot.com/123456/device/control/?sign=Fill in the sign&ts you calculated here=1712345678Request method:
POSTRequest body (Body)
3. How to write the code? (Pseudocode example here)
Because no matter what language is used, the logic is the same.
If you are using Java:
If you are using Python:Even WeChat mini programs have the same principle, that is, just send out the HTTP request above..
As long as the server returns successfully, that familiar voice will ring in your ears.
Step 4: Advanced gameplay - making the study room smarter
Just shouting "Welcome" is not enough. We can dig deeper into the interface capabilities to take the study room experience to the next level.
1. Create the "arrival reminder" function
Many study rooms charge by the hour. If the user doesn't renew when the time is almost up, you can't pat him on the shoulder, right? Let the trumpet shout!logic: Your system polling detects "10 minutes left for order A".instruction{"play:gbk:6":"Dear user, you have 10 minutes left to study, please renew in time."} .The prompt ID is used here6, which can serve as a good reminder without being too noisy..
2. Administrator/cleaning reminder
Sometimes the cleaning lady needs to clean a certain location, or remind a user not to make loud noises.You can make a "low-key" internal management page.scene: The administrator clicks "Remind Seat 3" on the mobile phone.instruction{"play:gbk:16":"Students in seat 3, please keep quiet. Thank you for your cooperation."} .This eliminates the need to go in and knock on the door, and avoids the embarrassment of face-to-face reminders.
3. Combined with access control/power outage control
"Smart Voice Speaker 1" is essentially a controllable device. In addition to making it talk, you can also give it other commands. For example, combined with the withdrawal logic:scene: When the user clicks "Quit", the system will send a voice message first.{"play:gbk:16":"Thank you for your use. Please bring your belongings with you."}, and then immediately send a power-off command{"power":0}Turn off the socket for that seat. This enables complete automation.
Summarize
The entire docking process is actually a"Backend adjustment interface"work.
Low threshold: There is no need to understand hardware circuits or flash firmware. As long as you can adjust the HTTP interface, you can play with this speaker.
Fast response: According to actual measurements, from order placement to broadcast, the delay is basically at the millisecond level, and the user experience is very good..
stability: The device is directly connected to Wi-Fi. As long as the network in the study room is uninterrupted, it will always be on standby.
Everyone, go back and give it a try. If you integrate these lines of code, your study room system will instantly have the ability to "voice interaction" and it will instantly feel much more advanced! If there is anything you don’t understand, please feel free to share it in the comment area.