Skip to content

Instantly share code, notes, and snippets.

@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[@]}"
#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 / cieplo-zimno.ino
Last active July 2, 2018 08:04
Kod do gry ciepło-zimno. Przykład dla Nettigo Starter Kit https://nettigo.pl/products/nettigo-starter-kit-dla-arduino Pełny opis projektu na: https://starter-kit.nettigo.pl/2018/07/saper-na-arduino/
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
#include "PCF8574.h"
#define LCD_ADDR 0x27 // Adres I2C wyświetlacza LCD
#define BTN_ADDR 0x20 // Adres I2C macierzy przycisków
const int ROWS[] = {4, 5, 6, 7}; // Do których pinów expandera podłączone są wiersze macierzy?
const int COLS[] = {3, 2, 1, 0}; // Do których pinów expandera podłączone są kolumny macierzy?
const int NUM_ROWS = sizeof(ROWS)/sizeof(int); // Liczba wierszy (obliczana automatycznie)
/***************************************************************************
Pogodełko - mini stacja pogodowa
https://nettigo.pl/products/pogodelko-twoja-pierwsza-stacja-pogodowa-z-wifi
v 1.0
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <Adafruit_NeoPixel.h>
#include <NewPing.h>
#define LED_PIN 6 // Pin, do którego podłączony jest "DIN" z NeoPixeli
#define LEDS_COUNT 8 // Ilość diod na pasku NeoPixel
#define BUZZER_PIN 9 // Pin buzzera
#define TRIGGER_PIN 12 // Pin "TRIG" czujnika odległości
#define ECHO_PIN 11 // Pin "ECHO" czujnika odległości
#define MAX_DISTANCE 200 // Maksymalny możliwy do zmierzenia dystans (200 dla HC-SR04)
#define TRIG_DISTANCE 100 // Dystans od którego zaczniemy informować o przeszkodzie
// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
@netmaniac
netmaniac / dht_sensor.h
Last active November 25, 2018 09:48
Simple air quality station - SDS011 + nodeMCU + DHT22 sending data to ThingSpeak. Project description (in Polish): http://starter-kit.nettigo.pl/2017/05/nodemcu-sds011-jako-badacz-jakosci-powietrza/ 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 :)
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN D7 // what digital pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
/*
24-02-2017 http://nettigo.pl Fixes to get it working on current Arduino IDE based on work:
3-2-2011 Spark Fun Electronics 2011 Nathan Seidle
Not all options are working. For sure works: Hello World, change background black/white,
Dull boy,both barcode examples and bitmap.
To use this example code, attach
Arduino : Printer
@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
@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.