Last active
August 29, 2015 14:19
-
-
Save wjwwood/ec20497ee75e73fd38ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from phant import Phant | |
from serial import Serial | |
import time | |
p = Phant('XGXqQ3maWluV1vn9xLgQ', 'moisture', private_key='REPLACEMEWITHPRIVATEKEY') | |
s = Serial('COM3') | |
last = None | |
while True: | |
line = s.readline() | |
last = last or time.time() | |
if time.time() - last > 15: | |
last = time.time() | |
print(line) | |
m = int(line.decode().split('=')[1].strip()) | |
print(m) | |
p.log(m) | |
print(p.remaining_bytes, p.cap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int analogInPin = A0; // Analog input pin that the moisture sensor is attached to | |
int sensorValue = 0; // value read from the moisture sensor | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
// read the analog in value: | |
sensorValue = analogRead(analogInPin); | |
// print the results to the serial monitor: | |
Serial.print("sensor = "); | |
Serial.println(sensorValue); | |
delay(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment