I’ve always had an itch to try out new ways to get somewhere. I guess I got that from my father; he’d be admonished by mother for wanted to try ‘shortcuts’ when driving which often resulted in back-tracking or otherwise ending up lost – and when lost means the middle of the Australian bush that is very lost indeed. His knowledge of remote country roads was only matched by his seeming disregard for transition from single man into family patriarch and the responsibility that entailed. I don’t want to paint a picture of someone who was frivolous or ignored safety, but at his heart there lurked an element of wildness.
So too for me. Before GPS, Google mapping every road in the world, and mobile phones I would study maps and work out that there may, just may be another way to get from A to B. I really enjoy the path less trod, understanding a new contraption from more than just the instructions, and trying new experiences.
I have for many years enjoyed a personal computer from Apple. Having used hundreds, if not thousands of computers during my time in IT, I fully appreciate the fundamental advantage of a Macbook: it just works.
I’ve now passed this older laptop to a member of the family and are now using a newer work machine, but need to keep both work and leisure separate – so I run two different browser windows with the ‘left’ one covered in employment related tabs, and the ‘right’ one open with personal items such as my home email. The method seems to work although I too often find myself at the wrong end of the spectrum, so to speak.
It reminded me of some of the dating apps that use the ‘swipe left, swipe right’ idea of approval – only my swiping is replaced by the MacOS idea of four-fingered strokes left or right on the enormous Macbook Pro touchpad. And oh – the Pro is a very enjoyable type of machine.
I’m really impressed by my internet provider, Andrews and Arnold. I’ve used the internet since before it was named, and Fidonet, 1200-baud modems, bonded twin ISDN lines and the whole shebang. Today’s FTTC and ADSL are fast and simple in comparison.
However the last physical leg is often the source of issues. Trees rubbing on telephone lines, storms, and cable modems losing sync when it rains are all part of that ultimate physical connection to my home. Even mobile data via 4G gets rain fade in a heavy rainstorm. A wet piece of string will still transmit a signal, but it will be pretty weak.
When I speak to my sister in remote Australia it seems that they are lucky to get even a mobile phone signal when standing in a particular corner of one room of their house. There is no internet via land-line, and often reasonable internet connection is only available from her office in the town. Netflix and streaming movies, Facebook and the like are all distant, unreasonable realities and for many people in developing nations. So my little worries and 80Mb per second seems like luxury. My quota is 1Tb per month, but I rarely reach that. I am also served by cable and could use that but the latency is too great for good gaming.
So I’m pretty happy with my internet connections!
Having obtained the raw protocol description from the vendor, I confirmed many of my earlier observations and now have a working system which can read the information. Like many programmers I approach the problem in a step-wise manner by getting each element working in turn and refining my solution. These are the steps I took so far:
- Obtained and assembled hardware, including a XY-017 TTL converter in a USB stick. This is used to read the incoming RS485 protocol.
- Attempted to read anything from the USB interface. I developed a program (‘disp.py’) to do this and the results are in the Git library.
- Cycle on #3 above until satisfied.
- Started work on a simple sending program on a Pycom LoPy which transmits to my LoRa antenna in my loft. I’d previously got the whole LoRa thing working hardware assembly and work on connecting to The Things Network.
- Vacillated for a few months. Hey, this is a hobby!
- Created a program to read the incoming message from MQTT as The Things Network publishes all incoming messages on a MQTT broker, and by subscribing using the appropriate keys you can read the raw messages.
- Decomposed the messages by using ctypes library on the CPython implementation, and uctypes on the MicroPython implementation.
This latter stage wasn’t so easy, as having muddled through to gain an understanding of how ctypes works and mapping the fields, I then had to learn a new way of mapping bit structures since MicroPython tries to be helpful by removing all the challenges of endian architecture in their implementation and it works different to CPython. It took a good chunk of time to get the normal Python working, and then realising that I had to grok something that looks completely different.
I’ve written some small-n-dirty test programs to make sure I understand this new aspect of MicroPython, and then I will implement it in my actual program running on the LoPy. I also need to create an accumulation as not all data will be sent immediately, and also turn off WiFi radio and set the IoT device into low power state. Lots more fun along the road.
I’ve just received a nice new ‘headless’ weather station from China, and I am engaged in connecting to its RS485 feed and understanding the protocol. They supplied a RS485-UART USB stick with it, and after playing around with some containerised NodeRED flows which couldn’t read the USB finally just used PySerial and have started dumping the data. Although it is advertised with the tag line “we will supply the communications protocol” this wasn’t forthcoming so I just dumped the bits down on the screen and have started reading them. Apparently they are a Fine Offset type of station and equivalent to the WH2950 type, without the monitor or network link. It’s all down to me!
The bytes look like this:
24 B3 7A 62 61 46 00 00 00 00 00 01 00 00 00 48 A3 $.zbaF………H.
24 B3 7A 62 61 46 00 00 00 00 00 00 00 00 00 D3 2D $.zbaF……….-
24 B3 7A 62 61 46 00 00 00 00 00 02 00 00 00 D4 30 $.zbaF……….0
24 B3 7A 62 61 46 00 00 00 00 00 00 00 00 00 D3 2D $.zbaF……….-
… which is fun. I quickly worked out that the standard size was 17 bytes, now I have run it through a hex dumper and started eye-balling the bytes. I may need to spin the anemometer to generate events to get readings, but this looks good.
I’ve also now connected it via a LoRaWAN link and have the data flowing back to me via MQTT. I need to compress the data as well as recording and averaging the readings, since the standard interval time of 16 seconds would exceed the fair-use policy of The Things Network. Meteorological masts (or ‘metmasts’) conform to an IEC standard, but mine can be much less rigorous than that: I’ve decided to take ten measurements and transmit the min/avg/max of them every 160 seconds. Given enough compression I think I can get the seven measurements (wind speed and direction, temperature, humidity, UV, lux, rainfall) into less than 10 bytes.
The git repo is up on BitBucket.
I’ve just encountered one of the interesting aspects of our drive to buy everything online: emergencies. It used to be that when you lost an item, say a power cord for a computer, that you would ask a friend or colleague, or go to the shops. With the push for ‘everything online’ that last choice has disappeared.
In the 90s there were many places where you could find spare items for your travel kit. I often added to my kit bag when travelling through an airport–the electronics shops there had lots of things including mosquito zappers, bug spray, ear buds, headphones, travel pillows, clothes detergent, and many odd fitments for your average travel worrier. Failing, the absentminded would exit their warm hotel and venture into the local shops to buy things from many places which stocked bits and parts. They used to be as frequent as nail bars in my local shopping area.
Now, along with the growth of fixed-price betting shops (and those nail bars), I miss those electronics shops replaced by endless coffee bars and empty hoardings. So commerce has moved online where prices are cheaper, but the immediacy of picking things up when you wanted has gone and I’m back to ‘making do’ for two days while my latest purchase is delivered.
Long way back I read a book which spoke of four types of personality. Nowadays we recognise five broad trait dimensions or domains, sometimes called the “Big Five”: Extroversion, Agreeableness, Conscientiousness, Neurotic-ism, and Openness. The 1960’s book wasn’t to blame for only choosing four since even longer back people talked of four elemental substances, such as earth, water, air, and fire. Especially the ancient Greeks, and they had some pretty good ideas.
But regardless – a personality type of ‘melancholic’ was one of the four types and these types of people were meant to be more prone to moodiness, feelings and deep thoughts.
I reject this now. My whole life experience suggests that instead of general types of people and categories into which they fall, that rather everyone has umpteen dimensions and lies in a spectrum along each of those. So I may be good at one thing and bad at another, while my neighbour is average at both. The point being that there is hundreds, if not thousands of these dimensions and everyone has them in different quantities and qualities. Understanding people through a lens of a specific type is almost as useless as handwriting analysis, which simply tells you that the writer is a person with human features – and yes, I read lot of books about that as well before realising that just speaking to someone for five minutes would reveal far more than hours of looking at their handwriting.
So when I ‘feel’ melancholy I associate it with a certain type of mood, or a combined feeling of warmth, wonder, content and amazement at things. I know that the word is meant to evoke deep feelings of gloom and pervasive sense of impending event, but I associate those more with depression and a lack of ‘agency’, or the ability to impact my own existence. I think some Heidegger, Sartre, or perhaps just plain Thoreau would be good at this part!
I eventually went for a small SX1301 based LoRa gateway from RAK Wireless, the 831 and now have that running in my house network. Radio frequency work is different to SBC/MCU work and is a lot more ‘physical’ in the sense that you need to think about the radio frequency and antenna patterns. That’s a whole new / old world for me – and one which I thought I’d left from my childhood days.
I grew up in a country town where one of my leisure activities was being part of a ‘radio club’ for amateurs, also known as ham radio enthusiasts. These were the days of CW McCall and the song Convoy so I heard a lot of 10-codes used when travelling in cars. Our radio club toured commercial radio sites as well as taking part in radio jamborees, and constructed some monstrous antennas to pick up radio signals from all over the world – so I got familiar with terms like baluns, impedance matching, dipoles and yagis. Radio is amazing, does weird things and in my estimation just a little easier to understand than quantum mechanics. I never did get my Morse radio license though it may have been useful, and regret that now.
Setting up the RAK831 with a partner Raspberry Pi, initially using the jumper wires to connect them was easy and I soon got a signal through on LoRa. It seemed pretty simply just to follow the recipes on the internet as the device is based around a IC880a chip and there are plenty of code examples up on GitHub. My node devices are LoPy from Pycom and as they used MicroPython are pretty familiar from my work around e-ink displays. I registered the gateway with The Things Network and have it receiving stuff now, even if it is sitting on my filing cabinet and needs to be placed into a IP56 gray box and fixed to the wall.
I drilled through my house outer wall and poked the antenna out there, one of those ‘rubber duck’ type mono-pole ones, I think it is quarter wave but works quite well. Then registering on the ttn-mapper website allowed me to start mapping the reception from a smaller, hand-held LoPy transmitting a sequence of “1234” in a 30 second delayed loop so as not to abuse the duty cycle of the 868 ISM band. The results were both disappointing and amazing – amazing that such a short antenna transmitting/receiving can get anything and pass it back to the internet, and disappointing that it can’t be heard in behind some local buildings.
I’ve a couple of thoughts on this: a quality antenna such as a half- or full-wave may be better, orientation of the receiver (it is horizontal now) may be important, elevation could be critical, and not placing it on one side of my house but instead the roof so that it isn’t blocked by a close building may all improve things. But for my first simple use case that I want to merely ‘hear’ my small environmental sensors I think what I have now is probably sufficient!
I’ve been interested in replacing my environmental sensor network that ran on an older communications protocol with a LoRaWan gateway and a set of button-battery sensors. Just today I started that journey using a couple of the excellent Pycom LoPy boards. This will give me the capability to measure things, and connect to a gateway using a single-channel LoRa environment.
Although I will register this with The Things Network, as it is initially not a true multi-channel gateway it probably is wise to limit it as a private gateway and not as an open public one, since the actual throughput and channels will be limited.
I’ve looked on AliExpress and there are other gateways available, although not cheap enough to consider as a impulse purchase. Some of these are based on the SX1276 and some on the SX1301. One seller even had a convoluted explanation why they still used the SX1276 rather than the multi-channel SX1301 but written in a very stilted Chinese-English hybrid and as it quickly descended into a dialogue with a block of cheese so I abandoned trying to think it through. Apparently the SX1301 needs to be front-ended by a couple of other radio-handling chips so likely is more difficult for OEM board manufacturers to build, so perhaps it may be best to avoid them until the prices drop on the multi-channel LoRaWAN gateways.
Instead I have gone with one from RAK Wireless married to a Raspberry Pi with a daughter board, and just working through the strange Reverse Polarity SMA connectors which they need to use for FCC certification so that I can glue my antenna on the outside wall.
Packets are streaming through from my PySense node so things look good for a deployment using this model.
As mentioned before, I purchased a Lattepanda as a single-board computer for running Windows 10. This works great, although the Intel Atom chip runs a little hot and needs extra cooling.
The main purpose of this is to run my Seneye aquarium monitor, so it needs to fit under my aquarium along with the other items that I’ve built to automate my fish hobby. This means an IP56 custom housing which presents me with a challenge: how to get heat out of a sealed box?
In the end I have decided that a completely sealed box is unreasonable, although you could imagine a small water-cooled one with the radiator external to the sealed box. Air holes drilled into each end and push/pull fans drawing the air past the computer board seemed to be an excellent idea as the Intel chip runs very hot. There were some challenges:
Getting a USB cable through a grommet
Did you spot my problem? It is in the bottom right of the photo. I was able to get a small micro-USB through a 10mm grommet by removing the sealed cable end, however I now have a bigger problem in that I need to get a USB-A type plug through to service the Seneye SUD device. For that I am using an external USB female panel mount and connect that to the USB input on the computer.
Switching it on and off
Another issue is that the LattePanda has a curious boot-up sequence. First you ‘switch it on’ by supplying power to the USB lead which goes through a sequence of blinking red and blue LEDs, then into a quiescent state of blue LED only waiting for you to trigger the Windows boot. This is done by pressing the ‘on’ micro button on the side to start the boot. But the real issue is that in a sealed box this will not be possible – I have to find a way to click that micro-button externally.