# :) my Relay output
# Relay  Example By NetmaxIOT  & Rohitkhosla
# OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla
# :)

# NOTE:
# 	Relay is both normally open and normally closed.
# 	When the coil is energised, they will both flip.
# 	LED will illuminate when normally open is closed (and normally closed is open).
import time
import Netmaxiot
# Connect the Netmaxiot SPDT Relay to digital port D4
# SIG,NC,VCC,GND
relay = 4

Netmaxiot.pinMode(relay, "OUTPUT")

while True:
    try:
        # switch on for 5 seconds
        Netmaxiot.digitalWrite(relay, 1)
        print("on")
        time.sleep(5)

        # switch off for 5 seconds
        Netmaxiot.digitalWrite(relay, 0)
        print("off")
        time.sleep(5)

    except KeyboardInterrupt:
        Netmaxiot.digitalWrite(relay, 0)
Beispiel #2
0
# :)

# retriggerable means the sensor will continue outputting high if motion was detected before the hold timer expires.
# non-retriggerable means the sensor will output high for the specified hold time only, then output low until motion is detected again.
# if there is constant motion detected, retriggerable will stay high for the duration and non-retriggerable will oscillate between high/low.

import time
import Netmaxiot

# Connect the Netmaxiot PIR Motion Sensor to digital pin 8
# NOTE: Some PIR sensors come with the SIG line connected to the yellow wire and some with the SIG line connected to the white wire.
# If the example does not work on the first run, try changing the pin number
# For example, for port D8, if pin 8 does not work below, change it to pin 7, since each port has 2 digital pins.
# For port 4, this would pin 3 and 4
pir_sensor = 8
motion = 0
Netmaxiot.pinMode(pir_sensor, "INPUT")
while True:
    try:
        # Sense motion, usually human, within the target range
        motion = Netmaxiot.digitalRead(pir_sensor)
        if motion == 0 or motion == 1:  # check if reads were 0 or 1 it can be 255 also because of IO Errors so remove those values
            if motion == 1:
                print('Motion Detected')
            else:
                print('-')
            # if your hold time is less than this, you might not see as many detections
        time.sleep(.2)
    except IOError:
        print("Error")
Beispiel #3
0
import time
import Netmaxiot

# Connect the Netmaxiot Light Sensor to analog port A0
# SIG,NC,VCC,GND
light_sensor = 0

# Connect the LED to digital port D4
# SIG,NC,VCC,GND
led = 4

# Turn on LED once sensor exceeds threshold resistance
threshold = 10

Netmaxiot.pinMode(light_sensor, "INPUT")
Netmaxiot.pinMode(led, "OUTPUT")

while True:
    try:
        # Get sensor value
        sensor_value = Netmaxiot.analogRead(light_sensor)

        # Calculate resistance of sensor in K
        resistance = (float)(1023 - sensor_value) * 10 / sensor_value

        if resistance > threshold:
            # Send HIGH to switch on LED
            Netmaxiot.digitalWrite(led, 1)
        else:
            # Send LOW to switch off LED
Beispiel #4
0
import Netmaxiot
import time

# Netmaxiot.pinMode(2,"INPUT")
# Netmaxiot.pinMode(5,"OUTPUT")
# Netmaxiot.pinMode(6,"OUTPUT")
# Netmaxiot.pinMode(7,"OUTPUT")
a = [2, 3, 4, 5, 6, 7]
i = 0
for i in range(0, 6):
    Netmaxiot.pinMode(a[i], "OUTPUT")
i = 0
while 1:
    for i in range(0, 6):
        print("LED ON ###############################")
        Netmaxiot.digitalWrite(a[i], 1)
        time.sleep(0.5)
        print("LED OFF ##############################")
        Netmaxiot.digitalWrite(a[i], 0)
        time.sleep(0.5)
