Raspberry Pi, Logs and IoT - Sending Pi Log and Sensor data to Logentries
Code snippets from the blog post: https://blog.logentries.com/2016/05/raspberry-pi-logs-and-iot-sending-pi-log-and-sensor-data-to-logentries
Raspberry Pi, Logs and IoT - Sending Pi Log and Sensor data to Logentries
Code snippets from the blog post: https://blog.logentries.com/2016/05/raspberry-pi-logs-and-iot-sending-pi-log-and-sensor-data-to-logentries
| import os | |
| import time | |
| import RPi.GPIO as GPIO | |
| from logentries import LogentriesHandler | |
| import logging | |
| log = logging.getLogger(‘logentries’) | |
| log.setLevel(logging.INFO) | |
| log.addHandler(LogentriesHandler(YOUR_TOKEN_HERE)) | |
| GPIO.setmode(GPIO.BCM) | |
| GPIO.setup(4, GPIO.IN) | |
| while True: | |
| state = GPIO.input(4) | |
| if (state==0): | |
| log.info(“state=Water Detected!”) | |
| else: | |
| log.info(“state=Dry”) | |
| time.sleep(1) |