Noob Need Help, Ape Brain Slow

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
FiguringOutLife
Posts: 3
Joined: Thu Sep 02, 2021 10:29 am

Noob Need Help, Ape Brain Slow

Post by FiguringOutLife » Thu Sep 02, 2021 11:19 am

First a bit about myself:
I have no experience with programming besides watching a game dev tutorial one time 5 years back.
Recently myself and my partner decided to try our hand at growing Microgreens(sprouts grown in a room under artificial light).
Being the bright spark I am, I decided I wanted to try Coding again and our grow room needed a basic climate controller, entirely built and coded by me....
This brings us to now:
my end goal is to have:
An lcd display current and desired temperature and humidity.
When the temperature or humidity is lower or higher than desired a heater, cooler, Dehumidifier or Humidifier will be activated via a set of relays.
Desired temp and humidity setting will be changeable via push buttons.

I currently have no Hardware so am unable to test my code.
Throw some advice my way and let me know where I've made mistakes or need to add additional code.

Please remember I'm here to learn and improve not to have someone fix my code.
Teach me what my mistakes are, don't just rewrite my work for me.


My unfinished code is as follows:

Code: Select all


Thanks in advance.

EDIT: removed code as it was non functional trash that didn't deserve life 🤣
Last edited by FiguringOutLife on Mon Oct 04, 2021 8:01 pm, edited 1 time in total.

Saul
Posts: 10
Joined: Wed Jun 10, 2020 10:20 pm

Re: Noob Need Help, Ape Brain Slow

Post by Saul » Sun Oct 03, 2021 6:12 am

Hi @FiguringOutLife,

I have not used the sensors your using but I'm also playing around with micropython and LCD's and from my experience I would say first nail down your hardware before you start doing sudo code. At least for me so much changed in terms of code/libraries needed and approach depending on the hardware I intend to use.

option 1)
If you really want to physically displaying the information I would go with a simple IC2 OLED:
128X64 I2C SSD1306
https://www.aliexpress.com/item/32830523451.html

I have not used it with micropython but there seems to either be built in libraries or libraries you can load in:
https://docs.micropython.org/en/latest/ ... d1306.html

option 2)
Later if you have a lot of time and want to compile your own FW for your esp32 and use a nicer LCD witch touch screen:
LCD: 240x320 SPI TFT LCD Touch Panel ILI9341
https://www.aliexpress.com/item/4000631140288.html

esp32 FW I really like (you need to compile):
https://github.com/lvgl/lv_micropython

Graphic library website:
https://lvgl.io/

I would recommend getting ESP32 with SPRAM for this route like:
ESP32-WROVER-IE
https://www.aliexpress.com/item/4001283527522.html

option 3)
Just create a web page that displays the needed information. This seems like a good tutorial:
https://randomnerdtutorials.com/esp32-e ... eb-server/


Once you get your hardware and choose the route you want to take, you can start tackling some of basic stuff like getting the FW on your device, connecting your hardware and running some basic commands/tests to make sure everything is working as expected. Then you can slowly test the functionality of the devices your interfacing.

Hopefully that's helpful :)

Regards,
Saul

FiguringOutLife
Posts: 3
Joined: Thu Sep 02, 2021 10:29 am

Re: Noob Need Help, Ape Brain Slow

Post by FiguringOutLife » Mon Oct 04, 2021 9:05 pm

Hey @Saul

You're definitely right about nailing down the hardware before trying anything code related.

In the time since I originally posted I've picked up all the hardware I need for the build and completely thrown out the garbage code I tried before.
It was so full of errors that it wasn't worth rewriting.

It's definitely a lot easier and more rewarding to wright a little code and get a sensor working then combine it with another little code to have two sensors working together etc.


I think for easy reference physically displaying information on a simple IC2 OLED is better. But also I love the idea of creating a Web page 🤔.
Those randomnerdtutorials are super easy to follow so I definitely think I have to give it a go.

I'm glad to hear you're an esp32 user as that's the board type I settled on. Although I got the esp32 devkitV1 from Amazone.

Your ideas and lcd links are definitely useful.
But I have to ask, have you used these aliexpress links?
I really don't trust the legitimacy of aliexpress 🤣

Thanks for taking the time to reply.

Saul
Posts: 10
Joined: Wed Jun 10, 2020 10:20 pm

Re: Noob Need Help, Ape Brain Slow

Post by Saul » Tue Oct 05, 2021 4:31 am

Hi @FiguringOutLife,

I don't know if I used those exact links as I bought my hardware a while ago, but I do use aliexpress for all of my tinkering (micro controllers, sensors, screens, electronic components, motors, bearings, shafts,...) as the price is half if not a third of the price of amazon. The only problem is that a lot of times it takes three times as long to get to my door step. So what I end up doing is ordering extra stuff that way if i change my approach i don't have to wait another month for more parts.

Also depending on how many IO pints you need you might be able get away with an esp8266 for the i2c display or webpage. I know you have the an esp32, but if you plan on having a few builds you can probably save some money going that route.

If you want to go the LVGL route I could help you get a dev environment going. Also they have a simulator if you want to mock up your UI:
https://sim.lvgl.io/v7/micropython/port ... index.html

LVGL widget examples:
https://github.com/lvgl/lvgl/tree/maste ... es/widgets

Regards,
Saul

FiguringOutLife
Posts: 3
Joined: Thu Sep 02, 2021 10:29 am

Re: Noob Need Help, Ape Brain Slow

Post by FiguringOutLife » Mon Oct 11, 2021 10:31 pm

Well I'll definitely have to try out aliexpress next time I want to buy something for this or another project.

I do plan to slowly expand this build as my knowledge base and skills increase so I think sticking with the esp32 from the start is probably in my best interests.
I'm assuming here that I can do everything from one esp32 (lighting, temperature, humidity, soil moisture, ventilation, data display)
Correct me if I'm wrong.

I'd definitely love to get some help, but I don't think I'm giving enough time to these projects to warrant more than asking and replying occasionally on the forum.

Edit: When I've got my script I front of me again I'll post an updated version.

Saul
Posts: 10
Joined: Wed Jun 10, 2020 10:20 pm

Re: Noob Need Help, Ape Brain Slow

Post by Saul » Wed Oct 13, 2021 8:05 pm

Hi @FiguringOutLife,
I don't think you will lose much if anything at all going with esp8266 especially if you just using wifi, i2c/spi; but definitely something you would have to test. Also, in terms of implementation aside from pin numbers it would probably be the same to communicate to your devices using either the esp32 or esp8266 when using micro python on both. Depending on how many implementation you do it might be worth investigating.

If you want to do many things with a single microcontroller then I would choose the i2c version of the devices/sensor you want to use leaving the spi ports open for devices that don't have i2c versions. Also noting the i2c addresses so they don't conflict or you will need to work around that. Here is a good i2c article:
https://learn.adafruit.com/i2c-addresses

To be honest I would probably not be able to help you with your code as it will be very unique to to what you are trying to do. It would probably be more helpful to post a specific issues your having so others can take a look or test on their side.

Post Reply