Skip to content

Instantly share code, notes, and snippets.

@jcere
jcere / read_sensors.py
Created January 22, 2017 21:00
Python code for reading data using the Raspberry Pi with the Sense Hat
import logging
import sqlite3
import sys
import time
import json
from sense_hat import SenseHat
from re import findall
from subprocess import check_output
public void FtpRequest(string ftpPath, string destPath)
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpPath);
request.Method = WebRequestMethods.Ftp.DownloadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential(userName, passWord);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
@jcere
jcere / Index.cshtml
Last active April 17, 2016 23:07
Ui Plot Code
@{
ViewBag.Title = "Plot";
}
<h3>Time Based Plot </h3>
<div>
<cpanel class="plotControls">
<input class="btn btn-default" id="btnGetData" type="button" value="Plot" />
@jcere
jcere / TempController.cs
Last active October 9, 2015 01:40
Sample of my controller code from the API
/// <summary>
/// get temperature data starting at time and continuing for span with given period
/// </summary>
/// <param name="time">time in seconds</param>
/// <param name="span">length of span in seconds</param>
/// <param name="period"></param>
/// <returns>JsonResult containing view model</returns>
public JsonResult Get(double time, double span, int period)
{
var data = tempRepo.GetSamplesFromSpan(time, span, period);
@jcere
jcere / TemperatureSampler.py
Last active October 7, 2015 02:09
Updated python script for taking timed temperature samples using an MCP3008 ADC with TMP35
import spidev
import time
import os
import json
import sqlite3
import sys
# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)
@jcere
jcere / TemperatureSampler.py
Last active September 21, 2015 23:48
Python script for taking timed temperature samples using an MCP3008 ADC
import spidev
import time
import os
import json
# Open SPI bus
spi = spidev.SpiDev()
spi.open(0,0)
# Function to read SPI data from MCP3008 chip