LowPowerLab Forum

Hardware support => Projects => Topic started by: syrinxtech on June 29, 2020, 11:21:41 AM

Title: A testament to Felix's Mega
Post by: syrinxtech on June 29, 2020, 11:21:41 AM
UPDATE: all new posts are now in this thread (https://lowpowerlab.com/forum/projects/a-testament-to-felix's-mega/).

I just wanted to give a shout out to Felix and his Mega.  Here's a list of what's currently connected to the Mega.  There are only 5 digital and one analog ports open.  There are two I2C devices connected and I still need to add an INA-219 to measure the current of the lipo's.  Way to go Felix!

Mega with HW radio
N/O rocker switch
BME280 - I2C
Adafruit GPS (Serial1)
Adafruit GA1A12S202 Analog light sensor
ML8511 UV Sensor
Max9814 Microphone
SD Cardreader - SPI
Tri-Color LED

The microphone can be remotely activated and record up to about 9 hours of audio and save in WAV format onto the SD card.  All of the GPS and environmental data are streamed over the RFM69 to another Moteino which grabs and displays the data.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 07, 2020, 10:53:40 PM

1.  Adding the Adafruit SI1145 UV/IR/Visible light sensor to get a "true" UV Index reading.
2.  Converting the RFM69 radios to LoRA for greater distance at slower speeds.
3.  Finished the menu system so I can send remote commands to the unit and have it respond with data to the logging device.
4.  Just received the INA3221 so I can start getting electrical telemetry readings.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 12, 2020, 07:51:05 AM
Well, the LoRA Mega, INA3221 and the SI1145 came in over the weekend.  I won't be able to install them until this Friday, but I can't wait to get the new parts installed.

I also ordered a small fan (about 1.5" square) and the DS1631 thermostat chip which should be here in several days.  I'm going to use an ATTiny85 to create an "autonomous cooling unit" for the rover.  When the DS1631 detects a temp of 90 or greater, it will raise a pin which the ATTiny will read and turn on the fan through a power FET.  The unit will also have a small Lipo with a solar panel to recharge.  If my calculations work, it will be able to run independently of any other systems and cool down the inside "forever".
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 16, 2020, 10:22:03 AM
What to add to the rover that has everything?

Why, a vibration "theft sensor" of course.  Right before the MCU goes to sleep, I read a vibration sensor for 1.5 seconds.  If it detects vibration (calibrated to exceed normal movement), it will send out a log message and sound the buzzer.  I know it's over the top but I am trying to cram every conceivable option into the design.  I'm officially out of pins on the long breadboard but the Mega is still running strong.

Hopefully swapping out the RFM69HW for the LoRa this weekend, along with upgrading the UV sensor.
Title: Re: A testament to Felix's Mega
Post by: Felix on July 17, 2020, 09:57:29 AM
Wouldn't you need to read that vibe sensor all the time though? Vibes can occur at any time.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 17, 2020, 02:42:36 PM
In loop(), just before I put the Mega to sleep for 8s, I count millis() for 1.5 seconds and read the vibration sensor.  The thinking is that if you're walking away with the rover, it will catch you after the next 8 sec cycle.

Just upgraded the UV sensor to the SI1145.  Working on the LoRA radio conversion now.  Using the arduinolibs crypto library to keep encryption with LoRA.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 18, 2020, 07:36:10 AM
Well, after spending a few hours trying to get the "arduinolibs" encryption package working with the RadioHead LoRa drivers, I gave up and took a break.  I started on it again and actually reached out to the author.  Rhys was incredibly responsive and answered my questions and I got the encryption working with the Speck cipher.

Then I ran into another problem because I wanted to overlay the encryption with the RH95 driver and the RHReliableDatagram manager.  I couldn't figure out how to use both the encrypted driver and the RH95 driver with one manager.  If anyone has worked out those details I would love to hear how you did it.

For now I'm punting encryption and going to back to finish the basic integration of the LoRa radio on the Mega.  Many thanks to Rhys for helping me out so quickly.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 20, 2020, 01:54:46 PM
The SI1145 UV sensor is installed and working perfectly.  Sitting on the deck, it measured a perfect 9.9 UV Index as compared to several other online measurement websites.

The fan arrived today and it looks really great.  The DS1631 chip is supposed to arrive on Thursday so hopefully Friday I will be able to add the ATTiny 85 and a BJT or MOSFET to power the fan (50 uA).  Once the DS1631 chip is programmed it will automatically turn on the fan through the ATTiny when a set high temperature threshold is reached.

The LoRa radios swap is complete, minus encryption.  At some point I hope to be able to do some range testing.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 23, 2020, 09:16:44 PM
Update on vibration sensor.  Reading the vibration sensor at the end of loop() and checking for "theft" was too ugly for me to ignore, so today I finally moved it to a pin-change interrupt using the EnableInterrupt library.  Had a slight issue with the microphone library and duplicated declarations, but fortunately the EnableInterrupt WIKI helped out with the #define needed to make the problem go away.  Now, it's a simple flag update in the ISR and the loop() now only checks for the flag.  If there has been movement it disables the interrupt, updates some timers, and enables the timer again after 5 mins.  Poor mans debounce.

Tomorrow I am going to start doing some testing to see how much of a difference the 5v fan might have.  Going to create two small boxes, with identical temp/hum measurements and set them outside.  One will have the fan and small vents installed.  Just curious to see how much of a difference the fan will make in 95 degree weather with the heat index at 105.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 25, 2020, 08:56:17 AM
Yesterday we did about 4 hours worth of testing in the heat to see how the fan might improve the ambient temperature inside a closed area.  I've never taken thermodynamics so excuse my testing methods.  We tried to keep it simple using two Moteinos, DHT11's and a power brick each inside of a plastic milk jug cut in half.  We put a small piece of wood on top of each jug to shield it from direct sunlight.  What we found over time is the one unit with the fan averaged 3-5 degrees cooler than the one without.  Is that enough to worry with?  Who knows....but I'll probably so some more testing just because it's fun. 

Since I'm still waiting on UPS to bring me the DS1631 chip, we just ran the fan at full speed on 5v.  The fan does support PWM, so I might experiment with running the fan at different speeds depending on the temperature.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 26, 2020, 07:55:09 AM
Here's a graph of yesteray's testing of the fan.  You can really tell when the clouds came over.  The test ran for a little over 4 hours.  I have one more test I want to run but so far I'm impressed with the output of this little fan.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on July 27, 2020, 04:44:57 PM
Thanks to UPS for delivering my PRUSA 3D printer today after 7 weeks of waiting!  And, according to their website, my DS1631 chip is supposed to be delivered today.  That chip will allow me to finish the "auto cooling" circuit for the rover and start testing this weekend.

I've been thinking about integrating OTA so I can update the code without having to bring the rover back to home base.  I also added a "flash erase" function to the wireless menu.  I've been thinking about potentially writing some measurements to flash in addition to the SD card.  We'll see about that one....just a thought at the moment.

If anyone has a suggestion for a sensor or measurement tool I have missed, please suggest it.  There is always room for improvement.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 05, 2020, 10:33:22 PM
Great news....the Prusa 3D printer is up and operational!  Now I get to drink through the new firehoses of the Prusa slicer and Fusion 360!  Love new challenges.  I felt I made a good choice on the cooling fan for the rover when I saw it was the same make and probably model as the one on the 3D printer.

Also just got in the Adafruit 3x4 keypad.  I decided to combine the logging and control functions into one 3D printed box.  It will house the 3x4 keypad for entering the commands to be sent to the rover.  The box will also have some form of screen (either a 4x20 LCD or more likely a Nextion screen, which comes in a variety of sizes.  Throw in the LoRA Moteino and some miscellaneous parts (power switch, buzzer, etc) and I'll be able to completely control the rover from one screen.  I have a little more code on the 3x4 keypad to try and make it as bulletproof as possible.

I have also picked out what I think might be the underlying drive system for the rover, a Traxxas Rustler RTR kit.  It will give me a great foundation on which to build the rover.  Lots more work there in the future.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 06, 2020, 09:33:57 AM
Just finished writing the code for the 3x4 keypad to accept 3-digit numbers for the commands.  I'm using the "*" as a BS character and "#" for ENTER.  After the user inputs the 3-digit code, it is verified as being a valid command number.

Although I'm not short on memory, I had never worked with integer arrays in PROGMEM before so I threw that in there to save 800 bytes.

I'm also considering an e-paper display in addition to the Nextion screen and the typical 2x16 or 4x20 LCD screens.  I have a couple of OLED's but I like the Nextion and e-paper displays better.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 07, 2020, 04:52:55 PM
Ran into an issue where the keypad entry was causing the radio to miss the incoming packets.  Rewrote the code using two different keypad events, one using the "*" to enter 'command mode' and the other to handle the keypad input.  You now have to hold down the '*' key until you are prompted for the command code.  That way the radio gets the majority of the time to help missing an incoming log packet.

Also pitched the PROGMEM code since I was already checking for invalid inputs on the rover end.

Worked out the dimensions for a 3d-printed opening to install the keypad.

Adding conditional compiles so I can swap out RFM69 and LoRA radios with a simple #define and a re-compile.  This will primarily be used for range testing in wooded areas.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 08, 2020, 05:30:14 PM
Conditional compiles for LoRA vs. RFM96 done.

Made one small change to opening for 3x4 keypad on 3d-printed box cover.

Lots of reading on RC trucks.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 10, 2020, 02:11:05 PM
Added OTA to the rover and cmd/control unit.  All covered by the conditional compile for the RFM69.

Started working on integration of Nextion 3.2" display into cmd/control unit.

Finished conversion of file delete from "delete by name" to "delete by number".  Briefly considered converting to Nextion for keypad input but I like the look of the keypad.

Need to get back to fan unit for rover.  Spent a couple of days playing with different ideas for the DS1631 chip.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 16, 2020, 10:10:44 AM
A couple of major changes to the project.

1. After fighting with the Moteino, the keypad and the Nextion (mainly due to the one serial port) on the command/control box, I ditched the Moteino and went with an ESP32 with an external RFM69 radio.  This also meant pitching LoRA, which I was OK with seeing as how most of the gains in LoRA distance would be negated by the trees and terrain.  If I was using this in a drone or balloon which is mainly vertical, I would have definitely kept the LoRA.  I know there are ways to work around the one serial problem, and I have done it on other projects, but after spending 2 days banging my head I decided to cut my losses and switch to the ESP32.  This change also gives me Internet access via wireless which I can use to stream log messages to the Internet for analysis and storage.  It also gives me BT in case I want to work on a phone app.  I had to remember how to handle the packing of the structs between the Mega and the ESP32, but I was able to get everything working.
2. The Nextion UI is almost done.  I have added all the necessary code to enter the 3-digit command into the keypad, send the command to the rover, and accept the log/data output and display it on the Nextion.  I'm thinking about taking on a scrolling window which would allow me to view older messages.
3.  I need to wire up a HW radio instead of the W model I have now.
4.  Still need to finish the fan circuit and finish testing.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 19, 2020, 10:21:58 AM

1.  Finished initial configuration of Nextion display and integration of 3x4 keypad.  Created pop-up windows with help information.  Finished screens for all input and log data coming from rover.
2.  A couple of bug fixes.
3.  Starting to work on possible PCB board design for the command/log box.
4.  Starting to work on 3d printing options for box design vs. commercial box.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on August 30, 2020, 09:51:10 PM
Weekend update:

1.  After a lot of work getting the physical keypad to work, I decided I liked it better using the Nextion for the keypad entry as well.  Just finished designing the keypad and coding the various features (ie, can't have a zero as first number, making sure there are 3 numbers before the OK button works, etc).  I'm using the 3.2" Nextion model....wish it was the next size up but it's certainly workable.  The buttons are 50x50 pixels.  Once the command number is entered, it is passed through Serial2 to the ESP32 for processing.
2.  Started work on the 3d print design for the box.  It will be about the size of an iPhone since I'm using the Nextion screen in portrait orientation.
3.  Finished gathering the parts to build the control box.  Still deciding on whether to use an external antenanna or just rely on the antenna wire.
Title: Re: A testament to Felix's Mega
Post by: syrinxtech on September 11, 2020, 11:19:11 AM
Finishing up the Nextion design:

1.  For log review, I went with a screen design that allows the last two log messages to be displayed on the screen.  Each individual window scrolls the log message.  As new messages come in they rotate between screens.
2.  I added a "999" code to erase both log windows.
3.  We moved the ESP/RFM69 and Nextion from a breadboard to a proto board which greatly reduced Nextion reboots caused by cables moving around.  Much easier to work with now.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on October 30, 2020, 02:14:25 PM
A couple of updates:

1.  Added a voltage monitor to the command/control unit.
2.  Added a "Settings" button on the main Nextion screen.  This takes you to a screen to see the battery voltage and a slider to adjust the screen brightness from 5-100%.
3.  Final 3D printing and circuit board design for the command/control unit.  It incorporates the Nextion screen, on/off rocker switch, USB jack to plug in for battery recharging, and micro SD card to update the Nextion code.
4.  Going to integrate OTA updates for ESP32 so you won't have to take off the back cover to update code.

Title: Re: A testament to Felix's Mega
Post by: syrinxtech on November 04, 2020, 11:10:38 AM
Today's updates:

1. The command/control box is done.  My brother-in-law did a fantastic job of 3D printing the enclosure and laying out the various components.  I'll try and get some pictures to upload.
2. Converted the Adafruit GPS from polling to interrupt-driven.  Using the "TimerOne" library, every millisecond the GPS is checked for input and data is read if necessary.  Once a NMEA sentence is completely read, it is processed.