# while 1:
# 	a=Netmaxiot.digitalRead(2)
# 	if(a==1):
# 		print "led on............."
# 		Netmaxiot.digitalWrite(5,1)
# 		time.sleep(0.2)
# 		Netmaxiot.digitalWrite(6,1)
# 		time.sleep(0.2)
# 		Netmaxiot.digitalWrite(7,1)
# 		time.sleep(1)
# 	else:
Beispiel #5
0
#!/usr/bin/env python
# ____________________________________________________
# :) My Buzzer Netmaxiot Sensor  interfacing
#  Buzzer By NetmaxIOT  & Rohitkhosla
# OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla
# :)
#----------------------------------------------------------------

import time
import Netmaxiot
# Connect the  Buzzer to digital port D8
# SIG,NC,VCC,GND
buzzer = 4
Netmaxiot.pinMode(buzzer, "OUTPUT")
while True:
    try:
        # Buzz for 1 second
        Netmaxiot.digitalWrite(buzzer, 1)
        print('start')
        time.sleep(2)
        # Stop buzzing for 1 second and repeat
        Netmaxiot.digitalWrite(buzzer, 0)
        print('stop')
        time.sleep(2)

    except KeyboardInterrupt:
        Netmaxiot.digitalWrite(buzzer, 0)
        break
    except IOError:
        print("Error")
import Netmaxiot
from time import sleep
pins = [2, 3, 4, 5, 6, 7]
for i in range(0, 6):
    Netmaxiot.pinMode(pins[i], "OUTPUT")
while True:
    for i in range(0, 6):
        Netmaxiot.digitalWrite(pins[i], 1)
        sleep(0.1)
        print i
    sleep(2)
    for i in range(5, -1, -1):
        Netmaxiot.digitalWrite(pins[i], 0)
        sleep(0.1)
        print i
    sleep(2)
#!/usr/bin/env python
# ____________________________________________________
# :) MY Netmaxiot Hardware Test interfacing library
#  HaRDWARE By NetmaxIOT  & Rohitkhosla   Tadaaaaaa
# OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla
# :)
#----------------------------------------------------------------

import time
import Netmaxiot

# Connect the Netmaxiot Button to Analog Port 0.
button = 14  # This is the A0 pin.
buzzer = 8  # This is the D8 pin.

Netmaxiot.pinMode(button, "INPUT")
Netmaxiot.pinMode(buzzer, "OUTPUT")

print("Netmaxiot Basic Hardware Test.")
print(
    "Setup:  Connect the button sensor to port A0.  Connect a simple Buzzer to port D8."
)
print(
    "Press the button on Netmax iot Shield and the buzzer will buzz tadaaaaaa!"
)
time.sleep(4.0)

while True:
    try:
        butt_val = Netmaxiot.digitalRead(
            button)  # Each time we go through the loop, we read A0.
from time import sleep
import Netmaxiot
Netmaxiot.pinMode(3, "OUTPUT")
Netmaxiot.pinMode(5, "OUTPUT")
Netmaxiot.pinMode(6, "OUTPUT")
i = 0
while True:
    print(i)
    Netmaxiot.analogWrite(3, i)
    Netmaxiot.analogWrite(5, i)
    Netmaxiot.analogWrite(6, i)
    i = i + 10
    sleep(0.2)
    if i > 255:
        i = 0
from time import sleep
import Netmaxiot
s1 = 5
s2 = 6
Netmaxiot.pinMode(s1, "INPUT")
Netmaxiot.pinMode(s2, "INPUT")
Netmaxiot.pinMode(2, "OUTPUT")
Netmaxiot.pinMode(3, "OUTPUT")
Netmaxiot.pinMode(4, "OUTPUT")
try:
    while True:
        x = Netmaxiot.digitalRead(s1)
        y = Netmaxiot.digitalRead(s2)
        if x == 0:
            Netmaxiot.digitalWrite(2, 1)
            Netmaxiot.digitalWrite(3, 1)
            Netmaxiot.digitalWrite(4, 1)
            sleep(0.2)
            Netmaxiot.digitalWrite(2, 0)
            Netmaxiot.digitalWrite(3, 0)
            Netmaxiot.digitalWrite(4, 0)
            print "Switch 1 pressed"
            sleep(0.2)
        elif y == 0:
            Netmaxiot.digitalWrite(2, 1)
            Netmaxiot.digitalWrite(3, 1)
            Netmaxiot.digitalWrite(4, 0)
            sleep(0.2)
            Netmaxiot.digitalWrite(2, 0)
            Netmaxiot.digitalWrite(3, 1)
            Netmaxiot.digitalWrite(4, 1)
