Getting into Nyancoin

While following the ups and downs of bitcoin and other cryptocurrencies I stumbled upon xPool.net which is a p2pool node with 0% fees. Looking through the various coins I saw nyancoin which I recognised as being one of those altcoins that starts with a big hype and then completely collapses (with the early adopter probably walking away with profit). Google lead me to the official r/nyancoin subreddit and nyan-coin website – it turns out that a few people led by coinaday have attempted to revive a completely dead altcoin by stabilising the blockchain, stabilising the markets and rebuilding the community. Reading through the posts it seemed that they really wanted it to work and so i thought it might be a experiment for me to get involved in.

Getting Involved

icon
Image from http://www.freenyancoins.uk/

The first step is to download the nyancoin wallet from the nyan-coin website, the code is quite old but appears to be very stable (certainly on OS X). It’ll download the whole blockchain and then you are then ready to send and receive nyancoin. Even if you don’t have coins if you leave the wallet open it’ll act as a node on the network – the more nodes there are the more stable the network is. You can also get involved with the small but loyal community on reddit at r/nyancoin.

Getting some coins

Mining with a GPU

I initially tried to mine some coins using the gpu on my mac book air (this is a bad idea due to the design of the macbook air – the gpu gets very hot) but was only managing to generate 12kHs and felt that it wasn’t worth the risk of loosing my laptop! If you happen to have a computer or laptop with a good quality GPU then it might be worth a go, you need to use cgminer 3.7.2 as this is the last version to have the algorithms for scrypt mining. I used the pre-compiled binary from here and then used these settings to mine in the xPool.net nyancoin mining pool.

–scrypt -o stratum+tcp://xpool.net:8870 -u insert_your_wallet_address_here/0 -p x -I 9

The -I option control the intensity of the mining which will give you more hashing power but will cause your system to be more unresponsive.  As mentioned before you need to be careful with this form of mining especially if you have a laptop as you don’t want your hardware to overheat and die. To ensure that I didn’t I used Macs Fan Control software to manage my fan by monitoring the GPU temperature.

In total i managed to mine 1.08 nyan coins in a about 24hours which at the current exchange rate just isn’t worth it.

Trading nyancoins

I then went on to use exchanges to invest in some nyancoins, nyancoins are listed on cryptsy and cryptopia.nz. Cryptsy as an online exchange is not doing well and the current advice is to avoid it so I signed up to cryptopia.nz. This an altcoin exchange with additional features such as running mining pools, a marketplace and other useful functions. Here I was able to exchange some dogecoin and bitcoin for nyancoin to build up a small stake in nyancoin. It was easy to deposit and then withdraw the coins to your main wallet (ideally you shouldn’t leave large volumes on the exchange due to possible but unlikely security issues). The price of nyancoin is still find its feet, back in its darkest days it was only 1 satoshi but currently its in the midteens – it appears that there are still lots of people who hold large quantities of nyancoins which they just want to get rid of in big dumps which cause the market to crash – this is one of the things that loyal nyancoin supporters are trying to buffer against.

Mining with a Scrypt ASIC Miner

To continue the experiment I thought it would be interesting to try out setting up a proper mining system, miners are key to the development of an altcoin, as the generation of new blocks also provides the system to allow for transactions to occur on the blockchain. The algorithm that nyancoin uses is scrypt which is originally from litecoin and was purposely designed to be mainly mined on GPUs and CPUs rather than specialist hardware (this is unlike bitcoin where the algorithm is easily shifted to specialised chips often referred to as ASIC miners). There are however a few scrypt asic miners that exist and I thought it would be interesting to try this out.

Searching on ebay I found a reasonable Zeusminer Blizzard miner which contained 6 specialist chipZeusminer Blizzards and should mine at 1.3mH/s which is far better then the 12kH/s from my GPU. I ordered it and it arrived a few days, its nice an self contained, with a large heatsink and single fan on the top. It didn’t come with a power supply, searching the website I found reference to requiring 12V at 2A and managed to find an adapter that fitted, the other connection was a usb cable which was included. Following this guide and ensuring that I reinstalled the usb-serial drivers I was then able to power up the miner and start mining using my macbook air. The software that is suggested in the guide is bfgminer (rather than cgminer) and I found this easy to use, i ended up using this command:

