Skip to content

Instantly share code, notes, and snippets.

View iotguider's full-sized avatar

Iotguider iotguider

View GitHub Profile
@iotguider
iotguider / Code_for_Reading_in_EEPROM.ino
Created May 15, 2018 13:33
Code for Reading in EEPROM
#include <EEPROM.h>
int a = 0;
int value;
void setup()
{
Serial.begin(9600);
}
void loop()
@iotguider
iotguider / Code_for_Writing_in_EEPROM.ino
Created May 15, 2018 13:32
Code for Writing in EEPROM
#include <EEPROM.h>
String a = "iotguider";
void setup() {
// put your setup code here, to run once:
for(int i=0;i&lt;a.length();i++)
{
EEPROM.write(i,a.charAt(i));
}
}
@iotguider
iotguider / Making_POST_HTTP_Requests_with_Python.py
Created May 14, 2018 17:16
Code for Making POST HTTP Requests with Python in Raspberry Pi
import requests
import json
url="http://example.com/index.php"
r = requests.post('http://example.com/index.php', params={'q': 'raspberry pi request'})
if r.status_code != 200:
print "Error:", r.status_code
@iotguider
iotguider / Making_GET_HTTP_Requests_with_Python.py
Created May 11, 2018 07:18
Code for Making GET HTTP Requests with Python in Raspberry Pi
import requests
import json
url="http://example.com/index.php"
r = requests.get('http://example.com/index.php', params={'q': 'raspberry pi request'})
if r.status_code != 200:
print "Error:", r.status_code
@iotguider
iotguider / Learn_interfacing_servo_motor_with_Raspberry_Pi.py
Created March 12, 2018 17:48
Code for interfacing servo motor with Raspberry Pi
import RPi.GPIO as GPIO # calling for header file for GPIO’s of PI
import time # calling for time to provide delays in program
GPIO.setmode (GPIO.BCM) # programming the GPIO by BCM pin numbers.
GPIO.setup(17,GPIO.OUT) # initialize GPIO17 as an output
servo = GPIO.PWM(17,50) # GPIO17 as PWM output, with 50Hz frequency
servo.start(0) # generate PWM signal with 7.5% duty cycle
servo.ChangeDutyCycle(7.5) # change duty cycle for getting the servo position to 90º
time.sleep(1) # sleep for 1 second
@iotguider
iotguider / Learn_interfacing_servo_motor_with_Arduino.ino
Created March 3, 2018 18:15
Code for interfacing servo motor with Arduino
#include <Servo.h>
// Create a servo object
Servo servo;
void setup() {
Servo1.attach(8); //Attaches servo to digital pin 8
}
void loop(){
// Make servo go to 90 degrees
@iotguider
iotguider / Learn_interfacing_DS3231_RTC_Module_in_ESP8266_WiFi_Module_NodeMCU.ino
Last active November 2, 2021 22:20
Code for interfacing DS3231 RTC Module in ESP8266 WiFi Module/NodeMCU
#include <Wire.h>
#include <RtcDS3231.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
RtcDS3231<TwoWire> Rtc(Wire);
ESP8266WebServer server(80);
const char* ssid = "ESPWiFi";
const char* password = "Password";
@iotguider
iotguider / Sending_SMS_from_Raspberry_Pi_using_Python.py
Created December 17, 2017 19:02
Code for Sending SMS from Raspberry Pi using Python
import RPi.GPIO as GPIO
import os
import sys
push_button = 23
led = 18
def setup():
GPIO.setmode(GPIO.BCM) # Numbers GPIOs by physical location
GPIO.setup(led,GPIO.OUT)
GPIO.setup(button,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
@iotguider
iotguider / Interfacing_Knock_Sensor_Module_KY-031_in_Arduino.ino
Created December 9, 2017 16:55
Code for Interfacing Knock Sensor Module KY-031 in Arduino
int Led = 13 ;// define LED Interface
int knockmodule = 2; // define the vibration sensor interface
int val; // define numeric variables val
void setup ()
{
pinMode (Led, OUTPUT) ; // define LED as output interface
pinMode (knockmodule, INPUT) ; // output interface defines vibration sensor
}
@iotguider
iotguider / Interfacing_Vibration_Switch_Module_KY-002_in_Raspberry_Pi.py
Created December 7, 2017 13:36
Code for interfacing Vibration Switch Module KY-002 in Raspberry Pi
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
sensor = 17
led = 27
GPIO.setup(sensor, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(led, GPIO.OUT)