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

Add support to Raspberry Pi Pico W #503

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ jobs:
- fqbn: arduino:mbed_edge:edge_control
type: mbed_edge
artifact-name-suffix: arduino-mbed_edge-edge_control
- fqbn: "rp2040:rp2040:rpipicow"
type: rp2040
artifact-name-suffix: rp2040-rp2040-rpipicow


# make board type-specific customizations to the matrix jobs
Expand Down Expand Up @@ -303,6 +306,13 @@ jobs:
- examples/ArduinoIoTCloud-DeferredOTA
- examples/ArduinoIoTCloud-Notecard
- examples/ArduinoIoTCloud-Schedule
# PicoW
- board:
type: rp2040
platforms: |
# Install rp2040 platform via Boards Manager
- name: rp2040:rp2040
source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

steps:
- name: Checkout
Expand Down
5 changes: 5 additions & 0 deletions src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
#define HAS_TCP
#endif

#if defined(ARDUINO_RASPBERRY_PI_PICO_W)
#define BOARD_HAS_SECRET_KEY
#define HAS_TCP
#endif

#if defined(BOARD_HAS_SOFTSE) || defined(BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_ECCX08) || defined(BOARD_HAS_SE050)
#define BOARD_HAS_SECURE_ELEMENT
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/tls/AIoTCUPCert.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
******************************************************************************/

#include <AIoTC_Config.h>
#if defined(ARDUINO_ARCH_ESP32) || defined (ARDUINO_EDGE_CONTROL)
#if defined(ARDUINO_ARCH_ESP32) || defined (ARDUINO_EDGE_CONTROL) || defined (ARDUINO_RASPBERRY_PI_PICO_W)

/******************************************************************************
* CONSTANTS
Expand Down Expand Up @@ -163,6 +163,6 @@ static const char AIoTUPCert[] =
"-----END CERTIFICATE-----\n";
#else

#endif /* #ifdef ARDUINO_ARCH_ESP32 */
#endif /* #ifdef ARDUINO_ARCH_ESP32 || ARDUINO_EDGE_CONTROL || ARDUINO_RASPBERRY_PI_PICO_W */

