Hi, I was trying to remotely run an led using an uno r4 wifi and I noticed that when I used the 'Secrets Tab' for my wifi info when I used A 9 volt and the non usb power port (so it was not connected to my laptop) it would not work. here's the code that i'm working with
I’ve used the same power supply on many different projects and it’s a new 9 volt. I don’t think that’s the problem. All I'm running is a red LED, so it uses not much voltage to run it anyway.
That is a vague description of your problem. How do you know that it's not working?
Are you saying that if you move the content of the secrets tab to the main ino file it all works?
For testing purposes I would use a 9V wall wart instead of a 9V battery.
Note:
It's not only the LED, it's the full board as well that needs to be powered. And WiFi chips are known to be power hungry, And that is something that a 9V PP3 battery can not provide.
My problem is that I can’t figure out how to put the Wi-Fi information in the sketch not in the secrets tab. I’ve used the same power supply on other projects and it work just fine. But thanks for trying to help.
I have done projects using wifi and the same 9 volt battery power supply, I just completely forgot how to do it and sometime that sketch got deleted. And since that I could not figure it out again. I remember that I had the wifi info in the sketch NOT thingProperties.h. Here's the code that i need to edit tom add the wifi Info.
#include "thingProperties.h"
const char SSID[] = "mySSID"; //My problem is that I do not remember how to enter the wifi info.
const char PASS[] = "myPassword"; //Is it in () or "" or what?
void setup() {
Serial.begin(9600);
delay(1500);
initProperties();
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
pinMode(13, OUTPUT);
}
void loop() {
ArduinoCloud.update();
digitalWrite(13, led);
}
void onLedChange() {
Serial.print("Led status changed:");
Serial.println(led);
}
At first i thought it would be in the thingProerties.h then i remembered that I had had it in the scetch its self.
You have already accomplished that with the changes you made to lines 4 and 5 of your thingProperties.h file:
When the Thing sketch uses the configuration from the "Secret" tab, as is the case with the thingProperties.h code that is generated by Arduino Cloud when you create a Thing, those lines look like this:
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
(SECRET_SSID and SECRET_OPTIONAL_PASS are macros automatically defined from the configuration in the "Secret" tab)
So if you are still experiencing the problem even after uploading the sketch with the modified thingProperties.h code you shared in post #1, then this disproves your hypothesis that the problem was caused by the use of the "Secret" tab. Now it is time to forget about the "Secret" tab and focus your attention on the more likely cause of the fault:
The amount of power required for stable operation of the Wi-Fi radio on the UNO R4 WiFi board can vary according to the environment. It very well might be that when it was working before the conditions were more favorable and so the radio didn't require as much power to communicate with the Wi-Fi access point as it does now and thus was able to get by with the marginal power provided by the battery.
So please, take the suggestion of the other helpers and check whether the problem still occurs if you use a more appropriate power supply.
You are wasting your time trying to move the Wi-Fi credentials to the .ino file. You already accomplished your goal of avoiding the use of the "Secret" tab through your changes to the code in the thingProperties.h file.
If you removed those lines from the thingProperties.h file and then delete the lines from the .ino file.
I tried using a non data transfer usb-c cable so it had full power it needed but it could not access the secrets tab on my computer, and guess what it didn't work! And as I said in post #8 I had at one point done this and then the sketch got deleted and I completely forgot how to do it.
If you are using Arduino IDE, you can either replace the secret macros in thingProperties.h, as you did in code you shared in post #1, or you can define the secret macros via #define directives in the arduino_secrets.h file of the sketch:
You might also need to add an #include "arduino_secrets.h" directive to the thingProperties.h code. Cloud Editor is supposed to add this to the sketch when you download it, but I see that feature is broken right now.
Please provide a detailed description of what you mean by this in a reply on this forum thread, including:
What did you do?
What were the results you expected from doing that thing?
What were the results you observed that did not match your expectations?
Make sure to include the full and exact text of any error or warning messages you might have encountered.
The Arduino board does not access the secrets tab at run time, it is accessed by the compiler when you compile/upload the code.
The only reason there is a secrets tab is so that your wifi credentials do not appear in the sketch itself. That makes it easier to share the sketch with someone else without accidentally revealing the SSID/password to your network.