Hello Everyone,
I am starting my very first Arduino project, fairly new to programming, totally new to Arduino but have played around with micropython on a pi pico. I am just beginning a C language course but I have to admit I am not picking it up very well. So I need help here writing my first program. My bigger issue is I need to install this project into a vehicle this Saturday!
So let me break down the project and see what folks here can do to get me going in the right direction. I am hoping this won't be too terribly difficult.
Project Scope:
2014 Mercedes Sprinter Van. Electronics Cabinet containing: 4 x 100ah Lithium Iron Phosphate Battery Array, 200 Watt Solar Input, 3000 Watt Inverter/Charger.
So we have some serious power generation in a closed space so we are going to generate some heat. Now there are 2 x 120mm 12v vent fans and 2 additional open vents. The 2 fans are on a manual switch that I would like to integrate into the project to automatically kick on and off based on temperature.
I want to be able to monitor the temperature in the cabinet with the sensor placed above the battery array. In the event of potential overheating I want to be able to warn the occupants of the van of a impending problem. I also want to kick on above mentioned vent fans on and off.
Hardware:
Arduino Nano Everything
Grove TH_02 Temperature/Humidity Sensor
Basic Pezio Buzzer
2 x 120mm PC fans
Expected Behavior:
Sound buzzer in 3 stages:
@ 100F, sound buzzer, 3 seconds on, 3 off, cycle 5 times. (First temp warning)
@ 130F, sound buzzer, 5 seconds on, 2 off, cycle 10 times. (Second temp warning)
@ 160*F, sound buzzer, on continuous 180 seconds, 10 second off, loop until temp goes below threshold or physically kill power to Nano. (Forced Intervention, Must open battery cabinet and take action to rectify dangerous overheating situation.)
Trigger Ground for fans, on @ 85F, off @ 80F
(Fans are on vehicle 12v circuit, not sure if triggering ground directly will create surge or current draw through the Nano. Could use standard automotive 12 relay, but these are honestly rather inadequate computer case fans with like 22g wiring)
Now I am thinking I only want buzzers to sound on increasing temperatures but not on descending temps. example, triggers 100F warning and goes up to say 110, but is now cooling back down so no need to trigger as it passes back below 100F trigger. I don't know, not sure I have the time to lose with extra coding at the moment.
Physical Setup: (Currently setup on breadboard)
TH_02 Temp Sensor, SDA Pin D18; SCL Pin D19; +5v pwr, ground
Buzzer, +3.3, Sig Pin D2
Fans, 12v vehicle power, ground signal D3? (Fans in the van)
Nano, 12v vehicle power with 3amp fuse. Ground to isolated chassis ground. (currently on USB+)
Programming:
Well I need serious help here as I am unfamiliar with Arduino hardware and the C/C++ language.
I know I need include certain libraries such as Arduino.h, TH02_dev.h, and wire.h.
I am unsure about the sensor driver TH02_dev.cpp?? I don't see it called in the TH02Demo.ino program I looked at.
(Totally guessing and just trying to layout some kind of framework, not sure what any of this would look like at the moment.) Guidance here is critical.
I would need to create a function for Alarm(buzzer), Temp, Fan?
I would need a way to pass the temp values to the Alarm and Fan functions? How?
Declare hardware pins in setup? Not sure of pin nomenclature for Nano?
If statements such as
If temp=100; buzzer(Pin D2, Low) // Temp = 100, activate buzzer;
buzzer(PinLow(3), Delay(3);
(buzzer=(b) 0<=5, b++) //buzzer cycle
else;
void() // do nothing
Then repeat code for each of 3 buzzer trigger temps. Something similar to trigger the vent fan?
Perhaps a 'While' statement would be better then a if/else statement?
Anyways, that is as far as my knowledge takes me for the moment. I just received my Nano today and currently have it in the breadboard blinking the LED for a burn in test. Smelled like hot electronics for about the first hour, although the board itself wasn't hot at all. Just new chips burning off factory coatings?
I have it setup in the web based IDE and I have been able to do a serial test to verify I can upload programs and get a response from the unit, reset button works, and then re-uploaded the blink led program. So I am physically setup for the most part.
I will start doing my best to start a sketch and at least get some kind of frame work built.
Thank You in advance for the help. And sorry my first post is a 'help me with my homework' kind of post. I do have alot to learn but I certainly am grateful for the help.
Robert