Skip to content

Instantly share code, notes, and snippets.


sarasantos/zapier_request Secret

Last active Nov 9, 2020
What would you like to do?
#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "YOUR-SSID";
const char* password = "PASSWORD";
//Your Domain name with URL path or IP address with path
const char* serverName = "";
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;
void setup() {
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println("Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.");
void loop() {
//Send an HTTP POST request
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
// Your Domain name with URL path or IP address with path
int number = random(10);
// Specify content-type header
//http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Data to send with HTTP POST
//String httpRequestData = "Test1="+String(number)+"&Test2=49.54";
// Send HTTP POST request
//int httpResponseCode = http.POST(httpRequestData);
// If you need an HTTP request with a content type: application/json, use the following:
http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.POST("{\"Time\":\"12:24\",\"OutsideTemp\":\"12\",\"T9.0\": \"12.1\",\"Th9.0\":\"30\",\"H9.0\": \"90%\",\"T9.1\":\"13\",\"H9.1\":\"80\",\"9.1Weight\":\"67.03\"}");
// If you need an HTTP request with a content type: text/plain
//http.addHeader("Content-Type", "text/plain");
//int httpResponseCode = http.POST("Hello, World!");
Serial.print("HTTP Response code: ");
// Free resources
else {
Serial.println("WiFi Disconnected");
lastTime = millis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment