Thank you for that here is a bit more detail and someone on GitHub said, “ I can tell you're not using this core, first of all (there are normally ~8 options listed on the bottom status line, not just RPI Pico on X
). You're using the Arduino MBED one which does not support that header, evidently. You should head over there for more assistance since it seems they don't have a pgmspace.h
header.”
-
I am using a capacitive moisture sensor V2.0 and OLED LCD Display.
-
I have tested the raspberry pico using a different program and it was flashing it worked however when trying to program the OLED display I am receiving an error. The capacitive sensor does also work I programmed it using the Raspberry Pico.
-
Here is the program code (sorry I tried using the code button but doesn't seem to organize it)
'/*
Soil Moisture Meter
soil_meter.ino
Measures percentage of moisture in soil
Uses Capacitive sensor
Requires calibration values
DroneBot Workshop 2022
https://dronebotworkshop.com
*/
// Include required libraries
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Set OLED size in pixels
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// Set OLED parameters
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Sensor constants - replace with values from calibration sketch
// Constant for dry sensor
const int DryValue = 2590;
// Constant for wet sensor
const int WetValue = 1430;
// Variables for soil moisture
int soilMoistureValue;
int soilMoisturePercent;
// Analog input port
#define SENSOR_IN 0
void setup() {
// Setup Serial Monitor
Serial.begin(9600);
// Initialize I2C display using 3.3-volts from VCC directly
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
display.clearDisplay();
// Set ADC to use 12 bits
analogReadResolution(12);
}
void loop() {
// Get soil mositure value
soilMoistureValue = analogRead(SENSOR_IN);
// Print to serial monitor
Serial.print(soilMoistureValue);
Serial.print(" - ");
// Determine soil moisture percentage value
soilMoisturePercent = map(soilMoistureValue, DryValue, WetValue, 0, 100);
// Keep values between 0 and 100
soilMoisturePercent = constrain(soilMoisturePercent, 0, 100);
// Print to serial monitor
Serial.println(soilMoisturePercent);
// Position and print text to OLED
display.setCursor(20, 0);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println("Moisture");
display.setCursor(30, 40);
display.setTextSize(3);
display.setTextColor(WHITE);
display.print(soilMoisturePercent);
display.println("%");
display.display();
delay(250);
display.clearDisplay();
delay(100);
}`
- I got the program from DroneBot Workshop on YouTube
YouTube link: https://youtu.be/pgGpuws7f9o?si=T4SWRrMpYHMliXjI
Article with code link:
Water Your Garden with IoT | DroneBot Workshop