bfgminer -S noauto -S zus:all –scrypt -o stratum+tcp://xpool.net:8870 -u KNbJngVn1NkDodBVY5i9uXRxz1qM5Lybbi/0 -p x

As I use my macbook air around the house and didn’t want to carry the miner with me I then switched to using my old macbook that only runs OS X 10.5.8. Getting the drivers to work took a while (had to find an old version) and then compile bfgminer was quite a challenge – I had to edit the source code in a number of places to get it to work – my suggestion is not to try on an old mac.

The adapter I had found then gave up, it appeared to overheat – I suspect that the zeusminer was drawing more current then it could supply. I had an old Apple Mac G5 case which I had previously installed a ATX power supply in the hopes of building a PC and so I use the 12V line to supply the Zeusminer. Also the large metal case of the G5 helped to keep the miner cool and slightly dampen the sound of the fan.G5 Case This has now been running for the last 48 hours without any problems, it has managed to mine a total of 729 nyancoins since I started it on the evening of 8/1/16

The future

My plan is to continue to support nyancoin, its been a fun experiement learning about how to revive a dead altcoin and also learning about how mining coins actually work. I intend to continue to mine with my mining setup though I won’t always have it on, have to be sensible with electricity costs but will continue to use wallet regularly so as to support the network.

Adding a DS18b20 1-wire digital thermometer to an LPC812 UKHASnet Node

DS18B20While my LPC812 UKHASnet nodes currently transmit the temperature from the RFM69HW radio module this isn’t particularly accurate as it is effected by how active the radio is.  As the LPC812 doesn’t have an ADC the easiest alternative is to use a DS18b20 1-Wire digital
thermometer from Maxim (Product Page).
These modules cost ~£2 and are quite easy to obtain as they are regularly used with arduino based products.

ds18b20pinFirst step is wiring the module to the LPC812, the version I use has 3 pins (TO-92), there are 2 ways that the module can be powered, either directly or parasitically where it uses current from the data line. I’ve found previously using the parasitic mode just added complications so have decided to go with the standard approach.
Using the EtnaNode 2nd Gen board I wired up pin 1 to ground, pin 3 to 3.3v (from the regulator) and then the DQ (data) pin to PIO0_12. As per the Figure 5 schematic it is necessary to have a 4.7K resistor as a pullup on the DQ line.ds18b20schem