Beispiel #10
0
import time
import Netmaxiot
x = 5
Netmaxiot.pinMode(x, "INPUT")
try:
    while True:
        lx = Netmaxiot.digitalRead(x)
        print "the value of our input is=%d" % lx
        time.sleep(0.2)
except IOError:
    print("Error")
#!/usr/bin/env python
#
import time
import Netmaxiot

# Connect the Netmaxiot Switch to digital port D3
# SIG,NC,VCC,GND
switch = 3

Netmaxiot.pinMode(switch,"INPUT")

while True:
    try:
        print(Netmaxiot.digitalRead(switch))
        time.sleep(.5)

    except IOError:
        print ("Error")
Beispiel #12
0
# MQ2 - Combustible Gas, Smoke
# MQ3 - Alcohol Vapor
# MQ5 - LPG, Natural Gas, Town Gas
# MQ9 - Carbon Monoxide, Coal Gas, Liquefied Gas
# 02 - Oxygen
# The sensitivity can be adjusted by the onboard potentiometer


import time
import Netmaxiot

# Connect the Netmaxiot Gas Sensor to analog port A0
# SIG,NC,VCC,GND

gas_sensor = 0
Netmaxiot.pinMode(gas_sensor,"INPUT")
while True:
    try:
        # Get sensor value
        sensor_value = Netmaxiot.analogRead(gas_sensor)

        # Calculate gas density - large value means more dense gas
        density = sensor_value*100 / 1023
        print "----------------------------------------------------"
        print " "
        print ("sensor_value =", sensor_value, " density =", density)
        print " "
        print "----------------------------------------------------"
        time.sleep(.5)
    except IOError:
        print ("Error")
Beispiel #13
0
#!/usr/bin/env python

# ____________________________________________________
# :) My  Button Netmaxiot interfacing 
# Button Example By NetmaxIOT  & Rohitkhosla
# OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla
# :)
#------------------------------------------------------------
import time
import Netmaxiot
# Connect the Netmaxiot Button to digital port D3
# SIG,NC,VCC,GND
button = 3
Netmaxiot.pinMode(button,"INPUT")
while True:
    try:
        print(Netmaxiot.digitalRead(button))
        time.sleep(0.2)

    except IOError:
        print ("Error")
Beispiel #14
0
import time
import Netmaxiot
from Adafruit_IO import Client
DELAY_TIME = 3
ADAFRUIT_IO_USERNAME = '******'
ADAFRUIT_IO_KEY = '65ba9a3ace5a45fd9aabb8083781f856'
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)
xlight = aio.feeds('light')
x1light = aio.feeds('light1')
x2light = aio.feeds('light2')
Netmaxiot.pinMode(2, "OUTPUT")
Netmaxiot.pinMode(3, "OUTPUT")
Netmaxiot.pinMode(4, "OUTPUT")
while True:
    mylightdata = aio.receive(xlight.key)
    print('Light', mylightdata.value)
    mylightdata1 = aio.receive(x1light.key)
    print('Light1', mylightdata1.value)
    mylightdata2 = aio.receive(x2light.key)
    print('Light2', mylightdata2.value)

    time.sleep(3)
    x = mylightdata.value
    x = int(x)
    x1 = mylightdata1.value
    x1 = int(x1)
    x2 = mylightdata2.value
    x2 = int(x2)
    if x == 1:
        print x
        Netmaxiot.digitalWrite(2, 1)
Beispiel #15
0
import Netmaxiot
from time import sleep
button = 5
button1 = 6

