New Fish

Long overdue update – the tank is going well, but there are a number of obstacles I’m currently trying to navigate.

The good news, finally purchased a pair of Apistogramma Caucatoides Double Reds. They are beautiful fish and I’m loving them so far.

The problems, in no particular order:

  • Covid-19 has really thrown a wrench into the tank – among other things.
  • I recently installed a Raspberry Pi running Node-Red and a Mosquitto MQTT broker. This acts as the main hub now. All of my esp8266 and esp32 boards communicate with Node-Red on the Pi. Fantastic system.
    • The problem is that there is something fishy going on – I am not sure if the Pi is overheating or if something is causing esp32 that run the lighting system to falter, but the automations stop after a day or so. Ordinarily, I would be home to trouble shoot, but with the pandemic still flared high, I am staying with my partner at her house and can’t be home to problem solve.
    • I am fairly certain the problem has something to do with the Micropython code I wrote. I’ve been learning more about try & except statements and it seems like this could be the culprit. Essentially, something in the program periodically throws an error which stalls the program.

  • A follow up problem to this issue with Node-Red umqtt automations is that it will fail with, obviously, the lights on or the lights off. So either the tank experiences 48 hours of blasting light or 48 hours of darkness. I’ve been stopping by my house every two days to check in (safely).
  • This, in turn, has kicked off some serious algae growth. Nothing too crazy yet, but without vigilant monitoring, I’m having trouble both understanding what is happening as well as well as fixing it.
  • As stated in previous posts, my naturally hard water is probably not making it any easier. I have added Indian Almond leaves, but I think CO2 is necessary. I purchased one of those cheap DIY baking soda/citric acid reactors, but it is not working very well. Depending on how the future shakes out with everything, I am seriously debating purchasing a proper regulator and pressurized co2 cylinder.
  • Also, due to Covid-19, I haven’t made it out to any pet stores recently to restock on food. The new cichlid don’t love the cheap flake food the guppies eat and I just ran out of frozen blood worms. I’ve been digging up earth worms for the Apistos, but I am not sure if they are big enough yet to go after earth worms.
  • I’ll be receiving a package of frozen food today, along with a few new aquatic plants (because why not) and some brine shrimp eggs. I’m going to try raising some baby brine shrimp and see how they do in terms of food for the Cichlids.

On another note, my lights are up and working. As of now, they are triggered by a MQTT message from Node-Red on the Pi. Its okay… but not cool enough, so I’ve order a pcb with 5 Meanwell LDD 700 PWM drivers. I’ll be using this to control the lights eventually. The advantage to this is that you can control the duty cycle on the LEDs with the drivers and thus the dimming/brightness of each LED string. So essentially, colour mixing with Red, Blue, Cool White and Warm White. I have to figure out what to do with the 5th driver.

I’ve written a code that can be triggered by MQTT and run transition fades from one duty cycle value to another. You would have to call these functions within the section listening for messages from the MQTT broker.

from machine import Pin, PWM import utime # This is still in BETA testing.  # The below light() function transtions between start value and stop values by increments as stated in the increase_X = variable.  # Still need to develop all of the various transitions and write the MQTT stuff.  r = PWM(Pin(16)) b = PWM(Pin(17)) ww = PWM(Pin(18))  cw = PWM(Pin(19)) def dark_sunrise():     red = 0     blue = 0     cool = 0     warm = 0     increase_r = 1     increase_b = 2     increase_cw = 3     increase_ww = 4          while True:         utime.sleep_ms(30)         while r.duty(red) != (1000):             if red > 300:                 print(str(r.duty()) + ' r.duty') # print() statements are for testing                 print(str(red) + ' red lights')                 break             else:                 print(str(r.duty()) + ' r.duty')                  print(str(red) + ' red lights')                  red += increase_r             break         while b.duty(blue) != (1000):             if blue > 300:                 print(str(b.duty()) + ' b.duty')                 print(str(blue) + ' blue lights')             else:                     print(str(b.duty()) + ' b.duty')                 print(str(blue) + ' blue lights')                 blue += increase_b             break         while cw.duty(cool) != (1000):             if cool > 300:                 print(str(cw.duty()) + ' cw.duty') # print() statements are for testing                 print(str(cool) + ' Cool White')                 break             else:                 print(str(cw.duty()) + ' cw.duty')                  print(str(cool) + ' Cool White')                  cool += increase_cw             break         while ww.duty(warm) != (1000):             if warm > 600:                 print(str(ww.duty()) + ' ww.duty') # print() statements are for testing                 print(str(warm) + ' Warm White')                 break             else:                 print(str(ww.duty()) + ' ww.duty')                  print(str(warm) + ' Warm White')                  warm += increase_ww             break         if red > 300 and blue > 300 and cool > 300 and warm > 600:             break

