Skip to content

Instantly share code, notes, and snippets.

@pingud98
pingud98 / cosmicpiparserinflux.py
Last active January 10, 2021 20:45
Cosmic Pi Parser for Influx
from influxdb import InfluxDBClient
import serial
import uuid
import random
import time
import datetime
import s2cell
dbframe = 0
@pingud98
pingud98 / cosmicsdcopy.sh
Created October 4, 2020 11:56
script to copy 5 cosmid pi sd cards using pinebook pro and multiple card readers
#!/bin/bash
sudo dd bs=4M if=cosmicpi17dist.img of=/dev/sda status=progress
sudo dd bs=4M if=cosmicpi17dist.img of=/dev/sdb status=progress
sudo dd bs=4M if=cosmicpi17dist.img of=/dev/sdc status=progress
sudo dd bs=4M if=cosmicpi17dist.img of=/dev/sdd status=progress
sudo dd bs=4M if=cosmicpi17dist.img of=/dev/sde status=progress
sudo sync
@pingud98
pingud98 / I2C_LCD_Driver.py
Created September 1, 2020 07:17
I2C LCD display scripts for Friendlyelec NanoPi NEO2 based NAS
# -*- coding: utf-8 -*-
# Original code found at:
# https://gist.github.com/DenisFromHR/cc863375a6e19dce359d
"""
Compiled, mashed and generally mutilated 2014-2015 by Denis Pleic
Made available under GNU GENERAL PUBLIC LICENSE
# Modified Python I2C library for Raspberry Pi
# as found on http://www.recantha.co.uk/blog/?p=4849
@pingud98
pingud98 / install.sh
Last active June 14, 2020 16:00 — forked from lukicdarkoo/install.sh
CosmicPi configuration script
#!/bin/bash
# Usage: curl https://gist.githubusercontent.com/lukicdarkoo/e33e00c6780ad0215d3932b810a10e46/raw | sh
echo "In case of any issues please consult cosmicpi.org for help, or contact us via Facebook "
echo "--- Expand the file system ---"
sudo resize2fs /dev/mmcblk0p2
echo "--- Update OS ---"
sudo apt -y update
@pingud98
pingud98 / CosmicPi1point6GPSTest.ino
Created August 2, 2019 21:06
GPS comms test for cosmic pi version 1.6
/*
GPS test routine, based on serial passthrough from the Arduino standard examples
which was originally written by by Erik Nyquist, kudos!
it wasn't working using 'serial' so I changed it to a non-reserved name and BINGO. :)
*/
HardwareSerial GPS(PA10,PB6);
void setup() {
Serial.begin(9600);
GPS.begin(9600);
@pingud98
pingud98 / CosmicPi16CalibrationUtil.ino
Last active July 21, 2019 21:19
A calibration utility for the Cosmic Pi V1.6 hardware, enables interactive setting of the HV and detection thresholds independently, and storage of the calibrated values in EEPROM. Requires STM32 Core for Arduino + the Cosmic Pi custom board type
/*
Cosmic Pi V1.6 Calibration script
Run this to set the EEPROM values in your Cosmic Pi, before flashing the operational software
Notes to user: If you set the thresholds/HV wrong and it goes crazy with interrupts, just re-flash and the values will
be reset before the interrupt is attached. Problem solved.
We write the values in the EEPROM at two places, one will be used for user manipulation, the other will remain there
for a 'hard reset'
This won't work unless you've got the Cosmic Pi board type and STM32 core for Arduino installed.
@pingud98
pingud98 / CosmicPi16Interrupt.ino
Created July 18, 2019 12:09
Interrupt function on Cosmic Pi 1.6 using STM32 for Arduino
//drive the dac channels
//set values into eeprom
#include <EEPROM.h>
//ref point for HV is 0xAD
//eeprom writing table
/*
*EEPROM Status - byte 00
*channel 0 high byte - 01
@pingud98
pingud98 / detectorxcal.ino
Last active July 19, 2019 11:42
Cosmic Pi V1.6 first cosmics
//drive the dac channels
/*
Crude code to get the Cosmic Pi up and running, spits out events (coincidence on both channels, after setting the HV to about 28V
and the DAC to 22F (whatever that is).
Makes the light blink (it's not very bright) and prints the event number.
Rate on the test unit seems reasonable, we'll test this against a proper setup over the next few weeks
To be re-written using interrupts for production code.
*/
@pingud98
pingud98 / neo2lcdscript.py
Created May 19, 2019 09:58
Python script to display status info on a cheap I2C lcd screen with my NanoPi Neo2
import socket
import fcntl
import struct
import psutil
import os
import sys
import time
home_dir = os.path.expanduser("~")
sys.path.append(home_dir)
import I2C_LCD_Driver
@pingud98
pingud98 / Particle.ino
Created March 23, 2019 18:12
Current beta code for the OpenAuto
//Open Auto code
//Arezzo release July 2018
//Released under the GPL V3.
//note that the number of live reservations in the system is stored in eeprom location 2046 (i.e. the last slot)
//ConfigCarFun
//Config string function - pass the master RFID and door mode via function.
//Car types
//1 = one button, wire to relay 1; pulse open, pulse close