Friday, May 21, 2021
3 PRONG ROCKER SWITCH
The rocker switch moves a metal arm between contact 2 and 1 on and off.
The 2 (c) is always on, only contact on pin 1 is on / off.
Pin 3 can be connected to the opposite polarity then what you chose to switch so the light turns on.
Note some have a led connected and same have a indicator glass bulb for 220v.
Saturday, January 9, 2021
Sharp GP2Y1014AU0F air quality with arduino
Pin 1 (sensor led) - 150ohm resistor to vcc 5v
Pin 6 - vcc 5v
Pin 2 - to gnd
Pin 4 - to gnd
Pin 3 - input led - connect to a digital pin on arduino.
Note according to datasheet the input (drive) led is actually the base of a transistor connected to GND and not the actual led. So when we set the digital pin to HIGH we connect the led to GND and stop it.
To turn the led on we have to set the digital pin to LOW.
Pin 5 - output- connect to analog pin on arduino A0-A5
Datasheet: https://global.sharp/products/device/lineup/data/pdf/datasheet/gp2y1010au_e.pdf
Connect Pin 3 lets say to DIGITAL 3.
We set in void() function --> pinmode(3, OUTPUT);
// one read
digitalWrite(ledPin, LOW); // power on the LED
delayMicroseconds(280); // Wait 0.28ms according to datasheet
output_voltage = analogRead(3); // read output
delayMicroseconds(40); // wait 0.040 ms according to datasheet
digitalWrite(ledPin, HIGH); // turn the LED off
output_voltage = (3.33 / 4096) * output_voltage; // max 3.6v
delayMicroseconds(9760);
Note: i used a chinese clone from wavgate and althout it says it has an atmega 328p chip - the analog line read 4064 when connected to the 3.3v line - so that means a 12bit ads with 3.33v internal reference.
If you have the normal 5v 10bit 1024 resolution ads - change above to 3.33/4096 to 5/1204 .
If you are not sure what ads bits you have, connect the 3.3 and 5 lines to A0 for example and read with analogRead and see what result you get.
Next we have to convert the voltage to dust density according to the graph offered in the datasheet.
We have from the graph and datasheet info:
Output voltage at no dust 0.6v - 0 mg/m3 dust - given in the datasheet
And the graph intersect at 3.5v - 0.5 mg/m3 dust - you can see it on the graph clearly
With two points we can make a formula.
y-0.6 = x-0
3.5-0.6 = 0.5-0
y-0.6 3.5-0.6
------- = ----------
x-0 0.5-0
x = 0.5(y-0.6) / (3.5-0.6)
x = (y-0.6)*0.5/2.9 = (y-0.6)*0.17 = 0.17*y - 0.6*0.17 = 0.17y-0.1
Note: the sensor it is not very exact, as in the datasheet it says voltage at no dust is typical 0.6V but can go from 0.1V to 1.1V
if(output_voltage>0.6) {
dust_density = (0.1724 * output_voltage) - 0.1;
dust_density *= 1000;
}
There you go.
Because the sensor output fluctuates a lot and it is not stable, i like to make an average of around 100 reads (129 in the code below) or about one second - one read takes 10ms - so the output its a bit more stable.
Next is full code that shows result on and a lcd screen or on the serial console.
#include "LiquidCrystal_I2C.h"
LiquidCrystal_I2C lcd(0x27,20,4);
#define dustPin A0
#define ledPin 2
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.clear();
Serial.begin(115200);
while (!Serial) delay(100);
Serial.println("GP2Y1010AU0F Sensor demo");
pinMode(ledPin,OUTPUT);
}
int i =0;
float sum =0;
void loop() {
float output_voltage =0;
float dust_density = 0;
// 100 samples medie - 1 reading per second
// one read
digitalWrite(ledPin, LOW); // power on the LED
delayMicroseconds(280); // Wait 0.28ms according to DS
output_voltage = analogRead(dustPin);
delayMicroseconds(40);
digitalWrite(ledPin, HIGH); // turn the LED off
output_voltage = (3.33 / 4096) * output_voltage; // max 3.6v
delayMicroseconds(9760);
if(output_voltage>0.6) {
dust_density = (0.1724 * output_voltage) - 0.1;
dust_density *= 1000;
}
else dust_density = 0;
sum = sum + dust_density;
i++;
if(i==129*2) {
dust_density = sum / i;
i=0;
sum =0;
lcd.setCursor(0,0);
lcd.print("Dust: ");
lcd.setCursor(6,0);
lcd.print(dust_density);
lcd.print("ug/m3");
/*
Serial.print(",\tDust Density = ");
Serial.print(dust_density);
Serial.println(" ug/m3");
*/
}
}
Wednesday, November 4, 2020
ESP32 ARDUINO
Open Arduino IDE go to File -> Preferences and add the link
https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
Then go to boards, search and install esp32.
When you upload the code if you get
Failed to connect to ESP32: Timed out waiting for packet header
just press/hold the boot button - when it shows connecting... ___ ..... ____ .....
ESP32 Pinout
Tuesday, August 25, 2020
HRV biofeedback
Meditation and bio-feedback.
HRV - heart rate variability
On an ECG - electrocardiogram - you get the letters P Q R S T.
The time between two R, noted as R-R is HRV.
During relaxation the parasympathetic nervous system dominates, heart bpm drops and HRV increases
During stress the sympathetic nervous system dominates, heart bpm increases and HRV decreases
If you are chronically stressed or injured etc the body will stay in a sympathetic mode to sustain recovery even while resting. This is consuming for the body and you should not do any stressful activities like training, tough decisions etc. that like overcome the body's ability to compensate and it will trow you out of balance and in a bad state of health.
Hence the need to read your morning HRV so you know how your body is doing and how you continue your day.
Sensors:
- HearthMath Inner Balance sensor: many reviews on amazon say the sensor's quality is not reflected by its price which is around 160$ + shipping
- Polar H7/H9 or H10 - H10 being the best for accuracy - most easy to find and buy locally ~ 100$
- CorSense from the maker of the app https://elitehrv.com/ - 165$ - but expensive outside of the US ( around 200$ in europe with added vat) - the most convenient one to use
Polar H7 and H9 vs Poalr H10
You can see in the above image, the H10 has the same metal rounded electrode that is crimped to the connector, but also another rectangular metal band behind it that acts as a shield connected to ground to prevent exterior interference.
Note: i bought an spare chest strap from aliexpress that it is rated as a replacement for the H10 but it only has the main electrode and no shielding - so it is an equivalent to the H7/H9 soft strap.
“The extra interference-preventing electrodes on the strap make it extremely sensitive to your heart’s electrical signals, providing maximum precision for heart rate readings and eliminating interference.”
Saturday, November 30, 2019
Air quality PM sensors comparison for arduino
( note that it works under 70% humidity depending on what weather conditions you have where you life)
The Nova SDS011 - also recommenced by the https://luftdaten.info/ project
Price: 17$
Official website: http://www.inovafitness.com/en/a/chanpinzhongxin/95.html
Buy from aliexpress: http://s.click.aliexpress.com/e/Nz5SXZBE
It also has support for hardware serial connection for the esp32 which does not have software serial.
Plantower
Official website: http://www.plantower.com/en/content/?108.html
https://airly.eu/en/ - a project by Philips in witch they use the Plantower PMS5003
You can see the sensor and the insides of their sensor here:
https://www.youtube.com/watch?v=FREADCgdq2M
Plantower PMS5003
Buy the Plantower PMS5003 from aliexpress: http://s.click.aliexpress.com/e/tb2qOLXK
Price: 12-13$
Popular Pm monitors on the market and what sensors they use:
Laser Egg - uses Plantower PMS3003

