إرسال قراءات المستشعر باستخدام POST
أرسل بياناتك إلى نقطة نهاية في الواجهة الخلفية.
إرسال قراءات المستشعر باستخدام POST درس مجاني في Arduino & IoT Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Arduino & IoT Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Now You Send Data Out
GET pulls data in. To push your sensor readings up to a server, you use a POST request instead. 📤
GET vs POST
A GET asks for data, while a POST sends a body of data to the server to create or store something new.
Same Setup as GET
You still create an HTTPClient and call begin() with the endpoint URL. Only the sending step changes for a POST.
HTTPClient http;
http.begin("http://api.example.com/readings");Build a Payload
Decide what to send. A small JSON string holding your readings is a clean, standard way to package the data.
String body = "{\"temp\":24.5}";Tell the Server the Type
Set a Content-Type header so the server knows your body is JSON. Without it, the server may misread your data.
http.addHeader("Content-Type", "application/json");Send with POST
Call POST() and pass your body. It returns a status code just like GET did, so you can confirm it worked.
int code = http.POST(body);Confirm It Was Stored
A 200 or 201 means the server accepted your data. 201 specifically means a new record was created.
if (code == 200 || code == 201) {
// stored
}Read Any Reply
Servers often reply to a POST too, maybe an id or a confirmation. Read it with getString() if you need it.
String reply = http.getString();Close the Connection
As always, call end() after a POST to release the connection and keep your board healthy for the next send.
http.end();Send on a Schedule
You rarely POST every loop. Read a sensor, then upload once every few seconds or minutes to save power and bandwidth.
Match the Server Shape
The server expects fields in a specific format. If your JSON keys or types are wrong, it will reject the reading.
Quick Check
You are sending a JSON body to your backend. Which request method fits?
Recap
You packaged readings as JSON, set the Content-Type header, sent them with POST(), checked the code, and closed up. Your data is in the cloud. 🎉
الأسئلة الشائعة
هل درس «إرسال قراءات المستشعر باستخدام POST» مجاني؟
نعم — نص درس «إرسال قراءات المستشعر باستخدام POST» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Arduino & IoT Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Arduino & IoT Academy 4 دروس في المجموع.
ماذا ستتعلم في «إرسال قراءات المستشعر باستخدام POST»؟
أرسل بياناتك إلى نقطة نهاية في الواجهة الخلفية. تتمرن على Arduino & IoT Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Arduino & IoT Academy؟
لا تُشترط خبرة سابقة. Arduino & IoT Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.
كم من الوقت يستغرق درس «إرسال قراءات المستشعر باستخدام POST»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Arduino & IoT Academy هذا؟
نعم. كل درس في Arduino & IoT Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- جلب البيانات من API باستخدام GET
- إرسال قراءات المستشعر باستخدام POST
- تحليل استجابات JSON
- استخدام HTTPS بأمان