Micropython and new horizons.

I have almost no real programming experience. I am ‘okay’ with computers, but most of it was all high-level UI kind of stuff. When I decided to get into Arduino as a hobby, it was because I knew that there were open source options for all of the IoT stuff coming to market, but I had no idea how to engage or hack any of those products. It seemed to me that a Google Home couldn’t be that complicated – or that a smart light was essentially just a wifi enabled on/off switch, which should be similarly simple.

I wasn’t wrong, but I wasn’t exactly right. Figuring out something as easy as a wifi controlled relay leads you into this world of computer science, programming languages, hardware compatibility and github (which I knew of, but was fairly intimidated by). I don’t know if diving into this rabbit warren was a necessary step or something particular to my personality (I am often confused by things until I can begin to understand their context.), but dive in I have been.

Arduino is a language based on C and C++. The underlying structure of the language is widely used and the Arduino language was developed by a helpful and dedicated community of people. Because of its legacy as one of the first hobby accessible microcontrollers, there was a concentration of people developing the language. But there are two limitations that I have encountered.

  1.  Because Arduino is based on a more complicated low level language (C, C++), writing new libraries and such requires substantially more ability and know-how than the casual hobby-ist. Luckily, the number of people more talented than I writing these libraries and code provides a wealth of examples and templates.
  2. The arduino IDE where you write the code needs to compile everything and translate it before loading it on the board and running it. This means that your workflow goes like this – code > compile > upload > run > error/unitended things > back to code > compile > upload > run > error/unitended things > back to code > compile > upload > run > etc etc. This means that it is difficult to quickly test and problem solve issues in your code, it also means that you spend a significant amount of time waiting to compile and upload code only to discover you made a typo somewhere.

This is where Micropython comes in. I came across micropython while experimenting with the ESP32 from Espresif. What an amazing little chip! I learned that Micropython is an implementation of Python 3 that was designed for the specific hardware constraints of microcontrollers.

Python and in this micropython has this wonderful little thing called a REPL. It allows you to pass code to the chip in real time and test out a section.like this:

>>> print(‘I am writing this in the REPL’)
I am writing this is the REPL

Python really is an elegant language. Very intuitive. The visual syntax of it is very clear and easy to read. For someone without much experience programming, it has an easily graspable internal logic.

The problem is that although its quite beautiful, it is far less common than Arduino and the number of libraries is far smaller. Now, you can leverage the huge python community for help, but there is going to be some stuff that doesn’t line up in the transition between a Python 3 and Micropython. Add to this the large number of hardware specific (relative to the size of the language) that have been made for various hardware… pyboard, circuitpython, microbit etc.

So, in a sense I am extremely excited by this new direction while also cautious … I think this will make me better at coding, but it might slow down the riparia project a bit.

So far I’ve written a few rudimentary scripts – a water level sensor that triggers a pump to top off the tank, a rudimentary light timer and a very basic thermostat/incubator for a horticultural project. All are just practice and proof of concept kind of things, but its exciting.

As always, the next big step (aside from adding more complexity to the operations) will be linking them to the net and getting wifi control, IFTTT hooks and wifi data-logging.

I really want micropython to surge, but also wondering if it makes more sense to run Python on a Pi Zero or something else.