Monday, July 18, 2016

Why sending garbage is required before radio transmission (aka preamble for AGC radio receivers)

Sometimes there is a trade-off doing it "low level", but how much I learn everyday!

I eventually discovered, the hard way, why radio receivers with automatic gain control (AGC) do need compulsory seemingly "useless" preambles for them to adjust their volume properly, for the real data to come.

First: send a calibrating preamble (alternating zeros/ones)

No signal? The gain is adjusted to get one. So we read radio noise!
By the way, this radio module took about 30ms to fully adjust its gain.
Once I re-think about it, it is plain obvious... a receiver does not know whether someone is really transmitting or not. So when nothing is transmitted, it acts just as anybody on a audio system who wants to check if the source is plugged or not: the receiver increases the volume (gain) until it catches something. But when nobody really is transmitting, increasing gain eventually ends up amplifying noise, i.e. seemingly random 0s and 1s. As humans, we know we are hearing static and the input device is not transmitting. But the receiver is not able to know.

Without proper calibration, the start of real data then gets buried in the noise, until the receiver manages to set its gain, back to actual transmission levels (i.e. it reduces the amplification until signal is just below saturation -- again, like a human who quickly turns the volume down after the source is plugged).

Sunday, July 17, 2016

Power IoT devices with solar energy, the $1.50 cheap way!

Had to find an easy solution to power some of my low-power device, like the one on the right (it is a minimalist 433MHz receiver).

A long time ago I bought a bunch of solar flashlight keyrings specifically for scavenging the parts.

They proved to be better than my expectations, with a very convenient 37×22×1.1mm solar cell which gives 7V unloaded, and up to 8mA for tested loads of 1 and 100 ohms (it "rains fire" as we often say here in summer: specs are only 5.2mA~6.3mA at 3.4V~4.5V loaded).

Admittedly, it is not much, but it is enough for a great lot of IoT devices, and given the size, it is just GREAT.

Measuring tiny currents to assess power consumption

The original EEVblog ĀµCurrent (David Jones).
Way cheaper than real industrial probes,
but still too expensive for my needs ($80+)
It is open source btw (see here).
Optimizing power needs requires power tools that can read tiny currents (nano or pico amperes)...

Nothing happened like I wanted to the last N days and had to work on unexpected stuff, like a remote water level alarm for our swimming pool after more leakages (the liner is 14 year old). So I made an RF alarm, which is powered by a small ultracapacitor (0.47F) backed by a tiny 3x2cm solar panel I scavenged from a led keychain.

I wanted it to be small, so I can duplicate the project and put sensors all around (I should end up at around 3x2x2 cm all included). But small means low power.





Friday, July 15, 2016

Tool to program an ATtiny85 AVR in situ in a minimalist configuration (ICSP)

Programming the chip, directly on the PCB (i.e. ICSP), via its shoulders.
Note how the pogo pins compensate for approximate placements!


Retractable pogo pins (top) and
regular 3x2 headers (bottom)

A long time ago, I made this little tool to help me upload code to Attiny85 AVR microcontrollers directly on the PCB (ICSP, i.e. in-circuit serial programming), but without even the need for a connector.

It plugs into regular 6 pin adapters of USB ASP programmers, and it relies on so-called elastic/retractable "pogo pins" to make contact with the DIP8 chip.









Saturday, July 9, 2016

Raspberry pi booting on a fullscreen web page (kiosk mode)

Start chromium at boot, while disabling screen savers

This is useful when you want a web application to be run straight out of booting process on a raspberry pi.

To start chromium in kiosk mode, without menus and cursor, use ''piconfig'' to boot into graphics mode and the ''pi'' user, then set the content of ''/home/pi/.config/lxsession/LXDE-pi/autostart'' to this:
''
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@xset s 0 0
@xset s noblank
@xset s noexpose
@xset dpms 0 0 0
xwit -root -warp $( cat /sys/module/*fb*/parameters/fbwidth ) $( cat /sys/module/*fb*/parameters/fbheight )
chromium-browser --app=http://172.24.1.1 --kiosk
''

You may use ''apt-get install unclutter'' instead of ''xwit'' above, to hide the cursor. Note: on NOOBS, ''.xinitrc'' does not seem to have any sort of effect, weirdly.

Hide booting process

When you want it to look more pro, you can redirect the boot process information to a secondary console, by changing ''tty1'' to ''tty2'' in ''/boot/cmdline''. You still can see it by pressing Control-Alt-F2 (then F7 to switch back to the grpahical terminal).

''
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty2 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
''

Set the raspberry as an accesspoint

Finally, to set your raspberry pi as a wifi access point: https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/

Lighttpd web server cgi-scripts

When you want lighttpd to be able to run a sudo cgi script, add this line with ''visudo'':
''
www-data ALL=(ALL) NOPASSWD: /var/www/cgi-bin/*
''