Skip to content

Commit 4d2b86b

Browse files
committed
base version of nikki.esp32 playground client
base version of nikki.esp32 playground client
1 parent 10a9b05 commit 4d2b86b

File tree

8 files changed

+817
-111
lines changed

8 files changed

+817
-111
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 nikki
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,90 @@
1-
# Arduino Library Manager list
1+
# NikkiClientESP
22

3-
This repository contains the list of libraries in the
4-
[Arduino Library Manager](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries#using-the-library-manager) index.
3+
**NikkiClientESP** is an Arduino library for **ESP32** that connects to the [Nikki.Build Playground](https://nikki.build) — a fun platform for ** rapid prototyping and applied learning ** using real IoT devices.
54

6-
## Table of Contents
7-
8-
<!-- toc -->
9-
10-
- [Frequently asked questions](#frequently-asked-questions)
11-
- [Adding a library to Library Manager](#adding-a-library-to-library-manager)
12-
- [Instructions](#instructions)
13-
- [If the problem is with the pull request:](#if-the-problem-is-with-the-pull-request)
14-
- [If the problem is with the library:](#if-the-problem-is-with-the-library)
15-
- [Changing the URL of a library already in Library Manager](#changing-the-url-of-a-library-already-in-library-manager)
16-
- [Removing a library from Library Manager](#removing-a-library-from-library-manager)
17-
- [Report a problem with Library Manager](#report-a-problem-with-library-manager)
18-
- [Security & Malware Reporting](#security--malware-reporting)
19-
20-
<!-- tocstop -->
21-
22-
## Frequently asked questions
23-
24-
For more information about Arduino Library Manager and how the index is maintained, please see [the FAQ](FAQ.md).
25-
26-
## Adding a library to Library Manager
27-
28-
If you would like to make a library available for installation via Library Manager, just submit a
29-
[pull request](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests)
30-
that adds the repository URL to [the list](repositories.txt). You are welcome to add multiple libraries at once.
31-
32-
See the instructions below for detailed instructions on how to do this via the GitHub web interface.
33-
34-
### Instructions
5+
This library makes it easy for students, makers, and educators to connect their ESP32 boards to the Nikki Playground over **WebSocket (WSS)** and exchange data in real time.
356

367
---
378

38-
⚠ If you behave irresponsibly in your interactions with this repository, your Library Manager Registry privileges will be revoked.
39-
40-
Carefully read and follow the instructions in any comments the bot and human maintainers make on your pull requests. If you are having trouble following the instructions, add a comment that provides a detailed description of the problem you are having and a human maintainer will provide assistance.
9+
## 🚀 Features
4110

42-
Although we have set up automation for the most basic tasks, this repository is maintained by humans. So behave in a manner appropriate for interacting with humans, including clearly communicating what you are hoping to accomplish.
11+
- Connect ESP32 to **Nikki Playground** securely via `wss://`
12+
- Send and receive real-time data using JSON
13+
- Auto-reconnect and status event callbacks
14+
- Great for **IoT learning**, **STEM education**, and **rapid prototypes**
4315

4416
---
4517

46-
1. You may want to first take a look at
47-
[the requirements for admission into the Arduino Library Manager index](FAQ.md#submission-requirements). Each submission will be checked for
48-
compliance before being accepted.
49-
1. Click the following link:<br />
50-
https://github.com/arduino/library-registry/fork<br />
51-
The "**Create a new fork**" page will open.
52-
1. Click the <kbd>Create fork</kbd> button in the "**Create a new fork**" page.<br />
53-
A "**Forking arduino/library-registry**" page will open while the fork is in the process of being created.
54-
1. Wait for the "Forking" process to finish.<br />
55-
The home page of your [fork](https://docs.github.com/get-started/quickstart/fork-a-repo) of the **library-registry** repository will open.
56-
1. Click on the file `repositories.txt` under the list of files you see in that page.<br />
57-
The "**library-registry/repositories.txt**" page will open.
58-
1. Click the pencil icon ("Edit this file") at the right side of the toolbar in the "**library-registry/repositories.txt**" page.<br />
59-
The `repositories.txt` file will open in the online text editor.
60-
1. Add the library repository's URL to the list (it doesn't matter where in the list). This should be the URL of the repository home page. For example:
61-
`https://github.com/arduino-libraries/Servo`
62-
1. Click the <kbd>Commit changes...</kbd> button located near the top right corner of the page.<br />
63-
The "**Commit changes**" dialog will open.
64-
1. Click the <kbd>Commit changes</kbd> button in the "**Commit changes**" dialog.<br />
65-
The "**library-registry/repositories.txt**" page will open.
66-
1. Click the "**library-registry**" link at the top of the "**library-registry/repositories.txt**" page.<br />
67-
The home page of your fork of the **library-registry** repository will open.
68-
1. You should see a banner on the page that says:
69-
70-
> **This branch is 1 commit ahead of arduino:main.**
71-
72-
Click the "**Contribute**" link near the right side of that banner.<br />
73-
A menu will open.
18+
## 📦 Installation
7419

75-
1. Click the <kbd>Open pull request</kbd> button in the menu.<br />
76-
The "**Open a pull request**" page will open.
77-
1. In the **"Open a pull request"** window that opens, click the <kbd>Create pull request</kbd> button.
20+
### Option 1 — From Arduino Library Manager
21+
1. Open Arduino IDE
22+
2. Go to **Tools → Manage Libraries**
23+
3. Search for **"NikkiClientESP"**
24+
4. Click **Install**
7825

79-
The library will be automatically checked for compliance as soon as the pull request is submitted. If no problems were
80-
found, the pull request will be immediately merged and the library will be available for installation via Library
81-
Manager within a day's time.
26+
### Option 2 — From GitHub
27+
1. Download this repo as ZIP
28+
2. In Arduino IDE, go to **Sketch → Include Library → Add .ZIP Library...**
29+
3. Select the downloaded ZIP file
8230

83-
If any problems are found, a bot will comment on the pull request to tell you what is wrong. The problem may be either
84-
with your pull request or with the library.
85-
86-
#### If the problem is with the pull request:
87-
88-
Edit the file in the
89-
[branch](https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches)
90-
you submitted the pull request from in your fork of the `arduino/library-registry` repository, then commit.
91-
92-
Doing this will update the pull request and cause the automated checks to run again.
31+
---
9332

94-
#### If the problem is with the library:
33+
## 🧩 Basic Example
9534

96-
1. Make the necessary fix in the library repository.
97-
1. Increment the `version` value in the library's
98-
[library.properties file](https://arduino.github.io/arduino-cli/latest/library-specification/#library-metadata).
99-
1. Create a
100-
[release](https://docs.github.com/repositories/releasing-projects-on-github/managing-releases-in-a-repository)
101-
or [tag](https://git-scm.com/docs/git-tag). The Library Manager index always uses tagged versions of the libraries,
102-
so even if the development version of the library is compliant, it can't be accepted until the latest release or tag
103-
is compliant. Alternatively, you can redo the existing release/tag if you prefer.
104-
1. Comment on your pull request here in the `arduino/library-registry` repository, mentioning **@ArduinoBot** in the
105-
comment. Doing this will cause the automated check to run again.
35+
```cpp
36+
#include <WiFi.h>
37+
#include <NikkiClientESP.h>
10638

107-
## Changing the URL of a library already in Library Manager
39+
const char* WIFI_SSID = "YourWiFi";
40+
const char* WIFI_PASS = "YourPassword";
10841

109-
Submit a pull request that changes the URL as desired in [repositories.txt](repositories.txt). This can be done by
110-
following [the instructions above](#instructions).
42+
const char* SERVICE_DEF_JSON = R"({
11143
112-
Since this type of request must be reviewed by a human maintainer, please write an explanation in the pull request
113-
description, making it clear that the URL is intentionally being changed.
44+
// replace this line with your serviceDef.json content here
11445
115-
## Removing a library from Library Manager
46+
})";
11647

117-
Submit a pull request that removes the URL from [repositories.txt](repositories.txt). This can be done by following
118-
[the instructions above](#instructions).
48+
const char* SERVICE_TOKEN_JSON = R"({
11949
120-
Since this type of request must be reviewed by a human maintainer, please write an explanation in the pull request
121-
description, making it clear that the URL is intentionally being removed.
50+
// replace this line with your serviceDef.json content here
12251
123-
## Report a problem with Library Manager
52+
})";
12453

125-
First, please take a look at [the FAQ](FAQ.md). If a library release is missing from Library Manager, it is usually
126-
because it was not compliant with all [the requirements](FAQ.md#update-requirements) listed in that document.
54+
NikkiClientESP nikki(SERVICE_DEF_JSON, SERVICE_TOKEN_JSON, true);
12755

128-
This repository is not an appropriate place to request support or report problems with a library. Check the library's
129-
own documentation for instructions or ask on the [Arduino Forum](https://forum.arduino.cc/).
56+
void setup() {
57+
Serial.begin(115200);
58+
WiFi.begin(WIFI_SSID, WIFI_PASS);
59+
while (WiFi.status() != WL_CONNECTED) delay(500);
60+
nikki.begin();
61+
}
13062

131-
If the problem is about something else, please submit an issue report [here](https://github.com/arduino/library-registry/issues/new/choose).
63+
void loop() {
64+
nikki.loop();
65+
if (nikki.isConnected()) {
66+
67+
if (nikki.isConnected()) {
68+
// Send a simple integer
69+
nikki.send(42);
70+
delay(5000);
13271

133-
## Security & Malware Reporting
72+
// Send a string
73+
nikki.send("Hello Nikki!");
74+
delay(5000);
13475

135-
If you think you found a vulnerability, malware or other security-related defect in any Arduino Library projects, please take a look at our security policy and report it to our Security Team 🛡️.
76+
// Send a float
77+
nikki.send(23.7);
78+
delay(5000);
13679

137-
Thank you!
80+
// Send a JSON object
81+
DynamicJsonDocument doc(256);
82+
doc["temp"] = 27.3;
83+
doc["humidity"] = 62;
84+
doc["unit"] = "C";
85+
nikki.send(doc.as<JsonVariant>());
13886

139-
E-mail contact: [email protected]
87+
}
88+
delay(5000);
89+
}
90+
}

examples/basic/basic.ino

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <WiFi.h>
2+
#include <NikkiClientESP.h>
3+
4+
5+
// --- WiFi Credentials ---
6+
const char *WIFI_SSID = "wifiSSD";
7+
const char *WIFI_PASS = "wifiPassword";
8+
9+
// --- Nikki Playground Credentials ---
10+
// (replace with values from NikkiBuild Playground dashboard)
11+
const char *SERVICE_DEF_JSON = R"(
12+
13+
// replace this line with your serviceDef.json content here
14+
15+
16+
)";
17+
18+
const char *SERVICE_TOKEN_JSON = R"(
19+
20+
// replace this line with your serviceToken.json content here
21+
22+
)";
23+
24+
// --- Create Nikki client instance ---..
25+
NikkiClientESP *nikki;
26+
27+
void onMessageReceived(const JsonVariant &msg) {
28+
Serial.println("[Nikki Playground] Received:");
29+
// Serial.println(msg);
30+
}
31+
32+
void onStatusChanged(const String &status, const String &details) {
33+
Serial.println("");
34+
Serial.print("[Status] ");
35+
Serial.print(status);
36+
Serial.print(" -> ");
37+
Serial.println(details);
38+
}
39+
40+
void setup() {
41+
42+
Serial.begin(115200);
43+
delay(1000);
44+
Serial.println("Connecting to WiFi...");
45+
WiFi.begin(WIFI_SSID, WIFI_PASS);
46+
while (WiFi.status() != WL_CONNECTED) {
47+
delay(500);
48+
Serial.print(".");
49+
}
50+
Serial.println("\nWiFi Connected!");
51+
52+
// Setup Nikki client
53+
54+
55+
nikki = new NikkiClientESP(SERVICE_DEF_JSON, SERVICE_TOKEN_JSON);
56+
57+
nikki->setOnMessage(onMessageReceived);
58+
nikki->setOnStatus(onStatusChanged);
59+
60+
// Start Nikki playground connection
61+
nikki->begin();
62+
delay(1000);
63+
Serial.println("Connecting to ws server ");
64+
}
65+
66+
static unsigned long lastSent = 0;
67+
68+
void loop() {
69+
70+
nikki->loop();
71+
72+
// Example: Send temperature reading periodically
73+
if (millis() - lastSent > 2000 && nikki->isConnected()) {
74+
lastSent = millis();
75+
76+
// Send a JSON object
77+
DynamicJsonDocument doc(256);
78+
doc["temp"] = 27.3;
79+
doc["humidity"] = 62;
80+
doc["unit"] = "C";
81+
doc["timeStamp"] = millis();
82+
nikki->send(doc);
83+
Serial.println("[Sent to Nikki Playground] ");
84+
}
85+
}

0 commit comments

Comments
 (0)