def myfunction(): humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) x = se.get_temperature() x = round(x, 2) sensorValue = Netmaxiot.analogRead(led) print("the value from adc is %d" % sensorValue) volt = sensorValue * 4.887 print("--------------------------------") print("the value of volt is %0.3f" % volt) light = volt / 5000 light = light * 100 print('light is %d' % light) print x print humidity print temperature time.sleep(3) payload = { 'mytemp': temperature, 'myhumdity': humidity, 'Dht': x, 'light': light } return payload
import Netmaxiot from time import sleep led=0; sensorValue = 0; while 1: sensorValue =Netmaxiot.analogRead(led) print("the value from adc is %d"%sensorValue) volt=sensorValue*4.887 print("--------------------------------") print("the value of volt is %0.3f"%volt) light=volt/5000 light=light* 100 print ('light is %d'%light) sleep(1)
#!/usr/bin/env python #------------------------------------------------------------ #:) # My Dht22 Sensor interfacing # DHT22 Sensor Example By NetmaxIOT & Rohitkhosla # OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla # ----------------------------------------------------------- #:) import Netmaxiot import math # Connect the dH22 Netmaxiot Temperature & Humidity Sensor Pro to digital port D4 # This example uses the blue colored sensor. # SIG,NC,VCC,GND sensor = 4 # The Sensor goes on digital port 4. # temp_humidity_sensor_type blue = 0 # The Blue colored sensor. IT IS DHT11 white = 1 # The White colored sensor. IT IS dHT22 while True: try: # This example uses the blue colored sensor. # The first parameter is the port, the second parameter is the type of sensor. [temp, humidity] = Netmaxiot.dht(sensor, blue) if math.isnan(temp) == False and math.isnan(humidity) == False: print("temp = %.02f C humidity =%.02f%%" % (temp, humidity)) except IOError: print("Error")
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
#!/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")
#!/usr/bin/env python # ____________________________________________________ # :) My Single Analog Sensor Netmaxiot Sensor interfacing # Analog Example By NetmaxIOT & Rohitkhosla # OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla # :) #---------------------------------------------------------------- import time import Netmaxiot #Analog Sensor connected to A0 Port of Netmax iot Shield :) sensor = 0 # Pin 0 is A0 Port. while True: try: sensor_value = Netmaxiot.analogRead(sensor) a = sensor_value * 4.88 b = a / 1000 print("sensor_value = %0.2f volts " % b) time.sleep(.5) except IOError: print("Error")
# :) # 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")
#!/usr/bin/env python import Netmaxiot try: print("Netmaxiot has firmware version: 2019.%s" % Netmaxiot.version()) except KeyboardInterrupt: print("KeyboardInterrupt") except IOError: print("Error")
import Netmaxiot import sys import urllib2 from time import sleep import Adafruit_DHT as dht # Enter Your API key here myAPI = 'Z7S5V1NHSVEDY7CP' # URL where we will send the data, Don't change it baseURL = 'https://api.thingspeak.com/update?api_key=%s' % myAPI def DHT11_data(): # Reading from DHT11 and storing the temperature and humidity humi, temp = dht.read_retry(dht.DHT11, 17) return humi, temp while True: try: pin0 = Netmaxiot.analogRead(0) humi, temp = DHT11_data() # If Reading is valid print "HI!" if isinstance(humi, float) and isinstance(temp, float): # Formatting to two decimal places humi = '%.2f' % humi temp = '%.2f' % temp # Sending the data to thingspeak conn = urllib2.urlopen(baseURL + '&field1=%s&field2=%s&field3=%s' % (temp, humi, pin0)) print conn.read() # Closing the connection conn.close() else: print 'Error'
import Netmaxiot from time import sleep led=3 led1=5 led2=6 Netmaxiot.pinMode(led,"OUTPUT") Netmaxiot.pinMode(led1,"OUTPUT") Netmaxiot.pinMode(led2,"OUTPUT") sleep(1) i=0 try: Netmaxiot.digitalWrite(led,0) Netmaxiot.digitalWrite(led1,0) Netmaxiot.digitalWrite(led2,0) while 1: print(i) print("analog pin 3,5,6,9") Netmaxiot.analogWrite(led,i) Netmaxiot.analogWrite(led1,i) Netmaxiot.analogWrite(led2,i) i=i+5 sleep(0.05) if(i>255): i=0 except KeyboardInterrupt: Netmaxiot.digitalWrite(led,0) Netmaxiot.digitalWrite(led1,0) Netmaxiot.digitalWrite(led2,0)
#!/usr/bin/env python # # :) my Digital Sensor Test # Digital Sensor Example By NetmaxIOT & Rohitkhosla # OpenSource MIT licence by Netmax IOT Shield And Rohitkhosla # :) import time import Netmaxiot button2 = 2 button3 = 3 button4 = 4 Netmaxiot.pinMode(button2, "INPUT") Netmaxiot.pinMode(button3, "INPUT") Netmaxiot.pinMode(button4, "INPUT") while True: try: d2 = Netmaxiot.digitalRead(button2) d3 = Netmaxiot.digitalRead(button3) d4 = Netmaxiot.digitalRead(button4) print("%d,%d,%d" % (d2, d3, d4)) except IOError: print("Error")
import Netmaxiot from time import sleep while 1: read = Netmaxiot.analogRead(0) light = read / 1000 light = light * 100 print "The light from LDR == %d Percent " % light sleep(1)
ADAFRUIT_IO_USERNAME = '******' ADAFRUIT_IO_KEY = '439d545f8aca4bea99ba3f4bcbceb081' aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY) Voltage0 = aio.feeds('lm35.voltage0') Voltage1 = aio.feeds('lm35.voltage1') Temp0 = aio.feeds('lm35.temp0') Temp1 = aio.feeds('lm35.temp1') ################################################### while True: ################################# PIN0 = Netmaxiot.analogRead(0) PIN1 = Netmaxiot.analogRead(1) vol0 = ((PIN0*4.88)/1000) vol1 = ((PIN1*4.88)/1000) temp0 = vol0/10 temp1 = vol1/10 ##################################################33 print '> Voltage 0 : ', str(float(vol0)) aio.send(Voltage0.key, float(vol0)) print '> Voltage 1 : ', str(float(vol1)) aio.send(Voltage1.key, float(vol1)) print '> Temp 0 : ', str(float(temp0)) aio.send(Temp0.key, float(temp0)) print '> Temp 1 : ', str(float(temp1)) aio.send(Temp1.key, float(temp1)) time.sleep(DELAY_TIME)
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)
#!/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.
#scope = ['https://spreadsheets.google.com/feeds', # 'https://www.googleapis.com/auth/drive'] #credentials = ServiceAccountCredentials.from_json_keyfile_name(GDOCS_OAUTH_JSON, scope) #gc = gspread.authorize(credentials) print('Logging sensor measurements to {0} every {1} seconds.'.format( GDOCS_SPREADSHEET_NAME, FREQUENCY_SECONDS)) print('Press Ctrl-C to quit.') worksheet = None while True: # Login if necessary. if worksheet is None: worksheet = login_open_sheet(GDOCS_OAUTH_JSON, GDOCS_SPREADSHEET_NAME) print "login to google sheet with login details" print "---------------------------------------------" PIN0 = Netmaxiot.analogRead(0) PIN1 = Netmaxiot.analogRead(1) PIN2 = Netmaxiot.analogRead(2) PIN3 = Netmaxiot.analogRead(3) #volt0=(PIN*4.89) #volt1=(PIN1*4.89) #volt2=(PIN2*4.89) #0volt3=(PIN3*4.89) pin0 = str(PIN0) pin1 = str(PIN1) pin2 = str(PIN2) pin3 = str(PIN3) # print (hum1) nowx = datetime.now() xp = nowx.strftime("20%y-%m-%d %X") time1 = str(xp)
# :) 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)
import Netmaxiot from time import sleep while 1: read1 = Netmaxiot.analogRead(2) read2 = Netmaxiot.analogRead(3) voltage1 = read1 * 4.887 voltage2 = read2 * 4.887 temp = voltage2 / 10 light = (voltage1 / 5000) * 100 print "our light is == %0.1f percent " % light print "The temp is == %0.1f degree " % temp sleep(1)
#!/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")
#!/usr/bin/env python import Netmaxiot import time Netmaxiot.pinMode(5,"OUTPUT") Netmaxiot.pinMode(6,"OUTPUT") Netmaxiot.pinMode(7,"OUTPUT") try: while 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) print("led off...............................") Netmaxiot.digitalWrite(5,0) time.sleep(0.2) Netmaxiot.digitalWrite(6,0) time.sleep(0.2) Netmaxiot.digitalWrite(7,0) time.sleep(1) except: print("Error !!! Please Check Your Connections")
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)
except Exception as ex: print( 'Unable to login and get spreadsheet. Check OAuth credentials, spreadsheet name, and make sure spreadsheet is shared to the client_email address in the OAuth .json file!' ) print('Google sheet login failed with error:', ex) sys.exit(1) print('Logging sensor measurements to {0} every {1} seconds.'.format( GDOCS_SPREADSHEET_NAME, FREQUENCY_SECONDS)) print('Press Ctrl-C to quit.') worksheet = None while True: # Login if necessary. x = se.get_temperature() read1 = Netmaxiot.analogRead(0) read2 = Netmaxiot.analogRead(1) voltage1 = read1 * 4.887 voltage2 = read2 * 4.887 light = voltage1 / 5000 light = light * 100 print "the value of light = %0.2f " % light print "--------" tempx = voltage2 / 10 print "--------" print "--------" print "the value of temp analog = %0.2f " % tempx tempp = round(tempx, 2) lightx = round(light, 2) if worksheet is None: worksheet = login_open_sheet(GDOCS_OAUTH_JSON, GDOCS_SPREADSHEET_NAME)
#!/usr/bin/env python import time import Netmaxiot Netmaxiot.pinMode(2, "OUTPUT") Netmaxiot.pinMode(3, "OUTPUT") Netmaxiot.pinMode(4, "OUTPUT") Netmaxiot.pinMode(5, "OUTPUT") Netmaxiot.pinMode(6, "OUTPUT") time.sleep(1) i = 0 try: Netmaxiot.digitalWrite(2, 0) Netmaxiot.digitalWrite(3, 0) Netmaxiot.digitalWrite(4, 0) Netmaxiot.analogWrite(3, 255) time.sleep(2) Netmaxiot.analogWrite(3, 128) time.sleep(2) while True: print(i) Netmaxiot.analogWrite(3, i) Netmaxiot.analogWrite(5, i) Netmaxiot.analogWrite(6, i) i = i + 5 time.sleep(0.05) if i > 255: i = 0 except KeyboardInterrupt: Netmaxiot.analogWrite(3, 0)
#!/usr/bin/env python import Netmaxiot # Connect the Netmaxiot Ultrasonic Ranger to digital port D4 # SIG,NC,VCC,GND ultrasonic_ranger = 4 while True: try: # Read distance value from Ultrasonic print(Netmaxiot.ultrasonicRead(ultrasonic_ranger)) except TypeError: print("Error") except IOError: print("Error")
# NOTE: # The sensor uses a thermistor to detect ambient temperature. # The resistance of a thermistor will increase when the ambient temperature decreases. # # There are 3 revisions 1.0, 1.1 and 1.2, each using a different model thermistor. # Each thermistor datasheet specifies a unique Nominal B-Constant which is used in the calculation forumla. # # The second argument in the Netmaxiot.temp() method defines which board version you have connected. # Defaults to '1.0'. eg. # temp = Netmaxiot.temp(sensor) # B value = 3975 # temp = Netmaxiot.temp(sensor,'1.1') # B value = 4250 # temp = Netmaxiot.temp(sensor,'1.2') # B value = 4250 import time import Netmaxiot # Connect the Netmaxiot Temperature Sensor to analog port A0 # SIG,NC,VCC,GND sensor = 0 while True: try: temp = Netmaxiot.temp(sensor, '1.1') print("temp =", temp) time.sleep(.5) except KeyboardInterrupt: break except IOError: print("Error")
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
#!/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")
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:
import Netmaxiot from time import sleep while 1: read = Netmaxiot.analogRead(0) sensorValue = Netmaxiot.analogRead(1) print("the value from lm is %d" % sensorValue) print("the value from adc is %d" % read) volt = read * 4.887 volt1 = sensorValue * 4.887 print("--------------------------------") print("the value of volt is %0.3f" % volt) light = volt / 5000 light = light * 100 print('light is %d' % light) print("--------------------------------") print("the value of volt is %0.3f mv" % volt) temp = volt1 / 10 print('temp is == %0.3f' % temp) sleep(1)
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")