Next step is sorting out the software side, the DS18b20 uses 1-Wire  protocol where it only requires a single data line (it can do both rx/tx). The LPC812 doesn’t have specific hardware for this but can just use a GPIO to bitbang the protocol. Luckily there is already software for both the 1-wire bus and ds18b20 by Joe Desbonnet (https://github.com/jdesbonnet) which he used for is LPC810 SousVide controller. I was able to integrate this code into my own LPC812 code with only a few changes. The DS18b20 relies on some quick timings, 1us ideally, and so my current mrtDelay was insufficient (this only allows 1ms). Looking at alternative code for LPC81* and DS18b20 by Gerrit Tamboer (http://home.kpn.nl/geetee1/lpc810_psychrometer.html) I saw that he used the function __delayticks() to give quicker timing and so I replicated this making a new UmrtDelay() function to give us microsecond level delays. Once all the delays were moved over to this new function I was then able to start reading the DS18b20.

The only issue currently is that the returned value is degC*100 to avoid using floats, it would be nice to fully integrate floats into the transmitted data but this is something that i’ll need to sort out with my stripped down version of sprintf. The code also only allows for a single DS18b20 on the 1-wire bus, in theory you could have more then 1 sensor on a single pin but this would requiring searching for each sensors ‘address’.

Find the latest code in the LPC812 github, in particular ds18b20.c and onewire.c you’ll need to ensure that you’ve selected the correct defines in settings.h including which pin the DQ line of the DS18b20 is connected to.

Measuring Battery Voltage on LPC812 (ADC)

I’ve been working on a prototype for an updated jam jar node, after the success of the ukhasnet hackweekend in 2015 and felt that actually jam jars are a good enclosure for floating nodes. The jam jar node that we launched (AI3) ran on batteries which would have only lasted a few days so ideally we want to put together a node that is able to charge its batteries. As noted in previous posts I have been looking at using supercapacitors however in this case going with a LiPo battery is probably best as it will allow the node to work overnight.

It would be therefore be helpful to have a method of monitoring the battery voltage both to allow easy experimentation but also allow the node to have some smart energy management (e.g if battery is low don’t transmit as often). Usually you would use a ADC with a resistor divider to read the battery voltage however the LPC812 (unlike the ATmega328) doesn’t have a full ADC. Luckily there are other ways of using the internal hardware in the LPC812 to act like an ADC and helpfully other people have already investigated this!

Method 1: Measure input VCC using comparator and resistor ladder

(Check out Jeelabs for more details)

This approach uses an internal resistor ladder and the internal comparator (decides whether the input is higher or lower then a reference). We setup the resistor ladder (31 steps) with Vcc and then compare the 0.9V internal reference with this. Starting at the bottom we work our way up until we find the step that equals 0.9V, and from there can calculate the input voltage. This is best shown with an example:

  1. We input an unknown voltage to VCC
  2. Setup the resistor ladder (each step is 1/31 of unknown voltage)
  3. Starting from step 1 we work out whether it equal or greater than the known reference voltage of 0.9V
  4. In this example we find that step 9 fits this
  5. Therefore 0.9V/9 = 0.1V per step and therefore 0.1V * 31 = 3.1V

I’ve been using this setup on my supercap nodes as they run without an external regulator to take advantage of the range of input voltages that the supercap can provide. However for the LiPo based node I need to use a voltage regulator for the GPS and so would need to have the LPC812 skip the voltage regulator. To try this out I cut the trace for voltage to the LPC812 and diverted it via a diode (to drop the voltage down a bit). While it did work I found that it was incredibly inaccurate as the difference that could occur with the battery (3.3V up to 4.2V) is only 3 steps difference.

Method 2: Measure Vcc using comparator and resistor ladder on ACMP_2

(Check out Nano-Age for more details)

Instead of measuring the input Vcc we can instead measure the battery voltage by passing it through a resistor divider and then into ACMP_I2 which is a fixed pin on PIO0_1 which on the LPC812 is pin 12. Unfortunately I’m already using this pin for SPI to the radio so had to cut the trace and due to the brilliance of the switch matrix I just had to move SPI0_SCK to PIO0_6 (10) and run a separate wire.

Using the code from the nano-age blog we can  use the function read_adc2() which uses the same concepts as Method 1 comparing the voltage to the resistor ladder. After trying a few different input voltage I was able to work out a adjustment factors to turn the reported value into a rough mV.

The main issue with this setup is the poor resolution, each step on my current setup equals 136mV and due to the range of the battery (3.3V – 4.2V) we are only going to get 7 steps (though more likely 6) but its better then Method 1.

Method 3: Delta-sigma modulation

(Check out Jeelabs for more information)

This is probably the best method as it creates a pretty good ADC rather than being stuck with using the internal resistor ladder. The approach is to use the comparator and an additional digital output to create a loop, varying the voltage to find where it matches and therefore calculate the input voltage. The code is a bit more complicated but is described really well on Jeelabs and will be great to get it working.

Current Setup

Currently I’m using Method 2 to measure battery voltage on AI4 but will eventually would like to switch to using Method 3 as it should give a lot better resolution. The code is currently setup using #defines for either #ADC (using Method 2) or #ACMPVCC (using Method 1) as it allows me to use the same codebase on different nodes.

Working with Supercapacitors

I’ve always been interested in using supercapacitors for powering UKHASnet nodes, its something about the simplicity of how you can use them. As I’ve been rebuilding my network I’ve wanted to put a solar powered repeater on the roof to add some range and so thought this would be an ideal opportunity to use supercapacitors.

The aim is to use a solar panel to charge a supercapacitor (with a diode in-between) and then to run a low power LPC812 UKHASnet node (running on my EtnaNode PCB). Supercap technology has come a long way in the last few years – high farad caps are now much more affordable. I therefore got hold of two 2.7V 15F capacitors from PowerStor/Eaton (HV1325-2R7156-R) and put them in series. This allows them to act like a 5.4V 7.5F capacitor (theory here), while we have lost capacitance it means that our supercaps can safely cope with the wide variation in voltage from the solar panel.

The LPC812 is running direct off the supercaps and so can measure its own input voltage which allows us to both keep track but also adjust our power consumption depending on how much is available. The LPC812 has its brownout circuitry turned on which means that when the voltage is low it doesn’t get stuck in a reset loop, once the voltage gets above 2.2V it’ll turn on and initially just act as a beacon. Once the voltage gets to 2.5V or above it starts to repeat packets, regularly monitoring the supercap voltage and if necessary going back to beaconing to save power.

AI0 is the current experimental node, its sitting just below the roof window and with the recent cloud cover is turning on around after 0930 and lasting to about 2100, the amount of time spent repeating is quite dependent on how much sunlight there is.

Now that the node is at least working partially I have some plans to make it work a bit better. Firstly some code changes including getting it to measure how much time it spends in repeat mode vs beacon mode as this will provide some useful information. Ideally I’d like the setup to survive the night, this might require the low power beacon mode to be extended further (perhaps a transmission every 5 or 10 minutes at night). I’m also currently looking at using the LTC3105 IC as a dc/dc step up convertor to make better use of the supercapacitors – in the setup I’m using now the voltage needs to climb up to at least 2.2v before anything can occur, with something like the LTC3105 it will be able to start doing useful things at 0.3V.

Setting up a UKHASnet Network

After moving house at the beginning of September have finally got round to rebuilding my UKHASnet network. Where I live now will hopefully be ideal as the house is 3 stories, with good views to the north towards the Kent North Downs.

First step was to setup a gateway, for this I used the old AB node connected to my old Macbook running a ruby upload script. As I’d moved location I had to reflash the LPC810 with the new location, despite it now having a new location it only sends the position on boot and with the current setup it misses that first packet – will have to have the new location manually uploaded to the server.

AB node:

  • LPC81022061246412_ca01df2288_o
  • RFM69HW running at 100mW
  • 1/4 wave wire (no ground plane)
  • USB-serial adapter (old aerocomm development board), also provides power.

On booting the AB node gateway I was pleased to see that AH6 node was still functioning, this is a Moteino (arduino) connected to an Adafruit Solar/Lipo Charger with a 2000mAh Lipo and a large solar panel. Its been outside for over 6 months and when I moved I placed it in the window (but not in an optimal position). It was still functioning 1 month later though the battery voltage had dropped to 3.54V and the node was in ‘zombie’ mode so was only beaconing. Again the node was set up to transmit the old location so needed to be programmed, opening the box I found that the lipo battery was quite puffy. I replaced this lipo with a rescued lipo from a old macbook battery, reprogrammed the node with the new location and have installed the node into the garden. Unfortunately our garden doesn’t get very muc21885827988_f2e4a2ab85_oh sunlight (as it is on the north side of the house) so it’ll be interesting to see how the node does over the winter.

AH6 node

  • Moteino (ATmega328 with RFM69HW)
  • Commercial SMA Dipole antenna
  • 6v Solar Panel (Voltaic Systems)
  • Adafruit Solar/DC/USB Lipo Charger
  • Plastic Container

Plans

  • Upgrade my car node (AH1) to new LPC812 node and add GPS, no battery so only transmits when the car is on.
  • Install solar powered node onto roof (probably magnet onto roof window) to act as well positioned repeater
  • Find local hosts for more nodes, will be interesting to see how if we can extend the range around Sevenoaks. If you would like to help out please get in touch.

UKHASnet Hack Weekend

Individual node descriptions to follow in future posts, pictures from Phil Crump and Dave Brooke

After much discussion and very little planning a group of 10 people meet up in Southampton for a weekend of hacking UKHASnet nodes. The plan was to spend Saturday building, programming and setting up UKHASnet nodes and then on the Sunday to head out and field test them. Before the weekend it was agreed to focus on creating a flotilla of UKHASnet buoys.

Saturday

ukhasnet buoy testing

On Saturday we all met up at the University of Southampton’s Engineering Department and set about working on build various UKHASnet nodes with a general approach of a sea buoy. Example nodes include AI2 (GSM/UKHASnet Gateway), QUAD0 (Quadcopter mounted node) and PFLOT0 (APRS/UKHASnet Gateway). Most of the morning and afternoon was hardware hacking and then in the evening we move onto building the ‘hulls’. We investigated a number of methods of waterproofing the nodes including jam jars, ‘tupperware’ food containers and water bottles. What was particularly difficult for us to get our heads around was making nodes heavy rather then the traditional push towards low mass for high altitude balloons.
By the end of the evening we have successfully tested (in the sink) 4 nodes which we hoped to launch the next day.

Sunday

ukhasnet beach gateway

jcoxon and AI3

Meeting the next morning at seaside car park of Milford on Sea (after some last minute soldering in the boot of the car) we set out to walk along the shingle spit that extends out into the solent which has Hurst Castle at the end. The weather was mildly overcast and warm though the wind did pick up quite quickly. Midway down the spit we decided to setup the 3G gateway and then proceded to launch the nodes out to sea. It was quickly noted that the wind direction and waves meant that you couldn’t just place them in the sea but had to try to get them as far out as possible which involved throwing them. The large AI2 GSM Gateway didn’t do well in the waves due to its top heavy design and additional buoyancy so this was then relegated to the beach. AI3, PFLOT0 and MBb were launched out to sea a number of times but each time they floated back to the beach.It was also deemed too windy to fly the quadcopter.

ukhasnet AI1 on mast

We then moved further up the beach, walking past Hurst Castle and found a space on the end of the spit, re-setup the gateway and then launched the nodes, because of the change in tides and the angle of the waves the nodes didn’t come back but continued around the spit. We were able to track the nodes, PFLOT0 and MBb were sensor nodes and either were rx’d directly or via AI3 which was both a repeater and GPS node.
We were able to track the nodes over a period of an hour out to a range of 660m, following the progress of AI3 on the map. The limiting factor was that our laptop ran out of batteries, the pay and display was running out of time and it was lunchtime!

Conclusion

Apart from the weekend being a particularly fun day it was great to see that some of the technology and hardware we had developed was working. We successfully had a 3 floating nodes and 3 beach nodes communicating between each other over a range of over 0.5km (and we suspect we could have got even further with some planning). It was also good opportunity to take the hardware and then build enclosures that could stand up to the choppy waves and also the extreme launch techniques.

Plans

  • Try again, build upon current hardware. Personally plan to explore the further use of jam jars as enclosures as they sit low in the water which improves their stability but does risk limiting their radio range
  • Launch on a calmer day and be able to fly the quadcopter node to extend the range of the setup
  • More of the floating nodes to have GPS and repeating capabilities
  • Extend range by having floating gateways (GSM, APRS or Sat)
  • Deployment from a boat to avoid drifting back
  • Suncream, a picnic and more batteries

Links

Playing Warhammer Shadow of the Horned Rat on OS X

Recently GOG announced that they had re-released Warhammer Shadow of the Horned Rat (WSOTHR), it brought back great memories of playing this exciting strategy game in my childhood. I rushed over to purchase it only to find that it only worked on Windows. Due to my experience with WINE I was pretty sure I could get it working so I went ahead and purchased it and downloaded it. Unfortunately there are somethings I can’t fix and WSOTHR in WINE is one of them (see here) – the main issue was getting 256 colours to work in OS X.

After failing with WINE I went for the brute force approach – emulate an 90s PC on my Macbook, run Windows 95 and then run WSOTHR. First step was to get hold of the latest QEMU source and compile that on my Macbook – this was pretty easy though I recommend that you chose to only compile the 386 processor to save time, power and space.

Once you’ve got QEMU working I then got hold of a ISO of Win95, there are a number of places where you can find this – I suggest you search for Win95 and ISO and see what comes up. Roughly following this guide:

  1. Create a hard drive: $ qemu-img create -f qcow win95.disk 2G
  2. Run the emulator with the newly created hard drive as hda and the cdrom pointed to the Win95 ISO you’ve found. I recommend you go for a bit of ram as it’ll speed things up (see the -m 128)  $ qemu-system-i386 -L . -hda win95.disk -soundhw sb16 -M pc -m 128 –vga cirrus -cdrom win95_osr2_en.iso
  3. Install Win95 onto the hard drive, this took a couple of goes as it hung in a few places but finally managed to install.
  4. Boot up in to Win95, you might even get the classic tone coming through your speakerswin95boot
  5. Next you need to install some cirrus VGA drivers to get the display to use 256 colours as well as create a ISO (CD Image) for WSOTHR.
    1. Download an original copy of WSOTHR (obviously having purchased GOG or owning an original), again this is a matter of searching online
    2. I created a ISO image of WSOTHR as well as a cirrus driver (I used GD54461.41.EXE), I used Disk Utility on OS X, when you make an image ensure that you select CD/DVD Master and FAT as the format.
  6. Now you can boot Win95 but change the cdrom from the win95 iso to the newly created iso:  $ qemu-system-i386 -L . -hda win95.disk -soundhw sb16 -M pc -m 128 –vga cirrus -cdrom Master.iso
  7. You can now install the cirrus VGA driver, switch to 256 colours and then install WSOTHR
  8. Now you can play – CHARGE!

win95play

Conclusion – it runs pretty well, my Mid 2012 Macbook doesn’t burst in to fan while playing which is good though it isn’t the quickest running, you can turn some features on and off to see if that helps. The only real issue is that the cut scenes don’t work but this might be due to the copy of WSOTHR i’ve got. Otherwise I can now play an awesome game of my childhood/teens – it wouldn’t be difficult to install some other games such as C&C…

Redsands Sensor Node (RED1)

As well as a full repeater node powered by a solar/lipo combination I’m planning to install a second smaller sensor node on Redsand Forts. The aim will that the sensor node will pass data back through the main RED0 node and therefore it doesn’t need to be ideally placed for reception. Sensor nodes don’t repeat data and therefore can turn off their radios in between beacons saving considerable power. It therefore will run just on batteries.

  • ATMega328 DIP chip
  • RFM69HW
  • MPL3115A2 i2c Pressure and Temperature Sensor
  • Stripboard
  • MCP1700
  • 2 * 3 Lithium Energizer AA
  • Sealable box

The node will be re-using the original AB node board (which has now been replaced by a Moteino + Moxon). I’ll be adding a spare i2c sensor board and using the sparkfun library. Antenna will be a 1/4 wave ground plane out of the top of the box.

Developing a remote UKHASnet node

For the past 6 months I have been working on a prototype UKHASnet node which is completely powered by solar. The aim is to install a UKHASnet node on the Redsands Forts out in the Thames Esturary where it will function independently both providing simple sensor data but also acting as a long range repeater. The Redsands forts were part of a larger set of WWII Anti-aircraft defences that were decommisioned in the 1950s but then used as sites for pirate radio. More recently Project Redsand has been repairing and preserving these 70 year old forts.

The Redsand forts can be seen from the North Kent coast as well as Essex and so a well placed repeater should allow a potential bridge over a significant distance. As the forts are difficult to get to the node will need to function independently and will need to be hardy to the elements. Project Redsand have kindly agreed to allow me to visit the forts when they go next and install the node.

The current node design is:

  • Moteino R4 – arduino/RFM69HW
  • 6V 2W Voltainics Solar Panel
  • Adafruit USB / DC / Solar Lipo charger
  • 2000mAh Lipo Battery
  • 868Mhz Dipole Antenna
  • Sistema Klip It Storage Container

The node has been installed outside in my garden for almost 6 months as I’ve tested various bits of software and settings. Currently it is install on the roof of our extension with the solar panel angled slightly and facing south east. The node will remain in repeating mode unless the battery voltage drops below 3.66 where it’ll go into a ‘zombie’ beacon mode. This setting has allowed the node to function for a number of weeks of winter weather with limited solar charging. For the last week it has managed to charge sufficiently to remain out of zombie mode.

ah6_feb_volt

The current prototype is named AH6 and can be followed on the ukhas.net website. It will continue to function in its current setup while I wait to go out to Redsand Forts and install the node – at that point I’ll change its node ID to RED0.