Additional resources:
http://aqicn.org/sensor/
https://www.mysensors.org/build/dust
Wednesday, November 20, 2019
Program Arduino Mini Pro 3.3/5V with Arduino Uno
Connect RST pin to GND on Arduino Uno - to bypass the UNO's bootloader
Connect 5V or 3.3V to VCC on Mini
Connect GND to GND on Mini
Connect TX to TX
Connect RX to RX
Select in the Arduino IDE -> Tools -> Board -> Arduino Pro or Pro Mini
Select in the Arduino IDE -> Tools -> Board -> Processor -> 3.3V 8Mhz or 5V 16Mhz
Select in the Arduino IDE -> Tools -> Port
Select File->Examples ->Basics->Blink and press Upload button
When uploading appears in the Arduino IDE press the RESET button on the mini.
When you press the RESET button you should see the rx,tx lights on the uno start to blink fast for a short time - the sketch it is being uploaded.
The led on the Mini Pro should start blinking at one second.
DONE. ENJOY.
Tuesday, November 19, 2019
Bosch BME280 sensor with arduino for temp humidity and pressure
Buy sensor for here: http://s.click.aliexpress.com/e/KY9P6WRm
Arduino Libraries Required:
Adafruit_Sensor.h
Adafruit_BME280.h
Go to Tools -> Manage Libraries : search for bme280 and select the adafruit one, and install all.
Wire connections:
- 5V and GND to coresponding
- the marked ones SDA, SCL on the end of the digital pins
- or the analog pins A4 (SDA) A5 (SCL)
Arduino Code:
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme; // I2C
void setup()
{
bool status;
status = bme.begin();
}
void loop() {
float temp = bme.readTemperature(); // celsius
float humidity = bme.readHumidity(); // read humidity
float altitude = bme.readAltitude(1013.25);// read altitude SEA LEVEL PRESSURE_HPA (1013.25)
float pressure = bme.readPressure() / 100.0F; // read pressure
delay(5000);
}
Display 2004A generic 4 line 20 characters display with PCF8574T expander
Wire connections:
- 5V and GND to corresponding
- the marked ones SDA, SCL on the end of the digital pins
- or the analog pins A4 (SDA) A5 (SCL)
Arduino Code:
#include <LiquidCrystal_I2C.h>If you have more devices on the I2C buss you can change the address by soldering the A0, A1 OR A2 connection on the PCF8574T board.
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.clear();
lcd.setCursor (0,3); // first parameter its the line 0,1,2,3 - second character position 0-20
lcd.print("Hello World");
}
void loop() {
}
Contract and Backlight
- In case you don't see nothing on the screen, use a screwdriver and adjust the blue potentiometer on the back.
- The backlight on/off is controlled by the jumper
- jumper in place: backlight on
- jumper removed: backlight off
The backlight can also be controlled with software.
Use lcd.backlight(); to turn it on and lcd.noBacklight(); to turn it off.
Tuesday, July 17, 2018
Ergonomic bicycle saddle
Tuesday, May 8, 2018
Ghid calatorie
Verifica daca ai nevoie de viza. In zona EU nu este nevoie.
Verifica ce moneda se foloseste local. Instaleaza-ti revolut.
Casele de schimb valutar din aeroporturi ofera un curs prost. Scoate cash de la ATM.
Verifica avertizarile MAE: https://www.mae.ro/travel-conditions/3703
Adaptor priza: https://www.worldstandards.eu/electricity/plugs-and-sockets/
- WizzAir: https://wizzair.com
Cumpara WIZZ Discount Club la un zbor iesi pe zero, la doua deja ai reducere
Daca ai intarziere verifica zborul aici: Status zboruri WizzAir - Ryanair : https://www.ryanair.com
- Toate conexiunile directe dintr-un aeroport
https://www.flightconnections.com/flights-from-bucharest-otp
- SEATGURU - vezi schita avionului cu locurile inainte sa-ti faci booking online si sa-ti alegi locul.
For ex. check this Boeing 737 from KLM : KLM_Boeing_737-800
Alege un rucsac care se deschide ca un bagaj pe laterala.
NU mai stai sa-ti recuperezi bagajul si salvezi mult timp, in special daca ai legaturi unde poti pierde urmatorul zbor.
Cabin Max Metz 44L

