Posts

Showing posts from 2020

de-bouncing an S0 energy sensor on a pi

I hooked up a submeter to my fuseboard some time ago, and not too long ago I started to read it with a Pi Zero.  However every now and again I would get a crazy reading, and from logging I would see bouncing. I would see interrupts where wiringpi would report the input as 0, and then again as 0, with no change to 1 inbetween.  I read up on debouncing and how the Pi is meant to do this, and also how some people have handled it in code by removing large deviations.   In my case, the solution has been to simply add logic in an encompassing if statement, to ignore interrupts where the pin is the same value as the last interrupt, and only count interrupts where the pin is a different like this  if (digitalRead(PIN) == last_interrupt_pin) { printf("Bounce ! Last Pin = %d This Pin = %d\n", digitalRead(PIN), last_interrupt_pin); }

day night meter

 I recently looked at moving from a basic electricity meter to a day/night meter, and got a little caught up in the maths, so thought I write it here. Where I live, your electricity is made up of a standing monthly charge, and a usage charge.  you by default get a meter which is an all day meter and not aware of day/night.  though smart meters are coming  (smart tarriffs some other time in the future). For free you can change your meter to be a day night meter, where the day tariff is higher than the all day tariff, but the night tariff is a lot cheaper.  The standing rate is different, but lets ignore that or now. There is a magic point where your % of electrcity used during the day vs night, will be equal to the cost of the all day tariff, and expressing this lets you figure out if you will save money moving from all day to day/night.  The maths looks like this (night rate - all day rate) / (night rate - day rate) = %day  (the percent of you 24hr us...

installing windows 10 on a mac mini 2,1

Mac mini 2,1 devices are tricky, they are 64bit, but have a 32bit EFI.  booting a usb to install windows isn't going to work. my internal cdrom drive is faulty, so can't use that an external cdrom won't install either. The easiest way to install it, is to boot the mac mini into target disk mode (hold T on boot).  Then connect a firewire cable to another system.  The internal disk in the mini will now show up as a disk on this other system. create a 4GB NTFS primary partition. copy the contents of windows 10 x32 cdrom onto it make the partition active with diskpart (select disk X/select partion X/active) put a bootsector on it. from cdrom \boot\bootsect.exe /nt60 y: reboot mini, and it will install windows from the internal disk. thanks to  https://www.bleepingcomputer.com/forums/t/619313/clean-install-windows-directly-from-the-hard-disk-drive/ drivers are fun, get apple ir, bluetooth etc from bootcamp 4.0.4326 and extract the sigmatel audio drivers,...

Installing FreeBSD 13 on a mac mini 2,1

Mac mini 2,1 devices are tricky, they are 64bit, but have a 32bit EFI.  booting a usb to install Freebsd isn't going to work. my internal cdrom drive is faulty, so can't use that an external cdrom won't install either. The easiest way to install it, is to boot the mac mini into target disk mode (hold T on boot).  Then connect a fireware cable to another system.  The internal disk in the mini will now show up as a disk on this other system. install virtualbox and setup raw disk access to the firewire drive.  install freebsd in virtualbox, which is therefore writing at a raw level to the disk in the mini.  complete the install, power cycle the mini and it should boot into freebsd. everything worked for me, graphics were a problem though with freebsd, it wouldn't detect the DVI.  digging around, this fixed it installing port graphics/drm-fbsd12.0-kmod and adding        kld_list="/boot/modules/drm.ko /boot/modules/i915kms.k...