I am new to arduino and electronics. But I am a programmer (unix system). I am working on project greenhouse for cactuses. I had working things, but I added a few features. When I change code, relay stopped working immediately, now on digital pin output I have just 2.8V. It is strange, when I switch back into older working version and simply add some features (from new version) its still working, but my old final version just simply tells that is going to switch on relay, but voltage is low.
Relay has its own 5V (1a) adaptor. I also have 1602 display, RTC module, SD card reader and 1 thermistor attached.
I cannot figure why :(, I made a lots of differences between these two files. Do you have any suggestions which kind of error in code can make this strange behavior?
That's quite clear from all the Strings... Pretty easy to make Swiss cheese of your memory with them. Using strings (no capital) would be more logical as you're already using the F() macro.
Mlok:
Relay has its own 5V (1a) adaptor.
I hope with shared GND? Aka, schematic (no Fritzing breadboard mess!) would be nice.
Mlok:
I made a lots of differences between these two files.
I think that is your biggest mistake Take baby steps! And test in between
But I don't see anything obvious wrong with the code. At least if you don't also get "turning on relay" and "turning off relay" messages all the time. An the rest is hard to debug. The bit of comment is unreadable for most of us... So better suited in the board of your language.
R2 = R1 * (1023.0 / (float)Vo - 1.0);
Besides float math being heavy, this certainly is also wrong The ADC has 1024 steps, NOT 1023
thanks for tip with strings, I am programming arduino 4rd day, good to know:) a lots of things to learn.
It is a working connection, when I make a sketch only with LOW and HIGH works like a charm, I have also older version, slowly adding features (which works fine), but I am still not catching moment when it wents wrong, so I decided to ask meanwhile I am coding maybe someone gets some trouble. Half voltage is really strange, isn't it
I only ever see two places you use digitalWrite() which is followed by a Serial print. Aka, if the code does something with the pin you should also see a Serial print. You don't see weird stuff there?
And yeah, to code is quite complex and full of String's so it might as well be a memory problem. Start by adding a print at the start of setup(). Maybe things are resetting.
Nothing strange, it prints out that relay is succesfully started or stopped, and also when I check for pin state it corresponds with the desired state.
Tried, it is not resetting, I added these strings fro debugging, they are not present in app before problem, app is working, listening to other buttons, writing on card, but when it has to start relay it is not started.
In both states led on relay is off and Voltage in wire is 2.75 with gnd on arduino.
But these code is working perfectly.
EDIT: when I use these files it gave me 0V if turned on and 5V if on. Perfect behavior