By bus :
- Flixbus – check their Route Map – its super cool for finding connections between cities
Let me give you my itinerary i did :
I left Paris at 22 and arrived in Munich at 10 – visited Munich until 18 and took a bus to Prague where I arrived at 23 and when to a hostel – as Prague its 2-3 times cheaper compared to Munich).
I stayed two nights in Prague then did another drive through Vienna and went to Budapest where again I stayed a few nights ( even cheaper rent for a hostel bed ).
- Check InterRail – package train travel around Europe
For stays:
Local transportation and airport transfer
Verifica costul transportului de la aeroporturile mici pana in oras.Zborurile lowcost aterizeaza departe de oras si costul/disntanta pot sa nu merite.
http://www.terravision.eu - low cost airport trasfers
Check Uber prices as well, especially if you have a night flight in some places its cheaper then taxi in others is more expensive.
I got in Paris a shared Uber for 6.5 euro and public transport would have costed me 4 euros but it was more hassle and I was tired so the Uber was well worth the extra 2.5 euros.
Tip: ask for a free metro/transport network at your hotel/hostel, don't spend 10 euro on one.
USEFUL TRAVEL SITES:
Thursday, March 29, 2018
How to get amazon checks safe
The easiest fix for this is using Payoneer, it's an payment system similar to Paypal, and it opens an us dollars account for you.
You also get the benefit of payments as small as 10$ from amazon.
1. First step open for free a Payoneer account. Use this link to register so you also get 25$ bonus after your receive payments.
Log in to your account and go to Receive - Global Payment Service. Make sure USD is selected from the left as in the image below.