led = 2
led1 = 3
led2 = 4

Netmaxiot.pinMode(button, "INPUT")
Netmaxiot.pinMode(button1, "INPUT")
Netmaxiot.pinMode(led, "OUTPUT")
Netmaxiot.pinMode(led1, "OUTPUT")
Netmaxiot.pinMode(led2, "OUTPUT")
while 1:
    if Netmaxiot.digitalRead(button) == 0:
        Netmaxiot.digitalWrite(led, 1)
        Netmaxiot.digitalWrite(led1, 1)
        Netmaxiot.digitalWrite(led2, 1)
        sleep(0.1)
        print "1 on"

        Netmaxiot.digitalWrite(led, 0)
        Netmaxiot.digitalWrite(led1, 0)
        Netmaxiot.digitalWrite(led2, 0)
        sleep(0.1)

    elif Netmaxiot.digitalRead(button1) == 0:
        Netmaxiot.digitalWrite(led, 1)
        Netmaxiot.digitalWrite(led1, 0)
        Netmaxiot.digitalWrite(led2, 1)
Beispiel #16
0
#!/usr/bin/env python
# Netmax switch example with iot port good one :)

import time
import Netmaxiot

# Connect the Netmaxiot Switch to digital port D3
# SIG,NC,VCC,GND
switch = 3

# Connect the Netmaxiot Relay to digital port D4
# SIG,NC,VCC,GND
relay = 4

Netmaxiot.pinMode(switch,"INPUT")
Netmaxiot.pinMode(relay,"OUTPUT")

while True:
    try:
        if Netmaxiot.digitalRead(switch):
            Netmaxiot.digitalWrite(relay,1)
        else:
            Netmaxiot.digitalWrite(relay,0)

        time.sleep(.5)

    except KeyboardInterrupt:
        Netmaxiot.digitalWrite(relay,0)
        break
    except IOError:
        print ("Error")
Beispiel #17
0
#!/usr/bin/env python

import time
import Netmaxiot

button2 = 2
button3 = 3
button4 = 4
sensor0 = 0
sensor1 = 1
sensor2 = 2

Netmaxiot.pinMode(button2, "INPUT")
Netmaxiot.pinMode(button3, "INPUT")
Netmaxiot.pinMode(button4, "INPUT")

while True:
    try:
        print time.time(),
        d2 = Netmaxiot.digitalRead(button2)
        d3 = Netmaxiot.digitalRead(button3)
        d4 = Netmaxiot.digitalRead(button4)
        sensor_value0 = Netmaxiot.analogRead(sensor0)
        sensor_value1 = Netmaxiot.analogRead(sensor1)
        sensor_value2 = Netmaxiot.analogRead(sensor2)
        print("%d,%d,%d" % (d2, d3, d4)),
        print("%d,%d,%d" % (sensor_value0, sensor_value1, sensor_value2))
    except IOError:
        print("Error")
Beispiel #18
0
#!/usr/bin/env python

import time
import Netmaxiot
led = 5
Netmaxiot.pinMode(led, "OUTPUT")
time.sleep(1)
i = 0
while True:
    try:
        # Reset
        if i > 255:
            i = 0

        # Current brightness
        print(i)

        # Give PWM output to LED
        Netmaxiot.analogWrite(led, i)

        # Increment brightness for next iteration
        i = i + 10
        time.sleep(.2)

    except KeyboardInterrupt:
        Netmaxiot.analogWrite(led, 0)
        break
    except IOError:
        print("Error")
Beispiel #19
0
#!/usr/bin/env python

import time
import Netmaxiot

# Connect the Netmaxiot Line Finder to digital port D7
# SIG,NC,VCC,GND
line_finder = 7

Netmaxiot.pinMode(line_finder, "INPUT")

while True:
    try:
        # Return HIGH when black line is detected, and LOW when white line is detected
        if Netmaxiot.digitalRead(line_finder) == 1:
            print("black line detected")
        else:
            print("white line detected")

        time.sleep(.5)

    except IOError:
        print("Error")