Skip to content

Instantly share code, notes, and snippets.

#include <ESP8266WiFi.h>
#define AP
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
#ifdef AP
Serial.println("Access Point");
WiFi.mode(WIFI_AP);
@netmaniac
netmaniac / fw.sh
Last active November 21, 2019 21:43
Simple bash function for checking if new usb serial converter has been attached. Tested on Ubuntu 18.04. Use PATH_NAME=$(wait_for_new_usb_serial)
function wait_for_new_usb_serial() {
local array=(`ls -1 //sys/bus/usb-serial/devices/`)
local ret=""
local current_devices
while (true) do
sleep 2
current_devices=(`ls -1 //sys/bus/usb-serial/devices/`)
for value in "${current_devices[@]}"
@netmaniac
netmaniac / i2c_lcd.py
Created October 19, 2016 09:12
Simple lib for PCF8574 based I2C LCD adapters
#!/usr/bin/python
# Supports 16x2 and 20x4 screens.
#
# Based on work by Matt Hawkins (raspberrypi-spy.co.uk)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@netmaniac
netmaniac / nova_sensor.py
Last active August 10, 2022 17:32
Nova SDS011 sensor. Code is free to use in own projects, but I don't provide any support nor don't make me liable if it is not working :)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import serial, time, struct, array
from datetime import datetime
ser = serial.Serial()
ser.port = "/dev/ttyUSB0" # Set this to your serial port
ser.baudrate = 9600
#define NOT_CORRECTED 10
/*
Change brightness of LED linearly to Human eye
32 step brightness using 8 bit PWM of Arduino
brightness step 24 should be twice bright than step 12 to your eye.
*/
#include <avr/pgmspace.h>
#define CIELPWM(a) (pgm_read_word_near(CIEL8 + a)) // CIE Lightness loopup table function
//https://github.com/nettigo/RadioNRF24
#include <SPI.h>
#include <RadioNRF24.h>
#define BUFF_SIZE 40
struct Payload {
byte id;
unsigned long data;
#include <SPI.h>
#include "Battery.h"
#include <Radio.h>
#include "PinChangeInterrupt.h"
//#include <TinyDebugSerial.h>
//TinyDebugSerial debug = TinyDebugSerial();
#define BUTTON 10
#define PHOTOCELL_PWR 9