2.1. Go to your amazon affiliate account and log in.
Go to Account Settings - Change Payment Method. See the image below.
2.2. Chose Pay me by direct deposit (United States Based Associates Only)
Fill in the data from the page on Payoneer opened earlier. See picture above.
3. Get at least 50$ in payments from Amazon then go and withdraw your earning to your local non-US bank account.
Monday, January 1, 2018
Understanding Bitcoin
In order to validate transactions miners have to do some work - solve some mathematical problems, and hence use some power and resources. The more people participating the more difficult the mathematical problems and the higher the security, as it requires huge amounts of processing power.
It becomes unprofitable for one individual to spend that much money on the hardware and power need it to run it vs the value gained.
Miners assemble all new transactions appearing into large bundles called blocks, which collectively constitute an authoritative record of all transactions ever made, the blockchain.
So instead of just being able to make blocks at will, miners have to produce a cryptographic hash of the block that meets certain criteria, and the only way to find one is to try computing many of them until you get lucky and find one that works. This process is referred to as hashing. The miner that successfully creates a block is rewarded with some freshly created bitcoins.
Mining pools: by sharing their processing power, miners can find blocks much faster. Pool users earn shares by submitting valid proofs of work, and are then rewarded according to the amount of work they contributed to solving a block.
Resources:
Bitcoin core: https://bitcoin.org
The blockchain: https://blockchain.info/
To find bitcoin ATMs around the world: https://coinatmradar.com/
https://bitcoin.org/en/full-node#what-is-a-full-node
An episode on the inside man where Morgan Spurlock buys bitcoins and tries to live one week by it : https://vid.me/gjbm/morgan-makes-cents-out-of-bitcoin
A documentary released in 2014 The Rise and Rise of Bitcoin
How is the bitcoin fee calculated ?
The value of the fee its not related to value of transferred bitcoins but by the size of the transaction in bytes.This is calculated by the number of in transaction for the wallet multiplied by something like 180 plus the number of out transactions for the wallet multiplied by something like 34. So getting bitcoins paid adds more to the fee then paying with bitcoins.
Then the bytes values of the transaction get multiplied by a value called satoshis that its network dependent : how many transactions are happening and what fees people use.
Most apps have some default values where they will use a value so that you transaction will get into the next n-th block based on some settings you input or uses some default values.
You can check satoshisvalue here : https://bitcoinfees.21.co/
How much profit can you make mining ?
(Your power / network hash power)* Coins generated per day * Coin price
Say you have 1 THash miner
1.03.2018 for Bitcoin:
(1/23.500.000)*1800*11.000 $ =~ 0.85$ / day
Minimum bitcoin transation is : 5460 satoshi or 0,05460 mBTC.
This is the same amount as the minimum fee recommended.
1 BTC = 1,000,000,00 satoshi
Why is there a minimum limit of transaction in bitcoin ?
This limit is not forced by the protocol but by a consensus between both bitcoin clients as well as miners in an effort to fight transaction spam
Altcoins
Altcoins are the alternative cryptocurrencies launched after the success of Bitcoin, as peer-to-peer digital currencies, that offer modifications in areas like transaction speed, privacy, proof-of-stake, DNS resolution and more, in an attempt to imitate that success.
How to solo mine bitcoin with vga
Download link here: http://bfgminer.org/files/4.10.6/
Get bitcoin core install and wait to download the blockchain - requires ~190GB of storage space [on 14.07.2018].
When you install the core chose to save the blockchain in other location then by default on C, for easier access. Put it in D:\Bitcoin if you have another partition or in C:\Bitcoin.
There you will have your configuration file: bitcoin.conf.
Note that depending on you internet connection it might take couple of days to fully download and sync to the network.
You cannot mine until the sync is completed.
Download link here: https://bitcoin.org/en/download
Now go and edit the bitcoin.conf file. If it does not exist just create one with notepad.
server=1
rpcuser=whaterver-user-you-like
rpcpassword=any-password
rpcport=8332
rpcallowip=127.0.0.1
disablewallet=1
Save and restart the bitcoin app.
Go to the folder where you unrared your bfgminer.
Create a mine.bat file to save the command so you don't have to type it every time you run it.
bfgminer -S opencl:auto -o http://127.0.0.1:8332 -u whaterver-user-you-like -p any-password --set-device intensity=9 --coinbase-addr 18Mzayw6yHve2zn1ZQkxKYnM9TcvfEF7Y2
pause
Replace the username and password with the ones you set in bitcoin core.
Go to https://www.blockchain.com/wallet and create a bitcoin wallet.
Replace the --conbase-addr with your new created wallet.
To get the address press the receive bitcoins button and you will get your address.
Run the file and I wish you good luck.
If you are lucky and win the bitcoin lottery don't forget to show your appreciation :)
My bitcoin address is: 18Mzayw6yHve2zn1ZQkxKYnM9TcvfEF7Y2
Friday, July 21, 2017
How to buy from china electronics cheap online
- Aliexpress - cheapest, only card payment
- Gearbest - best for buying phones, camera and laptops and accesories as well, also offers Paypal payments
- Banggood - a bit more expensive but offers Paypal payments and has good customer service
For cheap 1-5$ products tracking cost its almost as much as the product.
On aliexpress you can get international tracking even with the no cost shipping method.
Monday, July 3, 2017
Nikon Coolpix P900 full spectrum / infrared camera modification tutorial
You can see in the video above how to remove the filter inside the camera for increased IR spotting.
This is the camera with an external IR filter :
![]() |
| K&F CONCEPT DIGITAL IR 720 67mm JAPAN OPTICS |
![]() |
| COOLPIX P900 |
![]() |
| Coolpix 900 with IR Filter |
Here are pictures taken with the camera :
| Auto mode - no ir filter |
|
| Enhanced monochrome - no IR filter |
|
| Monocrome mode with inside camera filter |
|
Friday, March 10, 2017
Apache mod_rewrite module tutorial
RewriteEngine On # Turn on the rewriting engine
Rewrite rules can be preceded by one or more rewrite conditions.
Eg :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
. (any character)
* (zero of more of the preceding)
+ (one or more of the preceding)
{} (minimum to maximum quantifier)
? (ungreedy modifier)
! (at start of string means "negative pattern")
^ (start of string, or "negative" if at the start of a range)
$ (end of string)
[] (match any of contents)
- (range if used between square brackets)
() (group, backreferenced group)
| (alternative, or)
\ (the escape character itself)
Flags :
CO=cookie (set specified cookie)
E=var:value (set environment variable var to value)
F (forbidden - sends a 403 header to the user)
G (gone - no longer exists)
H=handler (set handler)
L (last - stop processing rules)
N (next - continue processing rules)
NC (case insensitive)
NE (do not escape special URL characters in output)
NS (ignore this rule if the request is a subrequest)
P (proxy - i.e., apache should grab the remote content specified in the substitution section and return it)
PT (pass through - use when processing URLs with additional handlers, e.g., mod_alias)
R (temporary redirect to new URL)
R=301 (permanent redirect to new URL)
QSA (append query string from request to substituted URL)
S=x (skip next x rules)
T=mime-type (force specified mime type)
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]




