#endif /* _AIOTC_UP_CERT_H_ */
2 changes: 2 additions & 0 deletions src/tls/utility/TLSClientMqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void TLSClientMqtt::begin(ConnectionHandler & connection, ArduinoIoTAuthenticati
if (authMode == ArduinoIoTAuthenticationMode::CERTIFICATE) {
setCACert(AIoTSSCert);
}
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
setCACert(AIoTUPCert);
#elif defined(ARDUINO_ARCH_ESP32)
(void)authMode;
setCACert(AIoTUPCert);
Expand Down
3 changes: 2 additions & 1 deletion src/tls/utility/TLSClientMqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ enum class ArduinoIoTAuthenticationMode
*/
#include <WiFiSSLClient.h>
class TLSClientMqtt : public WiFiSSLClient {
#elif defined(BOARD_ESP)
#elif defined(BOARD_ESP) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
/*
* ESP32*
* ESP82*
* PICOW
*/
#include <WiFiClientSecure.h>
class TLSClientMqtt : public WiFiClientSecure {
Expand Down
2 changes: 2 additions & 0 deletions src/tls/utility/TLSClientOta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void TLSClientOta::begin(ConnectionHandler &connection) {
* https://github.com/arduino-libraries/Arduino_ESP32_OTA/blob/fc755e7d1d3946232107e2590662ee08d6ccdec4/src/tls/amazon_root_ca.h
*/
(void)connection;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
setCACert(AIoTUPCert);
#elif defined(ARDUINO_ARCH_ESP32)
setCACert(AIoTUPCert);
#elif defined(ARDUINO_ARCH_ESP8266)
Expand Down
3 changes: 2 additions & 1 deletion src/tls/utility/TLSClientOta.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@
*/
#include <WiFiSSLClient.h>
class TLSClientOta : public WiFiSSLClient {
#elif defined(BOARD_ESP)
#elif defined(BOARD_ESP) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
/*
* ESP32*
* ESP82*
* PICOW
*/
#include <WiFiClientSecure.h>
class TLSClientOta : public WiFiClientSecure {
Expand Down
4 changes: 2 additions & 2 deletions src/utility/time/RTCMillis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "AIoTC_Config.h"

#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W)

#include <Arduino.h>
#include "RTCMillis.h"
Expand Down Expand Up @@ -61,4 +61,4 @@ unsigned long RTCMillis::get()
return _last_rtc_update_value;
}

#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 */
#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */
4 changes: 2 additions & 2 deletions src/utility/time/RTCMillis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef ARDUINO_IOT_CLOUD_RTC_MILLIS_H_
#define ARDUINO_IOT_CLOUD_RTC_MILLIS_H_

#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W)

/**************************************************************************************
* INCLUDE
Expand All @@ -45,6 +45,6 @@ class RTCMillis

};

#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 */
#endif /* HAS_NOTECARD || ARDUINO_ARCH_ESP8266 || ARDUINO_RASPBERRY_PI_PICO_W */

#endif /* ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ */
33 changes: 31 additions & 2 deletions src/utility/time/TimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "NTPUtils.h"
#include "TimeService.h"

#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W)
#include "RTCMillis.h"
#elif defined(ARDUINO_ARCH_SAMD)
#include <RTCZero.h>
Expand All @@ -41,7 +41,7 @@
* GLOBAL VARIABLES
**************************************************************************************/

#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
#if defined(HAS_NOTECARD) || defined(ARDUINO_ARCH_ESP8266) || defined (ARDUINO_RASPBERRY_PI_PICO_W)
RTCMillis rtc;
#elif defined(ARDUINO_ARCH_SAMD)
RTCZero rtc;
Expand Down Expand Up @@ -89,6 +89,12 @@ void renesas_setRTC(unsigned long time);
unsigned long renesas_getRTC();
#endif

#ifdef ARDUINO_RASPBERRY_PI_PICO_W
void pico_w_initRTC();
void pico_w_setRTC(unsigned long time);
unsigned long pico_w_getRTC();
#endif

#endif /* HAS_NOTECARD */

/**************************************************************************************
Expand Down Expand Up @@ -355,6 +361,8 @@ void TimeServiceClass::initRTC()
esp8266_initRTC();
#elif defined (ARDUINO_ARCH_RENESAS)
renesas_initRTC();
#elif defined (ARDUINO_RASPBERRY_PI_PICO_W)
pico_w_initRTC();
#else
#error "RTC not available for this architecture"
#endif
Expand All @@ -374,6 +382,8 @@ void TimeServiceClass::setRTC(unsigned long time)
esp8266_setRTC(time);
#elif defined (ARDUINO_ARCH_RENESAS)
renesas_setRTC(time);
#elif defined (ARDUINO_RASPBERRY_PI_PICO_W)
pico_w_setRTC(time);
#else
#error "RTC not available for this architecture"
#endif
Expand All @@ -393,6 +403,8 @@ unsigned long TimeServiceClass::getRTC()
return esp8266_getRTC();
#elif defined (ARDUINO_ARCH_RENESAS)
return renesas_getRTC();
#elif defined (ARDUINO_RASPBERRY_PI_PICO_W)
return pico_w_getRTC();
#else
#error "RTC not available for this architecture"
#endif
Expand Down Expand Up @@ -544,6 +556,23 @@ unsigned long renesas_getRTC()
}
#endif

#ifdef ARDUINO_RASPBERRY_PI_PICO_W
void pico_w_initRTC()
{
rtc.begin();
}

void pico_w_setRTC(unsigned long time)
{
rtc.set(time);
}

unsigned long pico_w_getRTC()
{
return rtc.get();
}
#endif

#endif /* HAS_NOTECARD */

/******************************************************************************
Expand Down
Loading