#solar tracking communication

1 messages · Page 1 of 1 (latest)

tawny sandal
#

Hi, I'm working on a project for class using a Keyestudio kit (this one: https://docs.keyestudio.com/projects/KS0530/en/latest/KS0530.html)) and I'm using an Orange Pi 3B. I need help on how to communicate information from the Arduino (like battery level, temperature, etc.) to Home Assistant. I'm new to Home Assistant and this type of projects, so any guidance would be greatly appreciated.

Also, I'm not sure if this is the right channel to ask, so please let me know if I should ask elsewhere.

spare light
#

What do you need help with specifically?

tawny sandal
#

idk how to communicate the information from the arduino to home assistant

spare light
#

Do you have to write Arduino code? Otherwise esphome would be much easier to setup

tawny sandal
#

i allready have the code from the kit

#

and the kit have arduino uno

spare light
#

okay than probably MQTT would be the easiest to setup

#

you need a broker and you need to setup the MQTT sensor in HA

tawny sandal
#

idk what is that could you explain to me?

spare light
#

no, use google. Then I can answer

#

you can figure this out yourself

tawny sandal
#

k ty

#

for what im reading i need a wifi module for arduino, is that correct?

spare light
#

Wifi or ethernet

#

Or whatever can give you networking

tawny sandal
#

I will talk about this to my teacher, tysm for the help

tawny sandal
#

@spare light sorry for the ping, but my teacher got me a ESP8266 this one, and im wondering if i can communicate the arduino and the esp8266 with the tx and rx pins, then i could use esphome and make the sensors in home assistant. I guess thats possible or its not?

spare light
#

you can also program the esp using arduino

tawny sandal
#

ok ty

earnest owl
#

Split your project into a few portions. Get each portion working and then string them together.

Think of how you eat a gigantic chocolate elephant - one bite at a time

  1. Get Homeassistant working on your Orange Pi. Write down all your configuration settings, passwords, etc. You will need those later when you want to send it data. Having a single document you can store these in that is NOT on GitHub, your school network, or publicly accessible is important for security. Don't hard code your passwords, etc into your source code if possible. Easy to cut/paste into your projects as needed. Learn to build in security onto your projects from the ground up, rather than a bolt-on later.
#
  1. Get your Arduino IDE configured to support the Uno as well as the ESP8266. (As an aside, the latest R4 has an ESP32 on board for WiFi access. The ESP32 is a big brother of the ESP8266).

Examine how much of your data can be collected directly by the ESP8266, rather than the Uno. You may not need both. Be amazed that the code you write for the Uno will also work on the ESP8265 with only minor changes.

Plan your code before you start writing it. Use big-picture pseoudo code. Split it into modules that perform a specific role, and what you expect it to do.

