Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic example code for Issue/324 on reading VSYS/VBUS while using wifi on Pico_W #326

Closed
wants to merge 4 commits into from

Conversation

pspeybro
Copy link

@pspeybro pspeybro commented Feb 6, 2023

This is a basic example on how to read VSYS and VBUS using ADC3 and WL_GPIO2 which share pins with wifi, so extra measures need to be taken to make sure wifi keeps working.
See also discussion on raspberrypi/pico-sdk#1222

There are probably some minor updates needed to align it with the other examples (for example put the wifi SSID and password and host ip address in Cmake file), but putting it up here so other people can find it as well.

It seems like I pulled in a few other commits, possibly because I created the branch from the master.

Copy link
Contributor

@kilograham kilograham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to rebase onto latest pico-examples develop (you seem to have picked up ws2812 changes somehow), and use latest pico-sdk develop (because you will want to include pico/cyw43_arch.h instead of anything more specific)

Also please look at the latest updates to pico_w examples in terms of how polling is done in examples

Comment on lines +141 to +144
printf("[1] http status %d \n", err);
}
else{
printf("[1] http client is busy...\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are all these [1] supposed to indicate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, some leftover from debugging, totally irrelevant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover, as in, I was running the http request on core1 initially, so it was indicating from which core the printf was coming...

#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include "hardware/gpio.h"
#include "hardware/adc.h" //to read ADC for soil moisture sensor, connected to pin 36 (3.3V), pin 33 (GND/AGND), pin 34 (GPIO28/ADC2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

soil moisture sensor - huh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one of these: https://arduino-tutorials.net/tutorial/capacitive-soil-moisture-sensor-arduino
I left the sensor reading in there to make the example at least a little more interesting.

@peterharperuk peterharperuk self-assigned this Feb 7, 2023
@peterharperuk
Copy link
Contributor

Glad it worked. I can make the changes needed to get it into pico-examples if you like.

@pspeybro
Copy link
Author

pspeybro commented Feb 7, 2023

I will be quite busy the following days, so if you have time to clean it up, be my guest. I mainly already wanted to share my solution so that other people can benefit from it.

@kilograham
Copy link
Contributor

is this superseded by #331 ?

@peterharperuk
Copy link
Contributor

Yes. The contribution from @pspeybro was helpful in adding this to the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants