So i am on the 4th iteration of this board and I have just about got it right. Kind of sad that its taken me so many goes to get this right, but what can i say. LOL. There is still one bodge wire on the backside of the board because I somehow left off a trace joining one row of push buttons off the 5v line. I am also not sure about the 5V regulator, its running very hot and it should not because its should only have about 300ma running thought it and there is no short to ground anywhere i can find, to explain it running so hot. By hot im guessing its hitting over 60 Deg C as its painful to touch.
Anyway, back to the point of this post. I have gotten back into coding things up and am making inroads. It mostly works now. Pressing the mode button will cycle through LSB, USB and CW. The band button will cycle through 80, 40, 20 and 15m the 4 bands that this radio will support, selecting the appropriate filter banks for both Low Pass and Band Pass filter boards as well as change the IF filter to a narrow CW filter in that mode.
The logger button will put it into logging mode, which along with a keyboard will make log entries and save them to SD Card in ADIF format. The logger is loosely based on my old arduino logger code which can be found in the menu bar above. Though, the code that is going into this is much more refined and polished and fixes most of the clunkyness that was in the earlier versions. I am a much improved programmer now than i was a few years ago when i wrote that code.
The VFO button will exit the logger and put the radio back into VFO mode. I still need to add in a couple more push buttons, one to change the Attenuation setting and the final one to allow changing the TX RX offset. At the moment it is hard coded for a 600hz offset for CW operation, but, i am going to make that variable for real split operation in SSB as well.
Anyway, that is where I am at with this at the moment. When i get things closer to being done, I will probably make a video of all the functions in action to put on youtube. But that is likely to be a couple of weeks away yet. Lots of work to be done in the mean time.
So while working on the code for the control board part of the receiver project, I came across an interesting conflict. The keyboard and the rotary encoder did not want to play nice with each other than and the compiler was spitting out an error about a vector conflict. Keyboard worked fine by itself and the rotary encoder worked fine by itself but put the code for both into the once program and the compiler went bonkers.
So i set about learning everything i could about interrupts on the Mega 2560. And this was where the fun began and i ended up going down a rabbit hole from which i was lucky to escape. Well i did survive and i did actually learn about interrupt vectors, pin change interrupts and external interrupts and a little about library conflicts along the way.
So this is not really a tutorial on using interrupts or the differences between pin change or external, but rather a rant about the 2 hours I spent last night reading and trying to understand what I had done and why there was a conflict. In the end it was because i programmed the rotary encoder to use pin change interrupts and it was the library i used that was in conflict with the keyboard library. I did not know that was what i had done, i had assumed that using pins 18 and 19 on the mega, being the external interrupt pins just worked in one way only. But no no no, they can be either external or pin change interrupts depending on how you code for it. Yes, a very rookie mistake.
So after finally working out what I had done wrong, or in reality why the libraries were in conflict, i changed 2 lines of code and had the rotary encoder working as it should be with the keyboard and everyone is happy. So at the moment I have a working keyboard, rotary encoder and VFO and now that my work week is done, I will hit the code hard tomorrow and make some real inroads into getting features in there that I want in my radio. Its not going to be as pretty as the Nextion vfo codes that are floating about the internet, but its going to be all mine. And sometimes, its good to know you have rolled your own and it does what you want.
Easter has been quite productive for me, this is project 3 out of 4 is rechargeable battery powered arduino clock with temp and humidity function. Nothing fancy, but highly practical and accurate. The code is a mess, but i have shared it down below, i know someone out there can clean it up and make it more efficient, but for now, its working and doing what it needs so, show the temp and the time.
Hardware is kind of inefficient for this task, arduino mega and 3.2″lcd are both overkill and power hungry. There is an RTC and temp humidity sensor, 18650 battery, boost and charge controller. As usual i did a really crap job at cutting the hole out, I really should have done this in the CNC, I might even make a how to video on how i do that later today.
#define DHTPIN A0
#define DHTTYPE DHT22
TFT_HX8357 tft = TFT_HX8357();
DHT dht(DHTPIN, DHTTYPE);
const long interval = 60000;
unsigned long previousMillis = 0;
bool Century = false;
unsigned long currentMillis = millis(); //Do stuff here every 60 seconds
if (currentMillis - previousMillis >= interval)
previousMillis = currentMillis;
tft.setCursor(10, 10, 1);
if (L_Date < 10)
if (L_Month < 10)
tft.setCursor(30, 100, 7);
if (L_Hour < 10)
if (L_Minute < 10)
tft.setCursor(20, 280, 4);
tft.setCursor(260, 280, 4);
humid = dht.readHumidity();
temp = dht.readTemperature();
L_Hour = Clock.getHour(h12, PM);
L_Minute = Clock.getMinute();
AmPm = "pm";
AmPm = "am";
L_Date = Clock.getDate();
L_Month = Clock.getMonth(Century);
L_Year = Clock.getYear();
L_Year += 2000;
DAW = Clock.getDoW();
DayOfWeek = "Sunday";
DayOfWeek = "Monday";
DayOfWeek = "Tuesday";
DayOfWeek = "Wednesday";
DayOfWeek = "Thursday";
DayOfWeek = "Friday";
DayOfWeek = "Saturday";
DayOfWeek = "ERROR";
What a day, what should have been a simple job, for a simple man turned out to be an all day endeavor to overcome a litany of problems. In other words it was a fucking disaster. LOL but hey, i got there in the end and now the weather station is about to be put back out in the weather to do its thing. So lets see, what went wrong, well the sensor i was using was different from the previous one, so i needed a different library, then the device address was different to what was in the code, then the micro controller I was using shit itself and died, then i had problems with my computer not recognizing USB devices, then the board library was being a pain in the arse and needed upgrading, and finally there was this problem with crashing because dumb arse here created an array and was causing a stack overflow because the array had no size.
Well, after all that, I now have a pile of crap on my bench destined for the bin and a nice space on my bench where the weather station used to be. This time i have spares and should be able to fix things if something breaks without having to wait months. Its been down for 5 weeks, and thankfully its back up and running. For now, touch wood. LOL. Now I need to create a page that will query the database and display the data.
Its been a while since i have posted anything to do with electronicals and as i have been tinkering with the its been taking forever weather station i thought i would post an update.
The major change has been to the power system. I found these rather cool Wemos 18650 boards that take care of charge, voltage boost etc etc for a couple of bucks. The specs are perfect for all sorts of projects and will match up perfectly with the 6V solar panel i have to go with this and will charge at a max of 0.5amps. The cheep lipos have a combine capacity of 3.5amp hours, and the project atm draws about 0.1 amp hours, so good for say 30 hours without sun, which in Brisbane should be more than enough, if not I will buy some real lipos and use them instead, but, once i start dropping the micro into standby, that current draw will drop dramatically.
I have the code all working for the modules installed, humidity, temp, pressure, rain, I still have Lux and UV sensors to install. The code will poll the sensors every 15mins, save the data to SD card and push a copy of the data to my home server where I am still working on a web interface and graphing to display the data. High and Low data for the day is saved at midnight and pushed to the home server also.
And not to be outdone, I have even done some woodwork and 1/2 built a house for this which will then get installed in the garden. Also I have coming from china a rain gauge and depth module for measuring how much rainfall there has been, the rain sensor i have in the above image just detects rain, not how much or how intense it is.
I ran into a little bit of an issue with the old power management system i had installed. The original design was to use a buck converter to drop the battery voltage to 3.3v, this worked fine except the micro controller would not run with 3.3v it needs 5v, so much for reading the manual which said it ran on 3.3v. So then I added a boost converter, except that the BMS would shut down when it was connected.
So onto plan C, i ripped out the BMS, the charge controller and the converter, and am now using an all in 1 unit that is designed to work as shield board for the wemos mini. USB cable will run to the solar panels to charge the lipo’s, the jst connector goes to the batteries and power out is from the 5v pin on the shield. Yeah its ugly, but will work. The 3.3v needed for the sensors will all run off the regulator on the micro. Its a mess, but will work.
Now that crap is sorted, its time to finish off the code and make it work. Thats a job for another night.