Sit down with your grandmother (yes I'm not joking - they are the best) or some other non-technical older person and explain each portion of your pseudo-code. She will smile and nod, but when you cannot explain a portion of it to her, without getting tongue tied, you know it is wrong and you have more work to do in that area.

Grandmother doesn't have to know code - she loves you and has infinite patience, and will listen all day to you speaking in a foreign language (computerese). The warm fresh baked cookies are a bonus as you rush off to change your code as you realise what you have done wrong. In the industry this is called a walkthrough with your peers, but we use grandmother until we can find a better expert, and grandmother gives better praise and will sing your praises far and wide, rather than somebody like your impatient big sister or even your teacher who doesn't have the time o do this for all the class.

  1. Setup your ESP8266 with Tasmota (a well known and reliable ESP sensor platform), just to check that HomeAssistant is working with your WiFi and that MQTT is configured correctly, and a sensor connected to the ESP8266 can be seen in HomeAssistant. Once you have confirmed your hardware is consistently reliable, you can focus on your code in that knowledge that they will talk to each other without having to wonder if you have made a wrong connection or have faulty equipment you cannot trust.
#
  1. Go back to your Uno and make sure your data is being reliably collected.

Print statements to the serial monitor in your Arduino IDE will greatly assist with debugging. Remember that your serial port will later be used for communicating with the ESP8266 and unexpected debugging statements will corrupt your serial data, so use an global debugging flag you can turn on/off at the top of your code.
Example: Allocate a global variable at the top of your code called debugstate.
Set debugstate to ON if you wish to debug your code.
Throughout your code print values and comments liberally so you can understand what is happening. This is your code talking to you - make it understandable
Each print statement should be like:
If debugstate=ON then print "your information you need"

If your debugging status at the top of your code is turned off, then nothing should be displayed on your serial monitor when your code runs if you have done this correctly and consistently.

Once you are satisfied that your code is robust, do a global search replace on the term "if debugstate" and turn it into a comment which your Arduino compiler will then ignore, making your code runtime much smaller, but giving you the option to go back and swap it back on again to debug further

Once you have discovered how to do this concept well, you will have a library you can create for yourself and the debugging clauses will be right there, right at the top, and you know you can trust them as you understand how they work. As a bonus, when you come back to your code in the future, you should becable to maintain it far better than if you have to rely on your memory on what each portion does.

  1. Plug your data from the Uno into MQTT and send it to HomeAssistant, via the ESP8266 which can be used as a pseudo serial port connected via WiFi, or Tasmota also has the ability to pass through data showing up on the serial port.
#
  1. Gotchas to look out for: Tx to Rx and Rx to Tx. Slower baud rates for reliability. Your USB port only gives you 5volts at 500mA but your chips may need more current sometimes. Don't carelessly mix your floats and integer variables. Explicitly define your variables at the top. Be aware of local vs global variables. Define your variable naming schemes wisely up front so they are always unique. Backup and TEST your restore works. Source code and data. Ask me how I know...

  2. Your teacher is wise, giving you a vastly more powerful ESP chip to act as a simple WiFi connection for your Uno. What you learn in making each component do a specific role will take you far in your understanding of how it all ties together. Breaking each chunk up and once you have mastered that, you can use that as a building block to assemble your final solution.

  3. Post your progress here so we can all follow how you go and offer suggestions. Don't expect others to write your code for you (Hint: Even ChatGPT writes awful buggy code, and the suggestions you find on stackoverflow or reddit are not always the best way to solve your problem. The person offering you suggestions may not know as much as you)

Stand on the shoulders of giants, and be liberal with helping others, and sharing what you do.

Others can also benefit from your voyage of discovery. It is frustrating to read of others problems and be left hanging on what eventually happened. So selfish not give back where you ended up and how you got there. Others will offer suggestions more willingly if they see your efforts and that you are not lazy and expect others to do all our homework for you.

earnest owl
#
  1. Always RTFM. The person that created your Uno, ESP8266, WiFi, WiFi code, common subroutines, etc knows the most about their product. Read what they have written and don't be afraid to ask lots of questions to boost your knowledge. Use search wisely and you will stumble over good ideas. Your skill is to assemble these building blocks in unique ways to solve your problem.

Conversely, document everything, and PLEASE spell check it. Your brilliant code can be wrecked by poor documentation. Leave lots of comments and hints in your code. Make it a habit from early on. The person that has to maintain or extend it, often a long time after you have moved on to other more exciting stuff, will appreciate it the most.

Learn to chunk-ify your code into useful subroutines that can be re-used. Make use of robust libraries that others have poured a lot of work into. You don't always have to re-invent the wheel. Well documented API's can save you a lot of debugging and make your efforts easier and more consistent.

School is where you aim to pass your subjects. Learning along the way is just an inadvertent bonus.

Having a gifted mentor like your teacher is just a bonus.

Be appreciative and always give credit for other's help and hard work that has helped you get to where you are.

Life is a journey, composed of many achievements and experiences. Never stop learning. Never be disenchanted. Collaborate. Share. Enjoy!

Best of luck.

Oh, please pass me another mouthful of that yummy chocolate elephant...

tawny sandal