def read_volt(): PIN0 = Netmaxiot.analogRead(0) PIN1 = Netmaxiot.analogRead(1) PIN2 = Netmaxiot.analogRead(2) PIN3 = Netmaxiot.analogRead(3) vol0 = ((PIN0 * 4.88) / 1000) vol1 = ((PIN1 * 4.88) / 1000) vol2 = ((PIN2 * 4.88) / 1000) vol3 = ((PIN3 * 4.88) / 1000) print(vol0) print(vol1) print(vol2) print(vol3) payload = { 'Voltage-0': vol0, 'Voltage-1': vol1, 'Voltage-2': vol2, 'Voltage-3': vol3 } return payload
def read_volt(): PIN0 = Netmaxiot.analogRead(0) # PIN1 = Netmaxiot.analogRead(1) # PIN2 = Netmaxiot.analogRead(2) # PIN3 = Netmaxiot.analogRead(3) vol0 = ((PIN0 * 4.88)) temp = vol0 / 10 # vol1 = ((PIN1*4.88)/1000) # vol2 = ((PIN2*4.88)/1000) # vol3 = ((PIN3*4.88)/1000) print(PIN0) print(vol0) print "The Temperature is %0.2f" % (temp) # print (vol1) # print (vol2) # print (vol3) payload = {'Voltage-0': vol0} # payload = {'Voltage-0': vol0, 'Voltage-1': vol1, 'Voltage-2': vol2, 'Voltage-3': vol3} return payload
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
#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)
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 Netmaxiot.digitalWrite(led, 0) print("sensor_value = %d resistance =%.2f" % (sensor_value, resistance)) time.sleep(.5)
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)
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 Netmaxiot from time import sleep #Sensor connected to A0,A1,A2 Port x = 0 y = 1 while 1: try: read1 = Netmaxiot.analogRead(x) read2 = Netmaxiot.analogRead(y) sleep (3.0) print (" ") print ("Reading channel 1=%d"%(read1)) print ("Reading channel 2=%d"%(read2)) print ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") vol=read1*4.89 print ("our voltage=%f mv "%(vol)) print "--------------------------------------" temp=vol/10 light=read2*100/1023 print "######################################" print ("Light intensity=%d Percent "%(light)) print ("temp=%0.2f *C "%(temp)) print "_________________________________" print " " except IOError: print ("Error please check you Netmax IOT Shiled and Sensors ")
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)
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'
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 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)
import Netmaxiot from time import sleep while 1: read = Netmaxiot.analogRead(0) read1 = Netmaxiot.analogRead(1) read2 = Netmaxiot.analogRead(2) read3 = Netmaxiot.analogRead(3) print("the value from adc is %d" % read) print("the value from adc1 is %d" % read1) print("the value from adc2 is %d" % read2) print("the value from adc3 is %d" % read3) volt = read * 4.887 volt1 = read1 * 4.887 volt2 = read2 * 4.887 volt3 = read3 * 4.887 print("--------------------------------") print("the value of volt is %0.2f" % volt) print("the value of volt1 is %0.2f" % volt1) print("the value of volt2 is %0.2f" % volt2) print("the value of volt3is %0.2f" % volt3) sleep(1)
#!/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")
#!/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")
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)
# Min Typ Max Condition # 0 0 0 sensor in open air # 0 20 300 sensor in dry soil # 300 580 700 sensor in humid soil # 700 940 950 sensor in water # Sensor values observer: # Val Condition # 0 sensor in open air # 18 sensor in dry soil # 425 sensor in humid soil # 690 sensor in water import time import Netmaxiot # Connect the Netmaxiot Moisture Sensor to analog port A0 # SIG,NC,VCC,GND sensor = 0 while True: try: print(Netmaxiot.analogRead(sensor)) time.sleep(.5) except KeyboardInterrupt: break except IOError: print ("Error")