Skip to content

Instantly share code, notes, and snippets.

@wjwwood
Last active August 29, 2015 14:19
Show Gist options
  • Save wjwwood/ec20497ee75e73fd38ad to your computer and use it in GitHub Desktop.
Save wjwwood/ec20497ee75e73fd38ad to your computer and use it in GitHub Desktop.
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)
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